mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 14:13:58 +08:00
f30244ee1b
This implements cross-build for "make release", moving the build into a container. This way we can support arm, arm64, ppc, and whatnot. * script/seccomp.sh: separate out of script/release.sh, amend to support cross-compile and save needed environment variables to a file. * Dockerfile: add installing libseccomp from source, as this is needed for release builds. * script/release.sh: amend to support more architectures in addition to the native build. Additional arches can be added by specifying "-a <arch>" argument (can be specified multiple times), or "make RELEASE_ARGS="-a arm64" release" if called via make. All supported architectures can be enabled via "make releaseall". * Makefile: move "release" target to "localrelease", add "release" and "releaseall" targets to build via the Dockerfile. This is done because most distros (including Fedora and openSUSE) lack cross-glibc, which is needed to cross-compile libseccomp. * Makefile: remove 'cross' and 'localcross' targets, as this is now done by the release script. * .github/workflows/validate.yum: amend the release CI job to cross-build for supported architectures, remove cross job. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
65 lines
1.6 KiB
Bash
Executable File
65 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# shellcheck source=./script/lib.sh
|
|
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
|
|
|
|
# Due to libseccomp being LGPL we must include its sources,
|
|
# so download, install and build against it.
|
|
# Parameters:
|
|
# $1 -- libseccomp version to download and build.
|
|
# $2 -- destination directory to put the source tarball in.
|
|
# $3 -- file to append LIBSECCOMP_PREFIX*= environment variables to
|
|
# (can be sourced to get install paths).
|
|
# $@ -- additional architectures to cross-compile for.
|
|
function build_libseccomp() {
|
|
local ver="$1"
|
|
shift
|
|
local dest="$1"
|
|
shift
|
|
local varfile="$1"
|
|
shift
|
|
local arches=("$@")
|
|
local tar="libseccomp-${ver}.tar.gz"
|
|
|
|
# Download and extract.
|
|
wget "https://github.com/seccomp/libseccomp/releases/download/v${ver}/${tar}"{,.asc}
|
|
local srcdir
|
|
srcdir="$(mktemp -d)"
|
|
tar xf "$tar" -C "$srcdir"
|
|
pushd "$srcdir/libseccomp-$ver" || return
|
|
|
|
# Build and install natively.
|
|
local prefix
|
|
prefix="$(mktemp -d)"
|
|
./configure \
|
|
--prefix="$prefix" --libdir="$prefix/lib" \
|
|
--enable-static --disable-shared
|
|
echo LIBSECCOMP_PREFIX="$prefix" >>"$varfile"
|
|
make install
|
|
make clean
|
|
|
|
# Build and install for additional architectures.
|
|
local arch
|
|
for arch in "${arches[@]}"; do
|
|
prefix="$(mktemp -d)"
|
|
set_cross_vars "$arch"
|
|
./configure --host "$HOST" \
|
|
--prefix="$prefix" --libdir="$prefix/lib" \
|
|
--enable-static --enable-shared
|
|
make install
|
|
make clean
|
|
echo "LIBSECCOMP_PREFIX_${arch}=$prefix" >>"$varfile"
|
|
done
|
|
|
|
# Place the source tarball to $dest.
|
|
popd || return
|
|
mv "$tar"{,.asc} "$dest"
|
|
}
|
|
|
|
if $# -lt 4; then
|
|
echo "Usage: seccomp.sh <version> <dest-dir> <var-file> [<extra-arch> ...]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
build_libseccomp "$@"
|