From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RIonr-0000qO-Qx for garchives@archives.gentoo.org; Tue, 25 Oct 2011 21:45:00 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E402B21C092; Tue, 25 Oct 2011 21:44:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A736D21C092 for ; Tue, 25 Oct 2011 21:44:50 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0DB6E1B401D for ; Tue, 25 Oct 2011 21:44:50 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 739878004F for ; Tue, 25 Oct 2011 21:44:49 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <9d4459dfea72717c0565b0cfe39fa3a87a57ad9d.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/, pym/portage/package/ebuild/_config/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/package/ebuild/_config/LocationsManager.py pym/portage/package/ebuild/config.py X-VCS-Directories: pym/portage/package/ebuild/ pym/portage/package/ebuild/_config/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 9d4459dfea72717c0565b0cfe39fa3a87a57ad9d Date: Tue, 25 Oct 2011 21:44:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 5e1b154550e96581257be7795bc751af commit: 9d4459dfea72717c0565b0cfe39fa3a87a57ad9d Author: Brian Harring chromium org> AuthorDate: Tue Oct 25 05:37:34 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Oct 25 21:36:42 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D9d4459df Track profile format, and if compatibility mode is in use. Warn if the profile is using portage-1 format, but isn't marked as such. --- .../package/ebuild/_config/LocationsManager.py | 67 ++++++++++++++= ++--- pym/portage/package/ebuild/config.py | 1 + 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym= /portage/package/ebuild/_config/LocationsManager.py index 4072ffc..a465935 100644 --- a/pym/portage/package/ebuild/_config/LocationsManager.py +++ b/pym/portage/package/ebuild/_config/LocationsManager.py @@ -13,8 +13,14 @@ from portage.exception import DirectoryNotFound, Parse= Error from portage.localization import _ from portage.util import ensure_dirs, grabfile, \ normalize_path, shlex_split, writemsg +from portage.repository.config import parse_layout_conf =20 =20 +_PORTAGE1_DIRECTORIES =3D frozenset([ + 'package.mask', 'package.provided', + 'package.use', 'package.use.mask', 'package.use.force', + 'use.mask', 'use.force']) + class LocationsManager(object): =20 def __init__(self, config_root=3DNone, eprefix=3DNone, config_profile_p= ath=3DNone, local_config=3DTrue, \ @@ -37,17 +43,23 @@ class LocationsManager(object): =20 self._check_var_directory("PORTAGE_CONFIGROOT", self.config_root) self.abs_user_config =3D os.path.join(self.config_root, USER_CONFIG_PA= TH) + self.config_profile_path =3D config_profile_path + + def load_profiles(self, known_repository_paths): + known_repos =3D [os.path.abspath(x) for x in set(known_repository_path= s)] + # force a trailing '/' for ease of doing startswith checks + known_repos =3D [(x + '/', parse_layout_conf(x)[0]) for x in known_rep= os] =20 - if config_profile_path is None: - config_profile_path =3D \ + if self.config_profile_path is None: + self.config_profile_path =3D \ os.path.join(self.config_root, PROFILE_PATH) - if os.path.isdir(config_profile_path): - self.profile_path =3D config_profile_path + if os.path.isdir(self.config_profile_path): + self.profile_path =3D self.config_profile_path else: - config_profile_path =3D \ + self.config_profile_path =3D \ os.path.join(self.abs_user_config, 'make.profile') - if os.path.isdir(config_profile_path): - self.profile_path =3D config_profile_path + if os.path.isdir(self.config_profile_path): + self.profile_path =3D self.config_profile_path else: self.profile_path =3D None else: @@ -55,14 +67,16 @@ class LocationsManager(object): # here, in order to create an empty profile # for checking dependencies of packages with # empty KEYWORDS. - self.profile_path =3D config_profile_path + self.profile_path =3D self.config_profile_path =20 =20 # The symlink might not exist or might not be a symlink. self.profiles =3D [] + self.profiles_complex =3D [] if self.profile_path: try: - self._addProfile(os.path.realpath(self.profile_path)) + self._addProfile(os.path.realpath(self.profile_path), + known_repos) except ParseError as e: writemsg(_("!!! Unable to parse profile: '%s'\n") % \ self.profile_path, noiselevel=3D-1) @@ -75,9 +89,11 @@ class LocationsManager(object): if os.path.exists(custom_prof): self.user_profile_dir =3D custom_prof self.profiles.append(custom_prof) + self.profiles_complex.append((custom_prof, True)) del custom_prof =20 self.profiles =3D tuple(self.profiles) + self.profiles_complex =3D tuple(self.profiles_complex) =20 def _check_var_directory(self, varname, var): if not os.path.isdir(var): @@ -86,7 +102,34 @@ class LocationsManager(object): noiselevel=3D-1) raise DirectoryNotFound(var) =20 - def _addProfile(self, currentPath): + def _addProfile(self, currentPath, known_repos): + current_abs_path =3D os.path.abspath(currentPath) + allow_directories =3D True + compat_mode =3D False + intersecting_repos =3D [x for x in known_repos if current_abs_path.sta= rtswith(x[0])] + if intersecting_repos: + # protect against nested repositories. Insane configuration, but the= longest + # path will be the correct one. + repo_loc, layout_data =3D max(intersecting_repos, key=3Dlambda x:len(= x[0])) + allow_directories =3D any(x.startswith("portage-1") + for x in layout_data['profile-formats']) + compat_mode =3D layout_data['profile-formats'] =3D=3D ('portage-1-com= pat',) + + if compat_mode: + offenders =3D _PORTAGE1_DIRECTORIES.intersection(os.listdir(currentPa= th)) + offenders =3D sorted(x for x in offenders + if os.path.isdir(os.path.join(currentPath, x))) + if offenders: + writemsg((_("Profile '%(profile_path)s' in repository " + "'%(repo_name)s' is using 'portage-1' profile format, but " + "the repository is not configured for it. This will break " + "in the future. Please either convert the following paths " + "to files, or add\nprofile-format =3D portage-1\nto the " + "repositories layout.conf. Files: '%(files)s'\n") + % dict(profile_path=3DcurrentPath, repo_name=3Drepo_loc, + files=3D', '.join(offenders))), + noiselevel=3D-1) + parentsFile =3D os.path.join(currentPath, "parent") eapi_file =3D os.path.join(currentPath, "eapi") f =3D None @@ -115,12 +158,14 @@ class LocationsManager(object): parentPath =3D normalize_path(os.path.join( currentPath, parentPath)) if os.path.exists(parentPath): - self._addProfile(parentPath) + self._addProfile(parentPath, known_repos) else: raise ParseError( _("Parent '%s' not found: '%s'") % \ (parentPath, parentsFile)) + self.profiles.append(currentPath) + self.profiles_complex.append((currentPath, allow_directories)) =20 def set_root_override(self, root_overwrite=3DNone): # Allow ROOT setting to come from make.conf if it's not overridden diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/e= build/config.py index d49ac60..c4c5e66 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -276,6 +276,7 @@ class config(object): locations_manager =3D LocationsManager(config_root=3Dconfig_root, config_profile_path=3Dconfig_profile_path, eprefix=3Deprefix, local_config=3Dlocal_config, target_root=3Dtarget_root) + locations_manager.load_profiles([]) =20 eprefix =3D locations_manager.eprefix config_root =3D locations_manager.config_root