def get_herd_base(repoman_settings): try: herd_base = make_herd_base( os.path.join(repoman_settings["PORTDIR"], "metadata/herds.xml")) except (EnvironmentError, ParseError, PermissionDenied) as e: err(str(e)) except FileNotFound: # TODO: Download as we do for metadata.dtd, but add a way to # disable for non-gentoo repoman users who may not have herds. herd_base = None return herd_base
def commit_check(repolevel, reposplit): # Check if it's in $PORTDIR/$CATEGORY/$PN , otherwise bail if commiting. # Reason for this is if they're trying to commit in just $FILESDIR/*, # the Manifest needs updating. # This check ensures that repoman knows where it is, # and the manifest recommit is at least possible. if repolevel not in [1, 2, 3]: print(red("***") + (" Commit attempts *must* be from within a vcs checkout," " category, or package directory.")) print(red("***") + (" Attempting to commit from a packages files directory" " will be blocked for instance.")) print(red("***") + (" This is intended behaviour," " to ensure the manifest is recommitted for a package.")) print(red("***")) err("Unable to identify level we're commiting from for %s" % '/'.join(reposplit))
def commit_check(repolevel, reposplit): # Check if it's in $PORTDIR/$CATEGORY/$PN , otherwise bail if commiting. # Reason for this is if they're trying to commit in just $FILESDIR/*, # the Manifest needs updating. # This check ensures that repoman knows where it is, # and the manifest recommit is at least possible. if repolevel not in [1, 2, 3]: print(red("***") + ( " Commit attempts *must* be from within a vcs checkout," " category, or package directory.")) print(red("***") + ( " Attempting to commit from a packages files directory" " will be blocked for instance.")) print(red("***") + ( " This is intended behaviour," " to ensure the manifest is recommitted for a package.")) print(red("***")) err( "Unable to identify level we're commiting from for %s" % '/'.join(reposplit))
def _vcs_unadded(self): myunadded = [] mydeleted = [] if self.vcs_settings.vcs == "cvs": try: myvcstree = portage.cvstree.getentries("./", recursive=1) myunadded = portage.cvstree.findunadded(myvcstree, recursive=1, basedir="./") except SystemExit: raise # TODO propagate this except: err("Error retrieving CVS tree; exiting.") if self.vcs_settings.vcs == "svn": try: with repoman_popen("svn status --no-ignore") as f: svnstatus = f.readlines() myunadded = [ "./" + elem.rstrip().split()[1] for elem in svnstatus if elem.startswith("?") or elem.startswith("I") ] except SystemExit: raise # TODO propagate this except: err("Error retrieving SVN info; exiting.") if self.vcs_settings.vcs == "git": # get list of files not under version control or missing myf = repoman_popen("git ls-files --others") myunadded = ["./" + elem[:-1] for elem in myf] myf.close() if self.vcs_settings.vcs == "bzr": try: with repoman_popen("bzr status -S .") as f: bzrstatus = f.readlines() myunadded = [ "./" + elem.rstrip().split()[1].split('/')[-1:][0] for elem in bzrstatus if elem.startswith("?") or elem[0:2] == " D" ] except SystemExit: raise # TODO propagate this except: err("Error retrieving bzr info; exiting.") if self.vcs_settings.vcs == "hg": with repoman_popen("hg status --no-status --unknown .") as f: myunadded = f.readlines() myunadded = ["./" + elem.rstrip() for elem in myunadded] # Mercurial doesn't handle manually deleted files as removed from # the repository, so the user need to remove them before commit, # using "hg remove [FILES]" with repoman_popen("hg status --no-status --deleted .") as f: mydeleted = f.readlines() mydeleted = ["./" + elem.rstrip() for elem in mydeleted] return myunadded, mydeleted
def _vcs_unadded(self): myunadded = [] mydeleted = [] if self.vcs_settings.vcs == "cvs": try: myvcstree = portage.cvstree.getentries("./", recursive=1) myunadded = portage.cvstree.findunadded( myvcstree, recursive=1, basedir="./") except SystemExit: raise # TODO propagate this except: err("Error retrieving CVS tree; exiting.") if self.vcs_settings.vcs == "svn": try: with repoman_popen("svn status --no-ignore") as f: svnstatus = f.readlines() myunadded = [ "./" + elem.rstrip().split()[1] for elem in svnstatus if elem.startswith("?") or elem.startswith("I")] except SystemExit: raise # TODO propagate this except: err("Error retrieving SVN info; exiting.") if self.vcs_settings.vcs == "git": # get list of files not under version control or missing myf = repoman_popen("git ls-files --others") myunadded = ["./" + elem[:-1] for elem in myf] myf.close() if self.vcs_settings.vcs == "bzr": try: with repoman_popen("bzr status -S .") as f: bzrstatus = f.readlines() myunadded = [ "./" + elem.rstrip().split()[1].split('/')[-1:][0] for elem in bzrstatus if elem.startswith("?") or elem[0:2] == " D"] except SystemExit: raise # TODO propagate this except: err("Error retrieving bzr info; exiting.") if self.vcs_settings.vcs == "hg": with repoman_popen("hg status --no-status --unknown .") as f: myunadded = f.readlines() myunadded = ["./" + elem.rstrip() for elem in myunadded] # Mercurial doesn't handle manually deleted files as removed from # the repository, so the user need to remove them before commit, # using "hg remove [FILES]" with repoman_popen("hg status --no-status --deleted .") as f: mydeleted = f.readlines() mydeleted = ["./" + elem.rstrip() for elem in mydeleted] return myunadded, mydeleted
def repo_metadata(portdb, repoman_settings): # get lists of valid keywords, licenses, and use kwlist = set() liclist = set() uselist = set() profile_list = [] global_pmasklines = [] for path in portdb.porttrees: try: liclist.update(os.listdir(os.path.join(path, "licenses"))) except OSError: pass kwlist.update( portage.grabfile(os.path.join(path, "profiles", "arch.list"))) use_desc = portage.grabfile(os.path.join(path, 'profiles', 'use.desc')) for x in use_desc: x = x.split() if x: uselist.add(x[0]) expand_desc_dir = os.path.join(path, 'profiles', 'desc') try: expand_list = os.listdir(expand_desc_dir) except OSError: pass else: for fn in expand_list: if not fn[-5:] == '.desc': continue use_prefix = fn[:-5].lower() + '_' for x in portage.grabfile(os.path.join(expand_desc_dir, fn)): x = x.split() if x: uselist.add(use_prefix + x[0]) global_pmasklines.append( portage.util.grabfile_package(os.path.join(path, 'profiles', 'package.mask'), recursive=1, verify_eapi=True)) desc_path = os.path.join(path, 'profiles', 'profiles.desc') try: desc_file = io.open(_unicode_encode(desc_path, encoding=_encodings['fs'], errors='strict'), mode='r', encoding=_encodings['repo.content'], errors='replace') except EnvironmentError: pass else: for i, x in enumerate(desc_file): if x[0] == "#": continue arch = x.split() if len(arch) == 0: continue if len(arch) != 3: err("wrong format: \"%s\" in %s line %d" % ( bad(x.strip()), desc_path, i + 1, )) elif arch[0] not in kwlist: err("invalid arch: \"%s\" in %s line %d" % ( bad(arch[0]), desc_path, i + 1, )) elif arch[2] not in valid_profile_types: err("invalid profile type: \"%s\" in %s line %d" % ( bad(arch[2]), desc_path, i + 1, )) profile_desc = ProfileDesc(arch[0], arch[2], arch[1], path) if not os.path.isdir(profile_desc.abs_path): logging.error( "Invalid %s profile (%s) for arch %s in %s line %d", arch[2], arch[1], arch[0], desc_path, i + 1) continue if os.path.exists( os.path.join(profile_desc.abs_path, 'deprecated')): continue profile_list.append(profile_desc) desc_file.close() global_pmasklines = portage.util.stack_lists(global_pmasklines, incremental=1) global_pmaskdict = {} for x in global_pmasklines: global_pmaskdict.setdefault(x.cp, []).append(x) del global_pmasklines return (kwlist, liclist, uselist, profile_list, global_pmaskdict, list_checks(kwlist, liclist, uselist, repoman_settings))
def repo_metadata(portdb, repoman_settings): # get lists of valid keywords, licenses, and use kwlist = set() liclist = set() uselist = set() profile_list = [] global_pmasklines = [] for path in portdb.porttrees: try: liclist.update(os.listdir(os.path.join(path, "licenses"))) except OSError: pass kwlist.update( portage.grabfile(os.path.join(path, "profiles", "arch.list"))) use_desc = portage.grabfile(os.path.join(path, 'profiles', 'use.desc')) for x in use_desc: x = x.split() if x: uselist.add(x[0]) expand_desc_dir = os.path.join(path, 'profiles', 'desc') try: expand_list = os.listdir(expand_desc_dir) except OSError: pass else: for fn in expand_list: if not fn[-5:] == '.desc': continue use_prefix = fn[:-5].lower() + '_' for x in portage.grabfile(os.path.join(expand_desc_dir, fn)): x = x.split() if x: uselist.add(use_prefix + x[0]) global_pmasklines.append( portage.util.grabfile_package( os.path.join(path, 'profiles', 'package.mask'), recursive=1, verify_eapi=True)) desc_path = os.path.join(path, 'profiles', 'profiles.desc') try: desc_file = io.open( _unicode_encode( desc_path, encoding=_encodings['fs'], errors='strict'), mode='r', encoding=_encodings['repo.content'], errors='replace') except EnvironmentError: pass else: for i, x in enumerate(desc_file): if x[0] == "#": continue arch = x.split() if len(arch) == 0: continue if len(arch) != 3: err( "wrong format: \"%s\" in %s line %d" % (bad(x.strip()), desc_path, i + 1, )) elif arch[0] not in kwlist: err( "invalid arch: \"%s\" in %s line %d" % (bad(arch[0]), desc_path, i + 1, )) elif arch[2] not in valid_profile_types: err( "invalid profile type: \"%s\" in %s line %d" % (bad(arch[2]), desc_path, i + 1, )) profile_desc = ProfileDesc(arch[0], arch[2], arch[1], path) if not os.path.isdir(profile_desc.abs_path): logging.error( "Invalid %s profile (%s) for arch %s in %s line %d", arch[2], arch[1], arch[0], desc_path, i + 1) continue if os.path.exists( os.path.join(profile_desc.abs_path, 'deprecated')): continue profile_list.append(profile_desc) desc_file.close() global_pmasklines = portage.util.stack_lists(global_pmasklines, incremental=1) global_pmaskdict = {} for x in global_pmasklines: global_pmaskdict.setdefault(x.cp, []).append(x) del global_pmasklines return ( kwlist, liclist, uselist, profile_list, global_pmaskdict, list_checks(kwlist, liclist, uselist, repoman_settings))