quickpkg: fix regression in hardlink support
authorZac Medico <zmedico@gentoo.org>
Sat, 29 Oct 2011 05:35:01 +0000 (22:35 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 29 Oct 2011 05:35:01 +0000 (22:35 -0700)
Hardlink support has been broken since commit
4198da0184aaec30c41f2e5d2c7af71c4d35b662, which omitted the hardlink
logic from TarFile.gettarinfo().

pym/portage/dbapi/vartree.py

index ee0db6f2452574ec4aa3dd6e2bd37aba79757bb4..73772b0e0a64016a7c64c44133c2edc20d12d943 100644 (file)
@@ -4560,11 +4560,20 @@ def tar_contents(contents, root, tar, protect=None, onProgress=None):
                tarinfo.mode = lst.st_mode
                tarinfo.uid = lst.st_uid
                tarinfo.gid = lst.st_gid
-               tarinfo.size = lst.st_size
+               tarinfo.size = 0
                tarinfo.mtime = lst.st_mtime
                tarinfo.linkname = ""
                if stat.S_ISREG(lst.st_mode):
-                       tarinfo.type = tarfile.REGTYPE
+                       inode = (lst.st_ino, lst.st_dev)
+                       if (lst.st_nlink > 1 and
+                               inode in tar.inodes and
+                               arcname != tar.inodes[inode]):
+                               tarinfo.type = tarfile.LNKTYPE
+                               tarinfo.linkname = tar.inodes[inode]
+                       else:
+                               tar.inodes[inode] = arcname
+                               tarinfo.type = tarfile.REGTYPE
+                               tarinfo.size = lst.st_size
                elif stat.S_ISDIR(lst.st_mode):
                        tarinfo.type = tarfile.DIRTYPE
                elif stat.S_ISLNK(lst.st_mode):