diff --git a/misc/cross-compile-upx-with-podman/10-create-image.sh b/misc/cross-compile-upx-with-podman/10-create-image.sh index 77de2c67..b12ff991 100755 --- a/misc/cross-compile-upx-with-podman/10-create-image.sh +++ b/misc/cross-compile-upx-with-podman/10-create-image.sh @@ -6,10 +6,10 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")" # create the image from Dockerfile # using a rootless Podman container -# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20210104-v8, +# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20210104-v10, # so you have to create that image first # WARNING: we install many packages, so the resulting image needs A LOT of disk space! -image=upx-cross-compile-20221108-v8 +image=upx-cross-compile-20221108-v10 podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir" diff --git a/misc/cross-compile-upx-with-podman/20-image-run-shell.sh b/misc/cross-compile-upx-with-podman/20-image-run-shell.sh index a2ab12b9..3e807210 100755 --- a/misc/cross-compile-upx-with-podman/20-image-run-shell.sh +++ b/misc/cross-compile-upx-with-podman/20-image-run-shell.sh @@ -6,7 +6,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")" # run an interactive shell in the image # using a rootless Podman container -image=upx-cross-compile-20221108-v8 +image=upx-cross-compile-20221108-v10 flags=( -ti --read-only --rm ) flags+=( --cap-drop=all ) # drop all capabilities diff --git a/misc/cross-compile-upx-with-podman/Dockerfile b/misc/cross-compile-upx-with-podman/Dockerfile index d5da8558..7ed818c9 100644 --- a/misc/cross-compile-upx-with-podman/Dockerfile +++ b/misc/cross-compile-upx-with-podman/Dockerfile @@ -1,7 +1,8 @@ -# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20210104-v8, +# NOTE: this image is based on rebuild-stubs-with-upx/upx-stubtools-20210104-v10, # so you have to create that image first # WARNING: we install many packages, so the resulting image needs A LOT of disk space! -FROM localhost/upx-stubtools-20210104-v8 +FROM localhost/upx-stubtools-20210104-v10 +ENV UPX_CONTAINER_IMAGE_NAME=upx-cross-compile-20221108-v10 ARG DEBIAN_FRONTEND=noninteractive USER root diff --git a/misc/cross-compile-upx-with-podman/build-all-inside-container.sh b/misc/cross-compile-upx-with-podman/build-all-inside-container.sh new file mode 100755 index 00000000..51eda618 --- /dev/null +++ b/misc/cross-compile-upx-with-podman/build-all-inside-container.sh @@ -0,0 +1,87 @@ +#! /usr/bin/env bash +## vim:set ts=4 sw=4 et: +set -e; set -o pipefail +argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")" + +# build UPX for 21 targets; must be run inside the container! +# using a rootless Podman container + +# simple sanity check that we are indeed running inside the container +if [[ $UPX_CONTAINER_IMAGE_NAME != upx-cross-compile-* ]]; then + echo "$argv0: NOTE: please run this script *inside* the container" + exit 1 +fi + +# go to upx top-level directory +cd $argv0dir/../.. +pwd +[[ -f src/version.h ]] || exit 1 # sanity check + +function run_config_and_build { + # requires: AR CC CXX RANLIB + local toolchain=$1 + local cmake_config_flags build_type bdir + # cmake flags + cmake_config_flags= + case $toolchain in + # these old architectures do not support sanitize + alpha-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; + hppa-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; + # avoid link errors with Windows cross compilers; need to install some more support libs?? + i686-w64-mingw32) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; + x86_64-w64-mingw32) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;; + esac + # for all build types + for build_type in Debug Release; do + bdir=build/cross/$toolchain/${build_type,,} + mkdir -p $bdir + # run_config + if [[ ! -f $bdir/CMakeCache.txt ]]; then + cmake -S . -B $bdir -DCMAKE_BUILD_TYPE=$build_type -DCMAKE_AR=$AR -DCMAKE_RANLIB=$RANLIB $cmake_config_flags + fi + # run_build + cmake --build $bdir --config $build_type --parallel + done +} + +# see Dockerfile for packages +for package in \ + g++-aarch64-linux-gnu \ + g++-alpha-linux-gnu \ + g++-arm-linux-gnueabi \ + g++-arm-linux-gnueabihf \ + g++-hppa-linux-gnu \ + g++-i686-linux-gnu \ + g++-m68k-linux-gnu \ + g++-mips-linux-gnu \ + g++-mipsel-linux-gnu \ + g++-mips64-linux-gnuabi64 \ + g++-mips64el-linux-gnuabi64 \ + g++-powerpc-linux-gnu \ + g++-powerpc64-linux-gnu \ + g++-powerpc64le-linux-gnu \ + g++-riscv64-linux-gnu \ + g++-s390x-linux-gnu \ + g++-sh4-linux-gnu \ + g++-sparc64-linux-gnu \ + g++-x86-64-linux-gnux32 \ + g++-mingw-w64-i686 \ + g++-mingw-w64-x86-64 +do + # setup toolchain and environment variables + toolchain=$package + toolchain=${toolchain/-x86-64/-x86_64} + toolchain=${toolchain/g++-/} + case $toolchain in + mingw-w64-i686) toolchain=i686-w64-mingw32 ;; + mingw-w64-x86_64) toolchain=x86_64-w64-mingw32 ;; + esac + echo "========== $toolchain" + export AR=/usr/bin/${toolchain}-ar + export CC=/usr/bin/${toolchain}-gcc + export CXX=/usr/bin/${toolchain}-g++ + export RANLIB=/usr/bin/${toolchain}-ranlib + ls -l $AR $CC $CXX $RANLIB + run_config_and_build $toolchain + unset AR CC CXX RANLIB +done diff --git a/misc/rebuild-stubs-with-podman/10-create-image.sh b/misc/rebuild-stubs-with-podman/10-create-image.sh index 3efbfc02..8627c2a3 100755 --- a/misc/rebuild-stubs-with-podman/10-create-image.sh +++ b/misc/rebuild-stubs-with-podman/10-create-image.sh @@ -6,7 +6,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")" # create the image from Dockerfile # using a rootless Podman container -image=upx-stubtools-20210104-v8 +image=upx-stubtools-20210104-v10 podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir" diff --git a/misc/rebuild-stubs-with-podman/20-image-run-shell.sh b/misc/rebuild-stubs-with-podman/20-image-run-shell.sh index d1e0a8dd..62e74ae9 100755 --- a/misc/rebuild-stubs-with-podman/20-image-run-shell.sh +++ b/misc/rebuild-stubs-with-podman/20-image-run-shell.sh @@ -6,7 +6,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")" # run an interactive shell in the image # using a rootless Podman container -image=upx-stubtools-20210104-v8 +image=upx-stubtools-20210104-v10 flags=( -ti --read-only --rm ) flags+=( --cap-drop=all ) # drop all capabilities diff --git a/misc/rebuild-stubs-with-podman/Dockerfile b/misc/rebuild-stubs-with-podman/Dockerfile index ea8f0496..fbf5db71 100644 --- a/misc/rebuild-stubs-with-podman/Dockerfile +++ b/misc/rebuild-stubs-with-podman/Dockerfile @@ -1,4 +1,5 @@ FROM docker.io/library/ubuntu:22.04 +ENV UPX_CONTAINER_IMAGE_NAME=upx-stubtools-20210104-v10 ARG DEBIAN_FRONTEND=noninteractive ENV LANG=C.UTF-8