diff --git a/.github/travis_testsuite.sh b/.github/travis_testsuite.sh index 8fda9644..77e59191 100644 --- a/.github/travis_testsuite.sh +++ b/.github/travis_testsuite.sh @@ -37,7 +37,10 @@ if test "$TRAVIS_OS_NAME" = "linux"; then cp "$TRAVIS_BUILD_DIR/deps/upx-testsuite/files/packed/amd64-linux.elf/upx-3.91" upx391.out upx_391="$PWD/upx391.out" fi + +$upx --version $upx --help + cd /; cd "$TRAVIS_BUILD_DIR/deps/upx-testsuite/files" || exit 1 ls -l packed/*/upx-3.91* $upx -l packed/*/upx-3.91* diff --git a/src/Makefile b/src/Makefile index a03595aa..9868a4bd 100644 --- a/src/Makefile +++ b/src/Makefile @@ -47,9 +47,10 @@ upx_SOURCES := $(sort $(wildcard $(srcdir)/*.cpp)) upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext))) ifneq ($(wildcard $(top_srcdir)/.git/.),) -UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=6 HEAD || echo "ERROR")) +UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=6 HEAD || echo 'ERROR')) ifneq ($(UPX_VERSION_GITREV),) -DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)"' +x := $(strip $(shell cd '$(top_srcdir)' && git diff --exit-code HEAD >/dev/null && echo '' || echo '+')) +DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)$(x)"' endif endif diff --git a/src/help.cpp b/src/help.cpp index e86babdb..743fbbf9 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -384,7 +384,11 @@ void show_version(int x) UNUSED(x); UNUSED(v); - fprintf(fp, "upx %s\n", UPX_VERSION_STRING); + fprintf(fp, "upx %s\n", UPX_VERSION_STRING +#if defined(UPX_VERSION_GITREV) + "-" UPX_VERSION_GITREV +#endif + ); #if (WITH_NRV) v = upx_nrv_version_string(); if (v != NULL && v[0]) diff --git a/src/main.cpp b/src/main.cpp index 2ba5bd49..82eca5f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1353,6 +1353,7 @@ __acc_static_noinline void upx_sanity_check(void) assert(memcmp(UPX_VERSION_DATE_ISO, UPX_VERSION_YEAR, 4) == 0); assert(memcmp(&UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE)-1 - 4], UPX_VERSION_YEAR, 4) == 0); #if defined(UPX_VERSION_GITREV) + COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_GITREV) <= 7 + 1) assert(strlen(UPX_VERSION_GITREV) >= 5); assert(strlen(UPX_VERSION_GITREV) <= 7); #endif