From 3a1b4f034bc358f550cdde23785a9a99376e255e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 20 Sep 2022 03:43:08 +0200 Subject: [PATCH 1/4] Preserve timestamps when extracting the squashfs Closes https://github.com/AppImage/AppImageKit/issues/1151 --- ci/test-appimagetool.sh | 9 +++++++++ src/runtime.c | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/ci/test-appimagetool.sh b/ci/test-appimagetool.sh index 125e9c19c..2f28bc065 100755 --- a/ci/test-appimagetool.sh +++ b/ci/test-appimagetool.sh @@ -135,3 +135,12 @@ if [ "$hash1" == "$hash3" ]; then echo "Hashes of regular and mtime-modified AppImages don't differ" exit 1 fi + +log "check mtimes are not lost when extracting" +./appimagetool.AppImage.3 --appimage-extract +if [ "$(stat -c %Y squashfs-root/appimagetool.png)" != "12345" ]; then + echo "mtime of appimagetool.png is not 12345 (as set by mksquashfs \"-all-time\"):" + ls -la squashfs-root + exit 1 +fi +rm -rf squashfs-root diff --git a/src/runtime.c b/src/runtime.c index bada3af93..88737223b 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -403,6 +403,11 @@ bool extract_appimage(const char* const appimage_path, const char* const _prefix fwrite(buf, 1, bytes_at_a_time, f); bytes_already_read = bytes_already_read + bytes_at_a_time; } + fflush(f); + int fd = fileno(f); + struct timespec times[] = { st.st_atim, st.st_mtim }; + if (futimens(fd, times) != 0) + fprintf(stderr, "futimens: %s\n", strerror(errno)); fclose(f); chmod(prefixed_path_to_extract, st.st_mode); if (!rv) From b7de36a1b1295cea2caf3e8dc3d6b37bf2a92d21 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 20 Sep 2022 18:46:49 +0200 Subject: [PATCH 2/4] Don't fail on architectures for which we can't actually run the appimage in CI --- ci/test-appimagetool.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ci/test-appimagetool.sh b/ci/test-appimagetool.sh index 2f28bc065..1787d5932 100755 --- a/ci/test-appimagetool.sh +++ b/ci/test-appimagetool.sh @@ -123,7 +123,7 @@ out=$("$appimagetool" appimagetool.AppDir appimagetool.AppImage --mksquashfs-opt echo "${out}" | grep -q "invalid option" "$appimagetool" appimagetool.AppDir appimagetool.AppImage.1 "$appimagetool" appimagetool.AppDir appimagetool.AppImage.2 --mksquashfs-opt "-mem" --mksquashfs-opt "100M" -"$appimagetool" appimagetool.AppDir appimagetool.AppImage.3 --mksquashfs-opt "-all-time" --mksquashfs-opt "12345" +"$appimagetool" appimagetool.AppDir appimagetool.AppImage.3 --mksquashfs-opt "-all-time" --mksquashfs-opt "1234567890" hash1=$(sha256sum appimagetool.AppImage.1 | awk '{print $1}') hash2=$(sha256sum appimagetool.AppImage.2 | awk '{print $1}') hash3=$(sha256sum appimagetool.AppImage.3 | awk '{print $1}') @@ -137,10 +137,13 @@ if [ "$hash1" == "$hash3" ]; then fi log "check mtimes are not lost when extracting" -./appimagetool.AppImage.3 --appimage-extract -if [ "$(stat -c %Y squashfs-root/appimagetool.png)" != "12345" ]; then - echo "mtime of appimagetool.png is not 12345 (as set by mksquashfs \"-all-time\"):" +if [[ "$(./appimagetool.AppImage.3 --appimage-extract 2>&1)" =~ "exec format error" ]]; then + echo "Can't extract AppImage on $(uname -m) (exec format error)" +elif [ "$(stat -c %Y squashfs-root/appimagetool.png)" != "1234567890" ]; then + echo "mtime of appimagetool.png is not 1234567890 / 2009-02-14 (as set by mksquashfs \"-all-time\"):" ls -la squashfs-root exit 1 +else + ls -la squashfs-root/appimagetool.png fi rm -rf squashfs-root From d1799758942890e368905fd10158960ebf51e368 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 20 Sep 2022 22:36:17 +0200 Subject: [PATCH 3/4] fix bash problem --- ci/test-appimagetool.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ci/test-appimagetool.sh b/ci/test-appimagetool.sh index 1787d5932..b56224449 100755 --- a/ci/test-appimagetool.sh +++ b/ci/test-appimagetool.sh @@ -136,14 +136,14 @@ if [ "$hash1" == "$hash3" ]; then exit 1 fi -log "check mtimes are not lost when extracting" +log "check mtimes are preserved when extracting squashfs" if [[ "$(./appimagetool.AppImage.3 --appimage-extract 2>&1)" =~ "exec format error" ]]; then echo "Can't extract AppImage on $(uname -m) (exec format error)" -elif [ "$(stat -c %Y squashfs-root/appimagetool.png)" != "1234567890" ]; then - echo "mtime of appimagetool.png is not 1234567890 / 2009-02-14 (as set by mksquashfs \"-all-time\"):" +else ls -la squashfs-root + if [ "$(stat -c %Y squashfs-root/appimagetool.png)" != "1234567890" ]; then + echo "mtime of appimagetool.png is not 1234567890 / 2009-02-14 (as set by mksquashfs \"-all-time\"):" exit 1 -else - ls -la squashfs-root/appimagetool.png + fi fi rm -rf squashfs-root From 5dc29ab4a9f2072b9cfd8fcd30e596b36ac08966 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 20 Sep 2022 23:08:19 +0200 Subject: [PATCH 4/4] fix bash problem --- ci/test-appimagetool.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/test-appimagetool.sh b/ci/test-appimagetool.sh index b56224449..fe829c00b 100755 --- a/ci/test-appimagetool.sh +++ b/ci/test-appimagetool.sh @@ -137,9 +137,8 @@ if [ "$hash1" == "$hash3" ]; then fi log "check mtimes are preserved when extracting squashfs" -if [[ "$(./appimagetool.AppImage.3 --appimage-extract 2>&1)" =~ "exec format error" ]]; then - echo "Can't extract AppImage on $(uname -m) (exec format error)" -else +./appimagetool.AppImage.3 --appimage-extract || echo "Can not extract AppImage on $(uname -m)" +if [ -d squashfs-root ]; then ls -la squashfs-root if [ "$(stat -c %Y squashfs-root/appimagetool.png)" != "1234567890" ]; then echo "mtime of appimagetool.png is not 1234567890 / 2009-02-14 (as set by mksquashfs \"-all-time\"):"