diff --git a/ci/test-appimagetool.sh b/ci/test-appimagetool.sh index aaf9491e..1be5ebbe 100755 --- a/ci/test-appimagetool.sh +++ b/ci/test-appimagetool.sh @@ -121,7 +121,7 @@ fi log "check --mksquashfs-opt forwarding" "$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}') @@ -134,6 +134,17 @@ if [ "$hash1" == "$hash3" ]; then exit 1 fi +log "check mtimes are preserved when extracting squashfs" +./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\"):" + exit 1 + fi +fi +rm -rf squashfs-root + log "check appimagetool dies when mksquashfs fails" set +e # temporarily disable error trapping as next line is supposed to fail out=$("$appimagetool" appimagetool.AppDir appimagetool.AppImage --mksquashfs-opt "-misspelt-option" 2>&1) @@ -142,4 +153,4 @@ set -e test ${rc} == 1 echo "${out}" | grep -q "invalid option" echo "${out}" | grep -qP 'mksquashfs \(pid \d+\) exited with code 1' -echo "${out}" | grep -q "sfs_mksquashfs error" +echo "${out}" | grep -q "sfs_mksquashfs error" \ No newline at end of file diff --git a/src/runtime.c b/src/runtime.c index e6cd989d..d3d5206c 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)