summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-12-08 11:23:48 -0800
committerZac Medico <zmedico@gentoo.org>2010-12-08 11:39:57 -0800
commit88e7cb5c627063a79b6636bcae7734dfb35902e0 (patch)
tree98116939892c665065d2019730bca8a0b4448c1f
parent616623d2fc4b907329dbc2f751a332fc12a41ba7 (diff)
downloadportage-88e7cb5c627063a79b6636bcae7734dfb35902e0.tar.gz
portage-88e7cb5c627063a79b6636bcae7734dfb35902e0.tar.bz2
portage-88e7cb5c627063a79b6636bcae7734dfb35902e0.zip
Preserve existing hardlinks during merge.
The previous code created hardlinks rather aggressively, which was helpful as a workaround for lack of hardlinks in tarballs created by quickpkg due to bug #185305. Since bug #338509, quickpkg tarballs preserve hardlinks, so there's no need for aggressive hardlink creation. Therefore, simply preserve existing hardlinks during merge, by comparison of st_dev and st_ino from the source files.
-rw-r--r--pym/portage/dbapi/vartree.py27
1 files changed, 8 insertions, 19 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index ee8e3e3b5..204d45b5d 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -3761,25 +3761,14 @@ class dblink(object):
# whether config protection or not, we merge the new file the
# same way. Unless moveme=0 (blocking directory)
if moveme:
- # Do not hardlink files unless they are in the same
- # directory, since otherwise tar may not be able to
- # extract a tarball of the resulting hardlinks due to
- # 'Invalid cross-device link' errors (depends on layout of
- # mount points). Also, don't hardlink zero-byte files since
- # it doesn't save any space, and don't hardlink
- # CONFIG_PROTECTed files since config files shouldn't be
- # hardlinked to eachother (for example, shadow installs
- # several identical config files inside /etc/pam.d/).
- parent_dir = os.path.dirname(myrealdest)
- hardlink_key = (parent_dir, mymd5, mystat.st_size,
- mystat.st_mode, mystat.st_uid, mystat.st_gid)
-
- hardlink_candidates = None
- if not protected and mystat.st_size != 0:
- hardlink_candidates = self._md5_merge_map.get(hardlink_key)
- if hardlink_candidates is None:
- hardlink_candidates = []
- self._md5_merge_map[hardlink_key] = hardlink_candidates
+ # Create hardlinks only for source files that already exist
+ # as hardlinks (having identical st_dev and st_ino).
+ hardlink_key = (mystat.st_dev, mystat.st_ino)
+
+ hardlink_candidates = self._md5_merge_map.get(hardlink_key)
+ if hardlink_candidates is None:
+ hardlink_candidates = []
+ self._md5_merge_map[hardlink_key] = hardlink_candidates
mymtime = movefile(mysrc, mydest, newmtime=thismtime,
sstat=mystat, mysettings=self.settings,