diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfe07bb4..7e5686c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,9 @@ jobs: run: | make -C build/extra/gcc-m32/debug test make -C build/extra/gcc-m32/release test + - name: 'Run file system test suite' + run: | + env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/test_symlinks.sh - name: 'Run test suite build/extra/gcc/release' run: | export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" @@ -142,6 +145,8 @@ jobs: fail-fast: false matrix: include: + # NOTE: macos does not have "env -C"; only with coreutils + # NOTE: macos-11 does not have "readlink -f"; only on macos >= 12 or with coreutils - { os: macos-11, gcc: gcc-10, gxx: 'g++-10', testsuite: true } - { os: macos-12, gcc: gcc-11, gxx: 'g++-11', testsuite: true } - { os: macos-13, gcc: gcc-12, gxx: 'g++-12', testsuite: true } @@ -201,6 +206,14 @@ jobs: run: | make -C build/extra/clang/debug test make -C build/extra/clang/release test + - name: 'Run file system test suite' + if: ${{ matrix.testsuite }} # for coreutils readlink + run: | + ## macos-11 does not have "readlink -f" + ## testsuite="$(readlink -fn ./misc/testsuite/test_symlinks.sh)" + ## (cd build/extra/clang/release && upx_exe=./upx bash "$testsuite") + export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" + env -C build/extra/clang/release bash "$PWD"/misc/testsuite/test_symlinks.sh - name: 'Run test suite build/extra/clang/release' if: ${{ matrix.testsuite }} run: | diff --git a/.github/workflows/weekly-ci-cc-alpine-linux.yml b/.github/workflows/weekly-ci-cc-alpine-linux.yml index 999b7845..ad290670 100644 --- a/.github/workflows/weekly-ci-cc-alpine-linux.yml +++ b/.github/workflows/weekly-ci-cc-alpine-linux.yml @@ -146,6 +146,14 @@ jobs: (cd "upx with space"/build/xtarget/gcc-static/release && DESTDIR="$PWD/Install with cmake" cmake --install .) (cd "upx with space"/build/xtarget/gcc-static/release && DESTDIR="$PWD/Install with make" make install) + - name: 'Run file system test suite (busybox)' + run: | + apk add bash sudo + testsuite="$(readlink -fn "upx with space"/misc/testsuite/test_symlinks.sh)" + cd "upx with space"/build/xtarget/gcc-static/release + # IMPORTANT: do NOT run as user root! + chmod a+w . && sudo -u operator bash "$testsuite" + # test suite - name: ${{ format('Run test suite level {0}', env.UPX_TESTSUITE_LEVEL) }} run: | @@ -156,3 +164,11 @@ jobs: export upx_testsuite_SRCDIR="$(readlink -fn "upx-testsuite with space")" testsuite_1="$(readlink -fn "upx with space"/misc/testsuite/upx_testsuite_1.sh)" (cd "upx with space"/build/xtarget/gcc-static/release && upx_exe=./upx bash "$testsuite_1") + + - name: 'Run file system test suite (coreutils)' + run: | + apk add bash coreutils sudo + testsuite="$(readlink -fn "upx with space"/misc/testsuite/test_symlinks.sh)" + cd "upx with space"/build/xtarget/gcc-static/release + # IMPORTANT: do NOT run as user root! + chmod a+w . && sudo -u operator bash "$testsuite" diff --git a/misc/testsuite/test_symlinks.sh b/misc/testsuite/test_symlinks.sh new file mode 100755 index 00000000..c1abb5ce --- /dev/null +++ b/misc/testsuite/test_symlinks.sh @@ -0,0 +1,373 @@ +#! /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") + +# IMPORTANT NOTE: do NOT run as user root!! +# IMPORTANT NOTE: this script only works on Unix!! +umask 0022 + +id || true +if [[ $UID == 0 || $EUID == 0 ]]; then + echo "ERROR: do not run as root: UID=$UID EUID=$EUID" + exit 91 +fi + +# test behaviour with symlinks; requires: +# $upx_exe (required, but with convenience fallback "./upx") +# optional settings: +# $upx_exe_runner (e.g. "qemu-x86_64 -cpu Westmere" or "valgrind") + +#*********************************************************************** +# init & checks +#*********************************************************************** + +# upx_exe +[[ -z $upx_exe && -f ./upx && -x ./upx ]] && upx_exe=./upx # convenience fallback +if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi +if [[ ! -f $upx_exe ]]; then echo "UPX-ERROR: file '$upx_exe' does not exist"; exit 1; fi +upx_exe=$(readlink -fn "$upx_exe") # make absolute +[[ -f $upx_exe ]] || exit 1 +upx_run=() +if [[ -n $upx_exe_runner ]]; then + # usage examples: + # export upx_exe_runner="qemu-x86_64 -cpu Westmere" + # export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet" + # export upx_exe_runner="wine" + IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array +fi +upx_run+=( "$upx_exe" ) +echo "upx_run='${upx_run[*]}'" + +# upx_run check, part1 +if ! "${upx_run[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi +if ! "${upx_run[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi +if ! "${upx_run[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi + +#*********************************************************************** +# +#*********************************************************************** + +failed() { + ####exit $1 + # log error and keep going + exit_code=1 + local a="$(basename "$(dirname "$PWD")")" + local b="$(basename "$PWD")" + let num_errors+=1 || true + all_errors="${all_errors} $a/$b/$1" + echo " FAILED $b/$1" +} + +assert_file() { + local f + for f in "$@"; do + [[ ! -L "$f" && -f "$f" ]] && continue + echo "failed '$f': not a regular file" + failed 21 + done +} + +assert_symlink_to_file() { + local f + for f in "$@"; do + [[ -L "$f" && -f "$f" ]] && continue + echo "failed '$f': not a symlink to file" + failed 22 + done +} + +assert_symlink_to_dir() { + local f + for f in "$@"; do + [[ -L "$f" && -d "$f" ]] && continue + echo "failed '$f': not a symlink to dir" + failed 23 + done +} + +assert_symlink_dangling() { + local f + for f in "$@"; do + [[ -L "$f" && ! -e "$f" ]] && continue + echo "failed '$f': not a dangling symlink" + failed 24 + done +} + +create_files() { + # clean + for d in z_dir_1 z_dir_2 z_dir_3 z_dir_4; do + if [[ -d $d ]]; then + chmod -R +w "./$d" + rm -rf "./$d" + fi + done + + mkdir z_dir_1 + cd z_dir_1 + : > z_file + ln -s z_file z_symlink_file + : > z_file_link_1 + ln z_file_link_1 z_file_link_2 + ln -s z_file_link_1 z_symlink_file_link + mkdir z_dir + ln -s z_dir z_symlink_dir + ln -s z_file_missing z_symlink_dangling + assert_file z_file* + assert_symlink_to_file z_symlink_file + assert_symlink_to_dir z_symlink_dir + assert_symlink_dangling z_symlink_dangling + cd .. + + # write-protect z_dir_2/z_file* + cp -ai z_dir_1 z_dir_2 + chmod a-w z_dir_2/z_file* + + # write-protect z_dir_3 itself + cp -ai z_dir_1 z_dir_3 + chmod a-w z_dir_3 + + # write-protect everything in z_dir_4 + cp -ai z_dir_1 z_dir_4 + chmod -R a-w z_dir_4 +} + +#*********************************************************************** +# +#*********************************************************************** + +export UPX="--prefer-ucl --no-color --no-progress" +export UPX_DEBUG_DISABLE_GITREV_WARNING=1 +export UPX_DEBUG_DOCTEST_VERBOSE=0 +export NO_COLOR=1 + +#set -x # debug +exit_code=0 +num_errors=0 +all_errors= + +testsuite_header() { + local x='==========='; x="$x$x$x$x$x$x$x" + echo -e "\n${x}\n${1}\n${x}\n" +} + +enter_dir() { + cd "$1" || exit 1 + echo "===== $(basename "$PWD")" +} +leave_dir() { + echo "===== $(basename "$PWD") files" + ls -lA + cd .. +} + +# create a tmpdir in current directory +tmpdir="$(mktemp -d tmp-upx-test-XXXXXX)" +cd "./$tmpdir" || exit 1 + +test_file="$(readlink -fn /bin/ls)" + +testsuite_header "default" +flags="-qq -1 --no-filter" +mkdir default +cd default +create_files +enter_dir z_dir_1 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +enter_dir z_dir_2 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +enter_dir z_dir_3 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +enter_dir z_dir_4 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +cd .. + +testsuite_header "force-overwrite" +flags="-qq -1 --no-filter --force-overwrite" +mkdir force-overwrite +cd force-overwrite +create_files +enter_dir z_dir_1 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18 +assert_file z_symlink_file z_symlink_file_link +assert_file z_symlink_dir +assert_file z_symlink_dangling +leave_dir +enter_dir z_dir_2 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18 +assert_file z_symlink_file z_symlink_file_link +assert_file z_symlink_dir +assert_file z_symlink_dangling +leave_dir +enter_dir z_dir_3 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +enter_dir z_dir_4 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +cd .. + +if [[ 1 == 1 ]]; then +testsuite_header "link" +flags="-qq -1 --no-filter --link" +mkdir link +cd link +create_files +enter_dir z_dir_1 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18 +assert_file z_symlink_file z_symlink_file_link +assert_file z_symlink_dir +assert_file z_symlink_dangling +leave_dir +enter_dir z_dir_2 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18 +assert_file z_symlink_file z_symlink_file_link +assert_file z_symlink_dir +assert_file z_symlink_dangling +leave_dir +enter_dir z_dir_3 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +enter_dir z_dir_4 +"${upx_run[@]}" $flags z_symlink_file && failed 10 +"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11 +"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12 +"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13 +"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17 +"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18 +assert_symlink_to_file z_symlink_file z_symlink_file_link +assert_symlink_to_dir z_symlink_dir +assert_symlink_dangling z_symlink_dangling +leave_dir +cd .. +fi + +# clean up +cd .. +chmod -R +w "./$tmpdir" +rm -rf "./$tmpdir" + +if [[ $exit_code == 0 ]]; then + echo "UPX testsuite passed. All done." +else + echo "UPX-ERROR: UPX testsuite FAILED:${all_errors}" + echo "UPX-ERROR: UPX testsuite FAILED with $num_errors error(s). See log file." +fi +exit $exit_code diff --git a/misc/testsuite/upx_testsuite_1.sh b/misc/testsuite/upx_testsuite_1.sh index a75d0261..2e67e82e 100755 --- a/misc/testsuite/upx_testsuite_1.sh +++ b/misc/testsuite/upx_testsuite_1.sh @@ -15,9 +15,9 @@ argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs") # # see https://github.com/upx/upx-testsuite.git -# /*********************************************************************** -# // init & checks -# ************************************************************************/ +#*********************************************************************** +# init & checks +#*********************************************************************** # upx_exe [[ -z $upx_exe && -f ./upx && -x ./upx ]] && upx_exe=./upx # convenience fallback @@ -91,9 +91,9 @@ if [[ $UPX_TESTSUITE_LEVEL == 0 ]]; then exit 0 fi -# /*********************************************************************** -# // setup -# ************************************************************************/ +#*********************************************************************** +# setup +#*********************************************************************** #set -x # debug exit_code=0 @@ -103,15 +103,14 @@ all_errors= export UPX="--prefer-ucl --no-color --no-progress" export UPX_DEBUG_DISABLE_GITREV_WARNING=1 export UPX_DEBUG_DOCTEST_VERBOSE=0 -export NO_COLOR=1 rm -rf ./testsuite_1 mkdir testsuite_1 || exit 1 cd testsuite_1 || exit 1 -# /*********************************************************************** -# // support functions -# ************************************************************************/ +#*********************************************************************** +# support functions +#*********************************************************************** run_upx() { local ec=0 @@ -195,13 +194,13 @@ testsuite_run_compress() { fi } -# /*********************************************************************** -# // expected checksums -# // -# // To ease maintenance of this script in case of updates this section -# // can be automatically re-created from the current checksums - -# // see call of function recreate_expected_sha256sums below. -# ************************************************************************/ +#*********************************************************************** +# expected checksums +# +# To ease maintenance of this script in case of updates this section +# can be automatically re-created from the current checksums - +# see call of function recreate_expected_sha256sums below. +#*********************************************************************** recreate_expected_sha256sums() { local o="$1" @@ -219,9 +218,9 @@ recreate_expected_sha256sums() { source "$argv0dir/upx_testsuite_1-expected_sha256sums.sh" || exit 1 -# /*********************************************************************** -# // decompression tests -# ************************************************************************/ +#*********************************************************************** +# decompression tests +#*********************************************************************** testdir=t010_decompressed mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected @@ -251,11 +250,11 @@ for f in t010_decompressed/*/*; do done testsuite_check_sha $testdir -# /*********************************************************************** -# // compression tests -# // info: we use fast compression levels because we want to -# // test UPX and not the compression libraries -# ************************************************************************/ +#*********************************************************************** +# compression tests +# info: we use fast compression levels because we want to +# test UPX and not the compression libraries +#*********************************************************************** if [[ $UPX_TESTSUITE_LEVEL -ge 2 ]]; then testdir=t110_compress_ucl_nrv2b_3_no_filter @@ -299,9 +298,9 @@ mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha2 time testsuite_run_compress --all-methods --no-lzma -5 --no-filter fi -# /*********************************************************************** -# // summary -# ************************************************************************/ +#*********************************************************************** +# summary +#*********************************************************************** # recreate checksums from current version for an easy update in case of changes recreate_expected_sha256sums .sha256sums.recreate diff --git a/src/conf.h b/src/conf.h index 11ff613b..465aec9b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -187,13 +187,15 @@ typedef upx_int64_t upx_off_t; #undef small #undef tos #undef unix -#if defined(__linux__) && !defined(__unix__) +#if (ACC_OS_POSIX) && !defined(__unix__) # define __unix__ 1 #endif +#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) +# undef __unix +# undef __unix__ +#endif #if (ACC_OS_DOS32) && defined(__DJGPP__) # undef sopen -# undef __unix -# undef __unix__ #endif #if defined(HAVE_DUP) && (HAVE_DUP + 0 == 0) diff --git a/src/help.cpp b/src/help.cpp index d9392387..89029ad3 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -225,7 +225,7 @@ void show_help(int verbose) { fg = con_fg(f, fg); con_fprintf(f, " --force-overwrite force overwrite of output files\n" -#if defined(__unix__) && !defined(__MSYS2__) +#if defined(__unix__) " --link preserve hard links (Unix only) [USE WITH CARE]\n" " --no-link do not preserve hard links but rename files [default]\n" #endif diff --git a/src/main.cpp b/src/main.cpp index 87224800..e9118f17 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -201,7 +201,8 @@ static void check_and_update_options(int i, int argc) { check_not_both(opt->force_overwrite, opt->preserve_link, "--force-overwrite", "--link"); check_not_both(opt->to_stdout, opt->preserve_link, "--stdout", "--link"); -#if defined(__unix__) && !defined(__MSYS2__) +#if defined(__unix__) + static_assert(HAVE_LSTAT); #else // preserve_link is currently silently ignored on non-Unix platforms // (we may revisit this decision later if there is some actual use-case) diff --git a/src/p_unix.cpp b/src/p_unix.cpp index a9dfbe2d..8b4b0c6f 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -72,7 +72,7 @@ tribool PackUnix::canPack() if (exetype == 0) return false; -#if defined(__unix__) && !defined(__MSYS2__) +#if defined(__unix__) // must be executable by owner if ((fi->st.st_mode & S_IXUSR) == 0) throwCantPack("file not executable; try 'chmod +x'");