Skip to content

Commit

Permalink
Preserve timestamps when extracting the squashfs
Browse files Browse the repository at this point in the history
  • Loading branch information
lalten committed Sep 20, 2022
1 parent 90704a0 commit 3a1b4f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ci/test-appimagetool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions src/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3a1b4f0

Please sign in to comment.