Skip to content

Commit

Permalink
release: add arm64 build
Browse files Browse the repository at this point in the history
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Sep 3, 2021
1 parent 963e014 commit 16cf452
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
- name: install deps
run: |
sudo apt -qq update
sudo apt -qq install gperf
sudo apt -qq install gperf gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: make release
run: make release
- name: upload artifacts
Expand Down
57 changes: 40 additions & 17 deletions script/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,45 @@ set -e
project="runc"
root="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")"

# Due to libseccomp being LGPL we must include its sources,
# so download, install and build against it.
function build_libseccomp() {
local ver="2.5.1"
local tar="libseccomp-${ver}.tar.gz"
local builddir="$1"

# Download.
wget "https://github.com/seccomp/libseccomp/releases/download/v${ver}/${tar}"{,.asc}

# Build and install.
tar xf "$tar"
pushd "libseccomp-${ver}"

LIBSECCOMP_PREFIX="$(mktemp -d)"
./configure --prefix="$LIBSECCOMP_PREFIX" --enable-static --disable-shared
make install
make clean

# Build and install for arm64.
LIBSECCOMP_PREFIX_ARM64="$(mktemp -d)"
./configure --host aarch64-linux-gnu --prefix="$LIBSECCOMP_PREFIX_ARM64" --enable-static --disable-shared
make install

# Put the sources to builddir.
mv "$tar"{,.asc} "$builddir"

# Clean.
popd
rm -rf "libseccomp-${LIBSECCOMP_PREFIX}"
}

# This function takes an output path as an argument, where the built
# (preferably static) binary should be placed.
function build_project() {
local builddir
builddir="$(dirname "$1")"

# Due to libseccomp being LGPL we must include its sources,
# so download, install and build against it.

local libseccomp_ver='2.5.1'
local tarball="libseccomp-${libseccomp_ver}.tar.gz"
local prefix
prefix="$(mktemp -d)"
wget "https://github.com/seccomp/libseccomp/releases/download/v${libseccomp_ver}/${tarball}"{,.asc}
tar xf "$tarball"
(
cd "libseccomp-${libseccomp_ver}"
./configure --prefix="$prefix" --enable-static --disable-shared
make install
)
mv "$tarball"{,.asc} "$builddir"
build_libseccomp "$builddir"

# For reproducible builds, add these to EXTRA_LDFLAGS:
# -w to disable DWARF generation;
Expand All @@ -51,10 +69,15 @@ function build_project() {
# Add -a to go build flags to make sure it links against
# the provided libseccomp, not the system one (otherwise
# it can reuse cached pkg-config results).
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static
rm -rf "$prefix"
make -C "$root" PKG_CONFIG_PATH="${LIBSECCOMP_PREFIX}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static
strip "$root/$project"
mv "$root/$project" "$1"
# Build for arm64.
CGO_ENABLED=1 GOARCH=arm64 CC=aarch64-linux-gnu-gcc make -C "$root" PKG_CONFIG_PATH="${LIBSECCOMP_PREFIX_ARM64}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" EXTRA_LDFLAGS="${ldflags}" static
strip "$root/$project"
mv "$root/$project" "$1/$project".arm64
# Cleanup.
rm -rf "${LIBSECCOMP_PREFIX}" "${LIBSECCOMP_PREFIX_ARM64}"
}

# End of the easy-to-configure portion.
Expand Down

0 comments on commit 16cf452

Please sign in to comment.