* [gentoo-portage-dev] [PATCH 1/2] Revert 'packages' profile as directory patches
@ 2014-05-16 15:05 Alexander Berntsen
2014-05-16 15:05 ` [gentoo-portage-dev] [PATCH 2/2] Turn a traceback into a graceful error Alexander Berntsen
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Berntsen @ 2014-05-16 15:05 UTC (permalink / raw
To: gentoo-portage-dev
This reverts commit 0c416cbb70858a5db2a1a23b2e90a95c0a1f2ea8 and
b4d8e300c04b768be7cd5c64116d6cc0453219b4.
Jorge Manuel B. S. Vicetto pointed out[0] that this is not useful. The
commits were made by me after talking to Michael Palimaka on IRC.
Apparently I did not get the full story straight, and made the commits
prematurely.
[0] https://bugs.gentoo.org/show_bug.cgi?id=282296#c14
---
pym/portage/_sets/profiles.py | 4 +---
pym/portage/package/ebuild/config.py | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/pym/portage/_sets/profiles.py b/pym/portage/_sets/profiles.py
index 7135d7f..39a2968 100644
--- a/pym/portage/_sets/profiles.py
+++ b/pym/portage/_sets/profiles.py
@@ -33,9 +33,7 @@ class PackagesSystemSet(PackageSet):
writemsg_level("\nPackagesSystemSet: profile paths: %s\n" % \
(self._profile_paths,), level=logging.DEBUG, noiselevel=-1)
- mylist = [grabfile_package(os.path.join(x, "packages"),
- recursive=True,
- verify_eapi=True) for x in self._profile_paths]
+ mylist = [grabfile_package(os.path.join(x, "packages"), verify_eapi=True) for x in self._profile_paths]
if debug:
writemsg_level("\nPackagesSystemSet: raw packages: %s\n" % \
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index e294968..e104501 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -557,7 +557,7 @@ class config(object):
self.user_profile_dir = locations_manager.user_profile_dir
packages_list = [grabfile_package(os.path.join(x, "packages"),
- recursive=True, verify_eapi=True) for x in self.profiles]
+ verify_eapi=True) for x in self.profiles]
self.packages = tuple(stack_lists(packages_list, incremental=1))
# revmaskdict
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-portage-dev] [PATCH 2/2] Turn a traceback into a graceful error
2014-05-16 15:05 [gentoo-portage-dev] [PATCH 1/2] Revert 'packages' profile as directory patches Alexander Berntsen
@ 2014-05-16 15:05 ` Alexander Berntsen
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Berntsen @ 2014-05-16 15:05 UTC (permalink / raw
To: gentoo-portage-dev
Prior to this patch, the following would traceback:
mkdir -p /etc/portage/make.profile/packages
emerge foo
This patch turns such a traceback into an error by implementing
IsADirectory error handling.
---
bin/emerge | 9 ++++++++-
pym/portage/exception.py | 4 ++++
pym/portage/package/ebuild/config.py | 13 ++++++++++---
pym/portage/util/__init__.py | 3 ++-
4 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/bin/emerge b/bin/emerge
index bb93d83..7773f7f 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -45,12 +45,19 @@ try:
from _emerge.main import emerge_main
if __name__ == "__main__":
- from portage.exception import ParseError, PermissionDenied
+ from portage.exception import IsADirectory, ParseError, \
+ PermissionDenied
try:
retval = emerge_main()
except PermissionDenied as e:
sys.stderr.write("Permission denied: '%s'\n" % str(e))
sys.exit(e.errno)
+ except IsADirectory as e:
+ sys.stderr.write("'%s' is a directory, but should be a file!\n"
+ "See portage man page for information on "
+ "which files may be directories.\n" %
+ str(e))
+ sys.exit(e.errno)
except ParseError as e:
sys.stderr.write("%s\n" % str(e))
sys.exit(1)
diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 6fa5447..ef62e7a 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -84,6 +84,10 @@ class FileNotFound(InvalidLocation):
class DirectoryNotFound(InvalidLocation):
"""A directory was not found when it was expected to exist"""
+class IsADirectory(PortageException):
+ """A directory was found when it was expected to be a file"""
+ from errno import EISDIR as errno
+
class OperationNotPermitted(PortageException):
"""An operation was not permitted operating system"""
from errno import EPERM as errno
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index e104501..f639e14 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -37,7 +37,8 @@ from portage.dep import Atom, isvalidatom, match_from_list, use_reduce, _repo_se
from portage.eapi import eapi_exports_AA, eapi_exports_merge_type, \
eapi_supports_prefix, eapi_exports_replace_vars, _get_eapi_attrs
from portage.env.loaders import KeyValuePairFileLoader
-from portage.exception import InvalidDependString, PortageException
+from portage.exception import InvalidDependString, IsADirectory, \
+ PortageException
from portage.localization import _
from portage.output import colorize
from portage.process import fakeroot_capable, sandbox_capable
@@ -556,8 +557,14 @@ class config(object):
self.profile_path = locations_manager.profile_path
self.user_profile_dir = locations_manager.user_profile_dir
- packages_list = [grabfile_package(os.path.join(x, "packages"),
- verify_eapi=True) for x in self.profiles]
+ try:
+ packages_list = [grabfile_package(os.path.join(x, "packages"),
+ verify_eapi=True) for x in self.profiles]
+ except IOError as e:
+ if e.errno == IsADirectory.errno:
+ raise IsADirectory(os.path.join(self.profile_path,
+ "packages"))
+
self.packages = tuple(stack_lists(packages_list, incremental=1))
# revmaskdict
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 614b2b3..4105c19 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -43,7 +43,8 @@ from portage import _unicode_encode
from portage import _unicode_decode
from portage.const import VCS_DIRS
from portage.exception import InvalidAtom, PortageException, FileNotFound, \
- OperationNotPermitted, ParseError, PermissionDenied, ReadOnlyFileSystem
+ IsADirectory, OperationNotPermitted, ParseError, PermissionDenied, \
+ ReadOnlyFileSystem
from portage.localization import _
from portage.proxy.objectproxy import ObjectProxy
from portage.cache.mappings import UserDict
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-16 15:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-16 15:05 [gentoo-portage-dev] [PATCH 1/2] Revert 'packages' profile as directory patches Alexander Berntsen
2014-05-16 15:05 ` [gentoo-portage-dev] [PATCH 2/2] Turn a traceback into a graceful error Alexander Berntsen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox