Files
runc/script/seccomp.sh
T
Kir Kolyshkin f95063ede4 Dockerfile: fix for seccomp
Commit f30244ee1b broke the scenario of using Dockefile for
anything but making a release. This happened because it installed
native libseccomp build to a temporary directory, and so linking against
libseccomp required setting a few environment variables.

Let's fix this, and simplify libseccomp installation. Instead of using
temporary directories, let's install native libseccomp to a specified
directory, all the cross-builds to its subdirectories, and set
PKG_CONFIG_PATH and LD_LIBRARY_PATH in Dockerfile so that the built
library will found by pkg-config and the dynamic linker (without setting
LD_LIBRARY_PATH, ld picks up distro-provided libseccomp.so).

While at it, fix some bugs introduced by the abovementioned commit.

This fixes building runc in  make targets like shell, dbuild,
integration, unittest -- i.e. those that depend on runcimage.

Fixes: f30244ee1b
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-10-01 10:20:56 -07:00

59 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
set -e -u -o pipefail
# 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.
# $@ -- additional architectures to cross-compile for.
function build_libseccomp() {
local ver="$1"
shift
local dest="$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 natively and install to /usr/local.
./configure \
--prefix="$dest" --libdir="$dest/lib" \
--enable-static --enable-shared
make install
make clean
# Build and install for additional architectures.
local arch
for arch in "${arches[@]}"; do
set_cross_vars "$arch"
./configure --host "$HOST" \
--prefix="$dest/$arch" --libdir="$dest/$arch/lib" \
--enable-static --enable-shared
make install
make clean
done
# Place the source tarball to $dest/src.
popd || return
mkdir "$dest"/src
mv "$tar"{,.asc} "$dest"/src
}
if [ $# -lt 4 ]; then
echo "Usage: seccomp.sh <version> <dest-dir> [<extra-arch> ...]" >&2
exit 1
fi
build_libseccomp "$@"