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()
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)
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)
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
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)
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()
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.
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"]