...

Text file src/github.com/opencontainers/runc/script/seccomp.sh

Documentation: github.com/opencontainers/runc/script

     1#!/bin/bash
     2
     3set -e -u -o pipefail
     4
     5# shellcheck source=./script/lib.sh
     6source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
     7
     8# sha256 checksums for seccomp release tarballs.
     9declare -A SECCOMP_SHA256=(
    10	["2.5.4"]=d82902400405cf0068574ef3dc1fe5f5926207543ba1ae6f8e7a1576351dcbdb
    11)
    12
    13# Due to libseccomp being LGPL we must include its sources,
    14# so download, install and build against it.
    15# Parameters:
    16#  $1 -- libseccomp version to download and build.
    17#  $2 -- destination directory.
    18#  $@ -- additional architectures to cross-compile for.
    19function build_libseccomp() {
    20	local ver="$1"
    21	shift
    22	local dest="$1"
    23	shift
    24	local arches=("$@")
    25	local tar="libseccomp-${ver}.tar.gz"
    26
    27	# Download, check, and extract.
    28	wget "https://github.com/seccomp/libseccomp/releases/download/v${ver}/${tar}"{,.asc}
    29	sha256sum --strict --check - <<<"${SECCOMP_SHA256[${ver}]} *${tar}"
    30
    31	local srcdir
    32	srcdir="$(mktemp -d)"
    33	tar xf "$tar" -C "$srcdir"
    34	pushd "$srcdir/libseccomp-$ver" || return
    35
    36	# Build natively and install to /usr/local.
    37	./configure \
    38		--prefix="$dest" --libdir="$dest/lib" \
    39		--enable-static --enable-shared
    40	make install
    41	make clean
    42
    43	# Build and install for additional architectures.
    44	local arch
    45	for arch in "${arches[@]}"; do
    46		set_cross_vars "$arch"
    47		./configure --host "$HOST" \
    48			--prefix="$dest/$arch" --libdir="$dest/$arch/lib" \
    49			--enable-static --enable-shared
    50		make install
    51		make clean
    52	done
    53
    54	# Place the source tarball to $dest/src.
    55	popd || return
    56	mkdir "$dest"/src
    57	mv "$tar"{,.asc} "$dest"/src
    58}
    59
    60if [ $# -lt 2 ]; then
    61	echo "Usage: seccomp.sh <version> <dest-dir> [<extra-arch> ...]" >&2
    62	exit 1
    63fi
    64
    65build_libseccomp "$@"

View as plain text