From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2913A138A1A for ; Wed, 18 Feb 2015 03:07:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D0F40E092C; Wed, 18 Feb 2015 03:06:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 46C76E092A for ; Wed, 18 Feb 2015 03:06:23 +0000 (UTC) Received: from x51r2.gaikai.org (unknown [100.42.98.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 64CAE340872; Wed, 18 Feb 2015 03:06:22 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: Zac Medico Subject: [gentoo-portage-dev] [PATCH 6/7] binpkg-multi-instance 6 of 7 Date: Tue, 17 Feb 2015 19:05:44 -0800 Message-Id: <1424228745-7794-7-git-send-email-zmedico@gentoo.org> X-Mailer: git-send-email 2.0.5 In-Reply-To: <1424228745-7794-1-git-send-email-zmedico@gentoo.org> References: <20150217115607.0eccc56a.dolsen@gentoo.org> <1424228745-7794-1-git-send-email-zmedico@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: ed8e308b-3e1d-4fe0-bd83-7c1f029858f5 X-Archives-Hash: 9ff6278f98b0f665f2c84071878a4595 Remove unused binarytree _remove_symlink, _create_symlink, prevent_collision, _move_to_all, and _move_from_all methods. These are all related to the oldest PKGDIR layout, which put all of the tbz2 files in $PKGDIR/All, and created symlinks to them in the category directories. The $PKGDIR/All layout should be practically extinct by now. Now portage recognizes all existing layouts, or mixtures of them, and uses the old packages in place. It never puts new packages in $PKGDIR/All, so there's no need to move packages around to prevent file name collisions between packages from different categories. It also only uses regular files (any symlinks are ignored). --- pym/portage/dbapi/bintree.py | 117 ++----------------------------------------- 1 file changed, 4 insertions(+), 113 deletions(-) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 5636a5f..a475fb5 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -471,89 +471,11 @@ class binarytree(object): return moves - def _remove_symlink(self, cpv): - """Remove a ${PKGDIR}/${CATEGORY}/${PF}.tbz2 symlink and also remove - the ${PKGDIR}/${CATEGORY} directory if empty. The file will not be - removed if os.path.islink() returns False.""" - mycat, mypkg = catsplit(cpv) - mylink = os.path.join(self.pkgdir, mycat, mypkg + ".tbz2") - if os.path.islink(mylink): - """Only remove it if it's really a link so that this method never - removes a real package that was placed here to avoid a collision.""" - os.unlink(mylink) - try: - os.rmdir(os.path.join(self.pkgdir, mycat)) - except OSError as e: - if e.errno not in (errno.ENOENT, - errno.ENOTEMPTY, errno.EEXIST): - raise - del e - - def _create_symlink(self, cpv): - """Create a ${PKGDIR}/${CATEGORY}/${PF}.tbz2 symlink (and - ${PKGDIR}/${CATEGORY} directory, if necessary). Any file that may - exist in the location of the symlink will first be removed.""" - mycat, mypkg = catsplit(cpv) - full_path = os.path.join(self.pkgdir, mycat, mypkg + ".tbz2") - self._ensure_dir(os.path.dirname(full_path)) - try: - os.unlink(full_path) - except OSError as e: - if e.errno != errno.ENOENT: - raise - del e - os.symlink(os.path.join("..", "All", mypkg + ".tbz2"), full_path) - def prevent_collision(self, cpv): - """Make sure that the file location ${PKGDIR}/All/${PF}.tbz2 is safe to - use for a given cpv. If a collision will occur with an existing - package from another category, the existing package will be bumped to - ${PKGDIR}/${CATEGORY}/${PF}.tbz2 so that both can coexist.""" - if not self._all_directory: - return - - # Copy group permissions for new directories that - # may have been created. - for path in ("All", catsplit(cpv)[0]): - path = os.path.join(self.pkgdir, path) - self._ensure_dir(path) - if not os.access(path, os.W_OK): - raise PermissionDenied("access('%s', W_OK)" % path) - - full_path = self.getname(cpv) - if "All" == full_path.split(os.path.sep)[-2]: - return - """Move a colliding package if it exists. Code below this point only - executes in rare cases.""" - mycat, mypkg = catsplit(cpv) - myfile = mypkg + ".tbz2" - mypath = os.path.join("All", myfile) - dest_path = os.path.join(self.pkgdir, mypath) - - try: - st = os.lstat(dest_path) - except OSError: - st = None - else: - if stat.S_ISLNK(st.st_mode): - st = None - try: - os.unlink(dest_path) - except OSError: - if os.path.exists(dest_path): - raise - - if st is not None: - # For invalid packages, other_cat could be None. - other_cat = portage.xpak.tbz2(dest_path).getfile(b"CATEGORY") - if other_cat: - other_cat = _unicode_decode(other_cat, - encoding=_encodings['repo.content'], errors='replace') - other_cat = other_cat.strip() - other_cpv = other_cat + "/" + mypkg - self._move_from_all(other_cpv) - self.inject(other_cpv) - self._move_to_all(cpv) + warnings.warn("The " + "portage.dbapi.bintree.binarytree.prevent_collision " + "method is deprecated.", + DeprecationWarning, stacklevel=2) def _ensure_dir(self, path): """ @@ -589,37 +511,6 @@ class binarytree(object): except PortageException: pass - def _move_to_all(self, cpv): - """If the file exists, move it. Whether or not it exists, update state - for future getname() calls.""" - mycat, mypkg = catsplit(cpv) - myfile = mypkg + ".tbz2" - self._pkg_paths[cpv] = os.path.join("All", myfile) - src_path = os.path.join(self.pkgdir, mycat, myfile) - try: - mystat = os.lstat(src_path) - except OSError as e: - mystat = None - if mystat and stat.S_ISREG(mystat.st_mode): - self._ensure_dir(os.path.join(self.pkgdir, "All")) - dest_path = os.path.join(self.pkgdir, "All", myfile) - _movefile(src_path, dest_path, mysettings=self.settings) - self._create_symlink(cpv) - self.inject(cpv) - - def _move_from_all(self, cpv): - """Move a package from ${PKGDIR}/All/${PF}.tbz2 to - ${PKGDIR}/${CATEGORY}/${PF}.tbz2 and update state from getname calls.""" - self._remove_symlink(cpv) - mycat, mypkg = catsplit(cpv) - myfile = mypkg + ".tbz2" - mypath = os.path.join(mycat, myfile) - dest_path = os.path.join(self.pkgdir, mypath) - self._ensure_dir(os.path.dirname(dest_path)) - src_path = os.path.join(self.pkgdir, "All", myfile) - _movefile(src_path, dest_path, mysettings=self.settings) - self._pkg_paths[cpv] = mypath - def populate(self, getbinpkgs=0): "populates the binarytree" -- 2.0.5