libxbps: apply file timestamps to unmodified files on-disk while unpacking.

This commit is contained in:
Juan RP 2015-02-25 11:10:18 +01:00
parent b133b9023c
commit cbe493858c
2 changed files with 31 additions and 0 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.44 (???):
* libxbps: while unpacking pkg files that were not modified (sha256 hash matched),
do not forget to also update the file timestamps on disk, to match
what the binary package has stored in the metadata.
* xbps-pkgdb(8): this now checks the modification time of pkg files
(iff the pkg metadata has that information).

View File

@ -392,6 +392,33 @@ unpack_archive(struct xbps_handle *xhp,
"mode to %s.\n", pkgver, entry_pname,
archive_entry_strmode(entry));
}
/*
* Check if current file mtime differs from archive entry
* in binpkg and apply mtime if true.
*/
if (!force && file_exists && skip_extract &&
(archive_entry_mtime_nsec(entry) != st.st_mtime)) {
struct timespec ts[2];
ts[0].tv_sec = archive_entry_atime(entry);
ts[0].tv_nsec = archive_entry_atime_nsec(entry);
ts[1].tv_sec = archive_entry_mtime(entry);
ts[1].tv_nsec = archive_entry_mtime_nsec(entry);
if (utimensat(AT_FDCWD, entry_pname, ts,
AT_SYMLINK_NOFOLLOW) == -1) {
xbps_dbg_printf(xhp,
"%s: failed "
"to set mtime %ju to %s: %s\n",
pkgver, archive_entry_mtime_nsec(entry),
entry_pname,
strerror(errno));
rv = EINVAL;
goto out;
}
xbps_dbg_printf(xhp, "%s: updated file timestamps to %s\n",
pkgver, entry_pname);
}
if (!force && skip_extract) {
archive_read_data_skip(ar);
continue;