Browse Source

dpkg: Set the modification time for unpacked symlinks if possible

Use lutimes() conditionally as it might not be widely available.
Guillem Jover 15 years ago
parent
commit
b3eb59cf43
3 changed files with 11 additions and 6 deletions
  1. 1 1
      configure.ac
  2. 1 0
      debian/changelog
  3. 9 5
      src/archives.c

+ 1 - 1
configure.ac

@@ -84,7 +84,7 @@ DPKG_CHECK_COMPAT_FUNCS([getopt getopt_long obstack_free \
                          strnlen strerror strsignal asprintf \
                          scandir alphasort unsetenv])
 AC_CHECK_FUNCS([strtoul strtoimax isascii bcopy memcpy setsid getdtablesize \
-                posix_fadvise])
+                lutimes posix_fadvise])
 
 DPKG_MMAP
 

+ 1 - 0
debian/changelog

@@ -46,6 +46,7 @@ dpkg (1.16.0) UNRELEASED; urgency=low
   * Fix typo in «dpkg-name --overwrite» argument parsing so that it actually
     works at all. Thanks to Ivan Gagis <igagis@gmail.com>. LP: #728708
   * Add armhf support to ostable and triplettable. Closes: #594179
+  * Set the modification time for unpacked symlinks on supported systems.
 
   [ Raphaël Hertzog ]
   * Fail properly when debian/source/format is empty. Closes: #600854

+ 9 - 5
src/archives.c

@@ -235,16 +235,20 @@ tarobject_set_mtime(struct tar_entry *te, const char *path)
 {
   struct timeval tv[2];
 
-  if (te->type == tar_filetype_symlink)
-    return;
-
   tv[0].tv_sec = currenttime;
   tv[0].tv_usec = 0;
   tv[1].tv_sec = te->mtime;
   tv[1].tv_usec = 0;
 
-  if (utimes(path, tv))
-    ohshite(_("error setting timestamps of `%.255s'"), path);
+  if (te->type == tar_filetype_symlink) {
+#ifdef HAVE_LUTIMES
+    if (lutimes(path, tv))
+      ohshite(_("error setting timestamps of `%.255s'"), path);
+#endif
+  } else {
+    if (utimes(path, tv))
+      ohshite(_("error setting timestamps of `%.255s'"), path);
+  }
 }
 
 static void