script/release.sh: add -a to force rebuild

https://golang.org/cmd/go/#hdr-Build_and_test_caching says:

> If you have made changes to the C libraries on your system, you will
> need to clean the cache explicitly or else use the -a build flag
> (see 'go help build') to force rebuilding of packages that depend
> on the updated C libraries.

This means that:

1. We need to either 'go clean -cache' or 'go build -a' when building
   the release binary. Adding '-a' seems less intrusive / more focused.

2. The check for existing libseccomp.a (added by commit d748280aa)
   is no longer needed.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-05-03 10:21:24 -07:00
parent c2c35aefee
commit 06a9ea36de
+4 -20
View File
@@ -30,25 +30,6 @@ function build_project() {
# Due to libseccomp being LGPL we must include its sources, # Due to libseccomp being LGPL we must include its sources,
# so download, install and build against it. # so download, install and build against it.
# Sanity check: check that the build won't use distro-provided
# libseccomp.a. If this is the case, explain and abort.
#
# Note go is not used here as it caches the build heavily,
# including, apparently, the results of pkg-config.
# shellcheck disable=SC2046
if read -ra flags < <(pkg-config --libs --cflags libseccomp 2>/dev/null) &&
cat <<EOF | gcc -static -x c -o /dev/null - "${flags[@]}"; then
#include <seccomp.h>
int main(void) { seccomp_version(); return 0; }
EOF
set +x
echo >&2
echo "Distro-provided libseccomp static library is installed." >&2
echo "Unable to build a static binary against own libsecomp." >&2
echo "Please uninstall libseccomp-static to fix." >&2
exit 1
fi
local libseccomp_ver='2.5.1' local libseccomp_ver='2.5.1'
local tarball="libseccomp-${libseccomp_ver}.tar.gz" local tarball="libseccomp-${libseccomp_ver}.tar.gz"
local prefix local prefix
@@ -62,7 +43,10 @@ EOF
) )
mv "$tarball"{,.asc} "$builddir" mv "$tarball"{,.asc} "$builddir"
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= static # 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" static
rm -rf "$prefix" rm -rf "$prefix"
mv "$root/$project" "$1" mv "$root/$project" "$1"
} }