diff options
-rwxr-xr-x | bin/emerge | 51 | ||||
-rwxr-xr-x | bin/portageq | 11 | ||||
-rw-r--r-- | pym/portage.py | 57 | ||||
-rw-r--r-- | pym/portage_const.py | 3 |
4 files changed, 114 insertions, 8 deletions
diff --git a/bin/emerge b/bin/emerge index 317ae4ef9..f42c2cb96 100755 --- a/bin/emerge +++ b/bin/emerge @@ -3524,6 +3524,25 @@ def chk_updated_info_files(root, infodirs, prev_mtimes, retval): def post_emerge(settings, mtimedb, retval): + """ + Misc. things to run at the end of a merge session. + + Update Info Files + Update Config Files + Update News Items + Commit mtimeDB + Exit Emerge + + @param settings: Configuration settings (typically portage.settings) + @type settings: portage.config() + @param mtimedb: The mtimeDB to store data needed across merge invocations + @type mtimedb: MtimeDB class instance + @param retval: Emerge's return value + @type retval: Int + @rype: None + @returns: + 1. Calls sys.exit(retval) + """ target_root = settings["ROOT"] info_mtimes = mtimedb["info"] config_protect = settings.get("CONFIG_PROTECT","").split() @@ -3539,6 +3558,16 @@ def post_emerge(settings, mtimedb, retval): chk_updated_info_files(target_root, infodirs, info_mtimes, retval) chk_updated_cfg_files(target_root, config_protect) + + NEWS_PATH = os.path.join( "metadata", "news" ) + UNREAD_PATH = os.path.join( target_root, portage.PRIVATE_PATH, 'news') + repo_id = 'gentoo' + unreadItems = checkUpdatedNewsItems(target_root, NEWS_PATH, UNREAD_PATH, repo_id) + if unreadItems: + print colorize("WARN", " * IMPORTANT:"), + print "%s news items need reading." % unreadItems + print colorize("WARN", " *"), + print "Type something to read the news" mtimedb.commit() sys.exit(retval) @@ -3577,6 +3606,28 @@ def chk_updated_cfg_files(target_root, config_protect): print " "+yellow("*")+" Type "+green("emerge --help config")+" to learn how to update config files." print +def checkUpdatedNewsItems( root, NEWS_PATH, UNREAD_PATH, repo_id ): + """ + Examines news items in repodir + '/' + NEWS_PATH and attempts to find unread items + Returns the number of unread (yet relevent) items. + + @param root: + @type root: + @param NEWS_PATH: + @type NEWS_PATH: + @param UNREAD_PATH: + @type UNREAD_PATH: + @param repo_id: + @type repo_id: + @rtype: Integer + @returns: + 1. The number of unread but relevant news items. + + """ + from portage_news import NewsManager + manager = NewsManager( root, NEWS_PATH, UNREAD_PATH ) + return manager.getUnreadItems( repo_id, update=True ) + def is_valid_package_atom(x): try: testkey = portage.dep_getkey(x) diff --git a/bin/portageq b/bin/portageq index 791aa4c9a..6485d7c79 100755 --- a/bin/portageq +++ b/bin/portageq @@ -270,6 +270,17 @@ def envvar(argv): else: print portage.settings[arg] +def get_repos(argv): + """<root> + Returns all repos with names (repo_name file) argv[0] = $ROOT + """ + print " ".join(portage.db[argv[0]]["porttree"].dbapi.getRepositories()) + +def get_repo_path(argv): + """<root> <repo_id> + Returns the path to the repo named argv[1], argv[0] = $ROOT + """ + print portage.db[argv[0]]["porttree"].dbapi.getRepositoryPath(argv[1]) #----------------------------------------------------------------------------- # diff --git a/pym/portage.py b/pym/portage.py index c867769c5..3cbe7114d 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -71,7 +71,7 @@ try: MOVE_BINARY, PRELINK_BINARY, WORLD_FILE, MAKE_CONF_FILE, MAKE_DEFAULTS_FILE, \ DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \ INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, CONFIG_MEMORY_FILE,\ - INCREMENTALS, EAPI, MISC_SH_BINARY + INCREMENTALS, EAPI, MISC_SH_BINARY, REPO_NAME_LOC, REPO_NAME_FILE from portage_data import ostype, lchown, userland, secpass, uid, wheelgid, \ portage_uid, portage_gid, userpriv_groups @@ -4527,19 +4527,34 @@ def getmaskingstatus(mycpv, settings=None, portdb=None): return rValue class portagetree: - def __init__(self, root="/", virtual=None, clone=None, settings=None): + def __init__(self, root="/", virtual=None, clone=None, settings=None, portroot=None): + """ + Constructor for a PortageTree + + Note: Portroot was added for GLEP 42 functionality and defaults to the $PORTDIR + env variable. + + @param root: ${ROOT}, defaults to '/', see make.conf(5) + @type root: String/Path + @param virtual: UNUSED + @type virtual: No Idea + @param clone: Set this if you want a copy of Clone + @type clone: Existing portagetree Instance + @param settings: Portage Configuration object (portage.settings) + @type settings: Instance of portage.config + """ if clone: - self.root=clone.root - self.portroot=clone.portroot - self.pkglines=clone.pkglines + self.root = clone.root + self.portroot = clone.portroot + self.pkglines = clone.pkglines else: - self.root=root + self.root = root if settings is None: settings = globals()["settings"] self.settings = settings - self.portroot=settings["PORTDIR"] - self.virtual=virtual + self.portroot = settings["PORTDIR"] + self.virtual = virtual self.dbapi = portdbapi( settings["PORTDIR"], mysettings=settings) @@ -5532,6 +5547,14 @@ class portdbapi(dbapi): self.porttrees = [self.porttree_root] + \ [os.path.realpath(t) for t in self.mysettings["PORTDIR_OVERLAY"].split()] + self.treemap = {} + for path in self.porttrees: + try: + repo_name = open( os.path.join( path , REPO_NAME_LOC ) ,'r').readline().rstrip() + self.treemap[repo_name] = path + except (OSError,IOError): + pass + self.auxdbmodule = self.mysettings.load_best_module("portdbapi.auxdbmodule") self.auxdb = {} self._init_cache_dirs() @@ -5603,6 +5626,24 @@ class portdbapi(dbapi): def findname(self,mycpv): return self.findname2(mycpv)[0] + def getRepositoryPath( self, repository_id ): + """ + This function is required for GLEP 42 compliance; given a valid repository ID + it must return a path to the repository + TreeMap = { id:path } + """ + if repository_id in self.treemap: + return self.treemap[repository_id] + return None + + def getRepositories( self ): + """ + This function is required for GLEP 42 compliance; it will return a list of + repository ID's + TreeMap = { id:path } + """ + return [k for k in self.treemap.keys() if k] + def findname2(self, mycpv, mytree=None): """ Returns the location of the CPV, and what overlay it was in. diff --git a/pym/portage_const.py b/pym/portage_const.py index a5c552f02..f5b392506 100644 --- a/pym/portage_const.py +++ b/pym/portage_const.py @@ -44,6 +44,9 @@ CUSTOM_MIRRORS_FILE = USER_CONFIG_PATH+"/mirrors" CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config" COLOR_MAP_FILE = USER_CONFIG_PATH + "/color.map" +REPO_NAME_FILE = "repo_name" +REPO_NAME_LOC = "profiles" + "/" + REPO_NAME_FILE + INCREMENTALS=["USE","USE_EXPAND","USE_EXPAND_HIDDEN","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFIG_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"] EBUILD_PHASES = ["setup", "unpack", "compile", "test", "install", "preinst", "postinst", "prerm", "postrm", "other"] |