mirror of https://github.com/upx/upx.git
all: remove unused scripts
This commit is contained in:
parent
57b2fb4c62
commit
9a0b5b65b8
|
@ -1,19 +0,0 @@
|
|||
#! /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")"
|
||||
|
||||
# create the image from Dockerfile
|
||||
# using a rootless Podman container
|
||||
|
||||
# NOTE: this image is based on rebuild-stubs/upx-stubtools-20221212-v7,
|
||||
# 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-ubuntu2204-20230721-v3
|
||||
[[ $1 == --print-image ]] && echo "$image" && exit 0
|
||||
|
||||
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
|
@ -1,40 +0,0 @@
|
|||
#! /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")"
|
||||
|
||||
# list all system packages that are installed in the image
|
||||
# using a rootless Podman container
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
||||
|
||||
echo 'Packages:'
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
podman run "${flags[@]}" "$image" bash -c $'dpkg -l | sed \'s/ *$//\' | LC_ALL=C sort'
|
||||
|
||||
echo
|
||||
echo 'Packages sorted by Installed-Size:'
|
||||
podman run "${flags[@]}" "$image" bash -c $'awk \'
|
||||
BEGIN {
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
{
|
||||
if ($1 == "Architecture:") arch = $2;
|
||||
if ($1 == "Installed-Size:") size = $2;
|
||||
if ($1 == "Package:") package = $2;
|
||||
if ($1 == "") {
|
||||
printf("%9d %-40s %s\\n", size, package, arch);
|
||||
count += 1; total += size;
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("%9d ===== TOTAL (%d packages)\\n", total, count);
|
||||
}
|
||||
\' /var/lib/dpkg/status | LC_ALL=C sort -rn'
|
|
@ -1,60 +0,0 @@
|
|||
#! /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")"
|
||||
|
||||
# run an interactive shell in the image
|
||||
# using a rootless Podman container
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
flags+=( -ti -e TERM="$TERM" ) # allocate an interactive pseudo-tty and pass $TERM
|
||||
if [[ 1 == 1 ]]; then
|
||||
# run as user upx 2000:2000
|
||||
flags+=( --user 2000 )
|
||||
# map container users 0..999 to subuid-users 1..1000, and map container user 2000 to current host user
|
||||
flags+=( --uidmap=0:1:1000 --uidmap=2000:0:1 )
|
||||
# map container groups 0..999 to subgid-groups 1..1000, and map container group 2000 to current host group
|
||||
flags+=( --gidmap=0:1:1000 --gidmap=2000:0:1 )
|
||||
# NOTE: we mount the upx top-level directory read-write under /home/upx/src/upx
|
||||
# INFO: SELinux users *may* have to add ":z" to the volume mount flags; check the docs!
|
||||
flags+=( -v "${argv0dir}/../../..:/home/upx/src/upx" )
|
||||
flags+=( -w /home/upx/src/upx ) # set working directory
|
||||
flags+=( --tmpfs /home/upx/.cache:rw,exec ) # mount a writeable tmpfs
|
||||
flags+=( --tmpfs /home/upx/.local:rw,exec ) # mount a writeable tmpfs
|
||||
else
|
||||
# run as user root 0:0
|
||||
# ONLY FOR DEBUGGING THE IMAGE
|
||||
# map container user/group 0 to current host user/group
|
||||
flags+=( --user 0 )
|
||||
fi
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# now we can cross-compile UPX for Windows:
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/cross-windows-mingw64/release
|
||||
# make build/extra/cross-windows-mingw64/release
|
||||
|
||||
# and we can run the clang Static Analyzer (scan-build)
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/scan-build/release
|
||||
# make build/extra/scan-build/release
|
||||
|
||||
# and lots of other cross-compilers are installed; see "ls /usr/bin/*g++*"
|
||||
|
||||
# and finally see
|
||||
# ./misc/podman/cross-compile-upx-ubuntu/build-all-inside-container.sh
|
||||
# after running that script we can do cool things like:
|
||||
# cd /home/upx/src/upx/build/cross-compile-upx-ubuntu2204/alpha-linux-gnu/debug
|
||||
# qemu-alpha -L /usr/alpha-linux-gnu ./upx --version
|
||||
# cd /home/upx/src/upx/build/cross-compile-upx-ubuntu2204/hppa-linux-gnu/debug
|
||||
# qemu-hppa -L /usr/hppa-linux-gnu ./upx --version
|
||||
# (similar for many other architectures/builds)
|
|
@ -1,56 +0,0 @@
|
|||
# NOTE: this image is based on rebuild-stubs/upx-stubtools-20221212-v7,
|
||||
# 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-20221212-v7
|
||||
ENV UPX_CONTAINER_IMAGE_NAME=upx-cross-compile-ubuntu2204-20230721-v3
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
USER root
|
||||
|
||||
# Ubuntu 22.04
|
||||
RUN apt-get update && apt-get upgrade -y \
|
||||
&& apt-get install -y \
|
||||
# Linux glibc cross compilers
|
||||
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 \
|
||||
# Linux glibc cross compilers - ILP32 on 64-bit CPUs
|
||||
g++-x86-64-linux-gnux32 \
|
||||
# Windows cross compilers
|
||||
g++-mingw-w64-i686 \
|
||||
g++-mingw-w64-x86-64 \
|
||||
# make sure that we use posix-threads (pthread/winpthreads) and NOT win32-threads
|
||||
&& for f in i686-w64-mingw32-g++ i686-w64-mingw32-gcc x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc; do update-alternatives --set $f /usr/bin/$f-posix; done \
|
||||
&& true
|
||||
RUN apt-get install -y \
|
||||
# clang-14 and tools
|
||||
clang-14 clang-format-14 clang-tidy-14 clang-tools-14 lldb-14 llvm-14 \
|
||||
# QEMU and Wine
|
||||
qemu-system qemu-user wine wine32:i386 wine64 \
|
||||
# misc
|
||||
gdb lsb-release valgrind \
|
||||
&& true
|
||||
RUN cd /usr/bin \
|
||||
# create unversioned clang symlinks in /usr/local/bin
|
||||
&& for f in clang*-14 llvm-*-14 scan-*-14; do ln -s -v ../../bin/$f /usr/local/bin/${f%-14}; done \
|
||||
&& ln -s -v ../../bin/obj2yaml-14 /usr/local/bin/llvm-obj2yaml \
|
||||
&& ln -s -v ../../bin/yaml2obj-14 /usr/local/bin/llvm-yaml2obj \
|
||||
&& true
|
||||
|
||||
# switch back to default user upx:upx 2000:2000
|
||||
USER upx
|
|
@ -1,99 +0,0 @@
|
|||
#! /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/../../.." || exit 1
|
||||
pwd
|
||||
test -f doc/upx.pod || exit 1 # sanity check
|
||||
test -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 sanitize link errors with current MinGW-w64 versions; link libstdc++ statically
|
||||
i686-w64-mingw32)
|
||||
cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON
|
||||
CC="$CC -static"; CXX="$CXX -static" ;;
|
||||
x86_64-w64-mingw32)
|
||||
cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON
|
||||
CC="$CC -static"; CXX="$CXX -static" ;;
|
||||
# avoid warnings about arm libstdc++ ABI change in gcc-7
|
||||
arm-linux-*) CXX="$CXX -Wno-psabi" ;;
|
||||
esac
|
||||
if [[ 1 == 1 ]]; then
|
||||
# prefer building with Ninja (ninja-build)
|
||||
cmake_config_flags="$cmake_config_flags -G Ninja -DUPX_CONFIG_CMAKE_DISABLE_INSTALL=ON"
|
||||
fi
|
||||
# for all build types
|
||||
for build_type in Debug Release; do
|
||||
bdir="build/cross-compile-upx-ubuntu2204/$toolchain/${build_type,,}"
|
||||
mkdir -p "$bdir"
|
||||
# run_config
|
||||
if [[ ! -f $bdir/CMakeCache.txt ]]; then
|
||||
export CMAKE_REQUIRED_QUIET=OFF
|
||||
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
|
File diff suppressed because it is too large
Load Diff
|
@ -1,149 +0,0 @@
|
|||
#! /bin/sh
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e
|
||||
|
||||
#
|
||||
# build UPX "by hand", using a POSIX-compliant shell and
|
||||
# a minimal number of compilation flags
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# uses optional environment variables: AR, CC, CXX, OPTIMIZE, VERBOSE
|
||||
# and optional settings for top_srcdir, obj_suffix and XXX_extra_flags
|
||||
|
||||
# shell init
|
||||
### set -x # enable logging
|
||||
DUALCASE=1; export DUALCASE # for MKS sh
|
||||
test -n "${ZSH_VERSION+set}" && emulate sh # for zsh
|
||||
my_argv0="$0"
|
||||
|
||||
# toolchain settings and compilation flags
|
||||
AR="${AR:-ar}"
|
||||
CC="${CC:-cc}"
|
||||
CXX="${CXX:-c++ -std=gnu++17}"
|
||||
# HINT: use "export AR=false" if "$AR rcs" does not work on your system; see below
|
||||
if test "x$AR" = "x0" || test "x$AR" = "xfalse" || test "x$AR" = "x/bin/false"; then
|
||||
AR="" # do not use $AR
|
||||
fi
|
||||
if test -z "${mandatory_flags+set}"; then
|
||||
# protect against security threats caused by misguided compiler "optimizations"
|
||||
mandatory_flags="-fno-strict-aliasing -fno-strict-overflow -funsigned-char"
|
||||
fi
|
||||
if test -z "${sensible_flags+set}"; then
|
||||
# not mandatory but good practice when using <windows.h>:
|
||||
sensible_flags="-DWIN32_LEAN_AND_MEAN"
|
||||
if test "x$OPTIMIZE" != "x" && test "x$OPTIMIZE" != "x0"; then
|
||||
# not mandatory and not minimal, but usually a good idea:
|
||||
sensible_flags="-Wall -O2 $sensible_flags"
|
||||
fi
|
||||
fi
|
||||
CC="$CC $sensible_flags $mandatory_flags"
|
||||
CXX="$CXX $sensible_flags $mandatory_flags"
|
||||
|
||||
# go to upx top-level directory
|
||||
# HINT: set "top_srcdir" manually if your system does not have "readlink -f"
|
||||
if test "x$top_srcdir" = "x"; then
|
||||
my_argv0abs="$(readlink -fn "$my_argv0")"
|
||||
test "x$my_argv0abs" = "x" && exit 1
|
||||
my_argv0dir="$(dirname "$my_argv0abs")"
|
||||
test "x$my_argv0dir" = "x" && exit 1
|
||||
cd "$my_argv0dir/../.." || exit 1
|
||||
else
|
||||
cd "$top_srcdir" || exit 1
|
||||
fi
|
||||
top_srcdir="$(pwd)" # absolute
|
||||
rel_top_srcdir=. # relative top_srcdir
|
||||
echo "# current directory: '$(pwd)'"
|
||||
test -f doc/upx.pod || exit 1 # sanity check
|
||||
test -f src/version.h || exit 1 # sanity check
|
||||
rm -rf ./build/by-hand # WARNING: existing build-directory gets deleted!
|
||||
|
||||
# helper function
|
||||
run() {
|
||||
if test 0 = 1; then
|
||||
# DEBUG dry-run: print command, but don't actually run unless $1 is "+"
|
||||
if test "x$1" = "x+"; then
|
||||
shift; echo "$@"; "$@"; return
|
||||
fi
|
||||
shift; echo "$@"; return
|
||||
fi
|
||||
# print short info and run command
|
||||
test "x$1" != "x" && test "x$1" != "x+" && echo "$1"
|
||||
shift
|
||||
if test "x$VERBOSE" != "x" && test "x$VERBOSE" != "x0"; then
|
||||
# print full command
|
||||
echo " $@"
|
||||
fi
|
||||
"$@"
|
||||
}
|
||||
|
||||
# helper function
|
||||
check_submodule() {
|
||||
#local ff # "local" seems unsupported by some versions of ksh
|
||||
for ff in COPYING LICENSE LICENSE.txt; do
|
||||
if test -f "$rel_top_srcdir/vendor/$1/$ff"; then
|
||||
# create and enter build directory; updates global $rel_top_srcdir
|
||||
run "+" cd "$rel_top_srcdir" || exit 1
|
||||
rel_top_srcdir=.
|
||||
echo "#===== build $1 ====="
|
||||
run "+" mkdir "build/by-hand/$1"
|
||||
run "+" cd "build/by-hand/$1" || exit 1
|
||||
rel_top_srcdir=../../..
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# build
|
||||
upx_submodule_defs=
|
||||
run "+" mkdir -p "build/by-hand"
|
||||
if check_submodule bzip2; then
|
||||
upx_submodule_defs="$upx_submodule_defs -DWITH_BZIP2"
|
||||
test -z "${bzip2_extra_flags+set}" && bzip2_extra_flags="-DBZ_NO_STDIO"
|
||||
for f in "$rel_top_srcdir"/vendor/bzip2/*.c; do
|
||||
run "CC $f" $CC $bzip2_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule ucl; then
|
||||
#upx_submodule_defs="$upx_submodule_defs -DWITH_UCL"
|
||||
test -z "${ucl_extra_flags+set}" && ucl_extra_flags=
|
||||
for f in "$rel_top_srcdir"/vendor/ucl/src/*.c; do
|
||||
run "CC $f" $CC -I"$rel_top_srcdir"/vendor/ucl/include -I"$rel_top_srcdir"/vendor/ucl $ucl_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule zlib; then
|
||||
#upx_submodule_defs="$upx_submodule_defs -DWITH_ZLIB"
|
||||
test -z "${zlib_extra_flags+set}" && zlib_extra_flags="-DHAVE_UNISTD_H -DHAVE_VSNPRINTF"
|
||||
for f in "$rel_top_srcdir"/vendor/zlib/*.c; do
|
||||
run "CC $f" $CC $zlib_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule zstd; then
|
||||
upx_submodule_defs="$upx_submodule_defs -DWITH_ZSTD"
|
||||
test -z "${zstd_extra_flags+set}" && zstd_extra_flags="-DDYNAMIC_BMI2=0 -DZSTD_DISABLE_ASM"
|
||||
for f in "$rel_top_srcdir"/vendor/zstd/lib/*/*.c; do
|
||||
run "CC $f" $CC $zstd_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
run "+" cd "$rel_top_srcdir" || exit 1
|
||||
rel_top_srcdir=.
|
||||
echo "#===== build UPX ====="
|
||||
run "+" cd "build/by-hand" || exit 1
|
||||
rel_top_srcdir=../..
|
||||
for f in "$rel_top_srcdir"/src/*.cpp "$rel_top_srcdir"/src/*/*.cpp; do
|
||||
run "CXX $f" $CXX -I"$rel_top_srcdir"/vendor $upx_submodule_defs -c "$f"
|
||||
done
|
||||
# echo "#===== link UPX ====="
|
||||
test "x$obj_suffix" = "x" && obj_suffix=.o
|
||||
if test "x$AR" = "x"; then
|
||||
# link without using $AR
|
||||
run "CXX upx" $CXX -o upx *${obj_suffix} */*${obj_suffix}
|
||||
else
|
||||
run "AR libupx" $AR rcs ${AR_LIBFILE:-libupx_submodules.a} */*${obj_suffix}
|
||||
run "CXX upx" $CXX -o upx *${obj_suffix} -L. -lupx_submodules
|
||||
fi
|
||||
echo "# current directory: '$(pwd)'"
|
||||
ls -l upx*
|
||||
|
||||
echo "# All done."
|
Loading…
Reference in New Issue