diff options
-rwxr-xr-x | bin/repoman | 113 |
1 files changed, 66 insertions, 47 deletions
diff --git a/bin/repoman b/bin/repoman index 0c2b5708e..b568bbead 100755 --- a/bin/repoman +++ b/bin/repoman @@ -540,6 +540,18 @@ repodir = os.path.realpath(repodir) def caterror(mycat): err(mycat+" is not an official category. Skipping QA checks in this directory.\nPlease ensure that you add "+catdir+" to "+repodir+"/profiles/categories\nif it is a new category.") +class ProfileDesc(object): + __slots__ = ('abs_path', 'arch', 'status', 'sub_path', 'tree_path',) + def __init__(self, arch, status, sub_path, tree_path): + self.arch = arch + self.status = status + self.sub_path = normalize_path(sub_path.lstrip(os.sep)) + self.tree_path = tree_path + self.abs_path = os.path.join(tree_path, 'profiles', self.sub_path) + +profile_list = [] +valid_profile_types = frozenset(['dev', 'exp', 'stable']) + # get lists of valid keywords, licenses, and use kwlist = set() liclist = set() @@ -574,6 +586,60 @@ for path in portdb.porttrees: if x: uselist.add(use_prefix + x[0]) + desc_path = os.path.join(path, 'profiles', 'profiles.desc') + try: + desc_file = codecs.open(desc_path, mode='r', errors='replace') + except OSError: + 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: \"" + bad(x.strip()) + "\" in " + \ + desc_path + " line %d" % (i+1, )) + elif arch[0] not in kwlist: + err("invalid arch: \"" + bad(arch[0]) + "\" in " + \ + desc_path + " line %d" % (i+1, )) + elif arch[2] not in valid_profile_types: + err("invalid profile type: \"" + bad(arch[2]) + "\" in " + \ + desc_path + " line %d" % (i+1, )) + profile_desc = ProfileDesc(arch[0], arch[2], arch[1], portdir) + 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 + profile_list.append(profile_desc) + desc_file.close() + +repoman_settings['PORTAGE_ARCHLIST'] = ' '.join(sorted(kwlist)) +repoman_settings.backup_changes('PORTAGE_ARCHLIST') + +# Ensure that profile sub_path attributes are unique. Process in reverse order +# so that profiles with duplicate sub_path from overlays will override +# profiles with the same sub_path from parent repos. +profiles = {} +profile_list.reverse() +profile_sub_paths = set() +for prof in profile_list: + if prof.sub_path in profile_sub_paths: + continue + profile_sub_paths.add(prof.sub_path) + profiles.setdefault(prof.arch, []).append(prof) + +for x in repoman_settings.archlist(): + if x[0] == "~": + continue + if x not in profiles: + print red("\""+x+"\" doesn't have a valid profile listed in profiles.desc.") + print red("You need to either \"cvs update\" your profiles dir or follow this") + print red("up with the "+x+" team.") + print + if not liclist: logging.fatal("Couldn't find licenses?") sys.exit(1) @@ -620,53 +686,6 @@ scanlist.sort() logging.debug("Found the following packages to scan:\n%s" % '\n'.join(scanlist)) -class ProfileDesc(object): - __slots__ = ('abs_path', 'status', 'sub_path', 'tree_path',) - def __init__(self, status, sub_path, tree_path): - self.status = status - self.sub_path = normalize_path(sub_path.lstrip(os.sep)) - self.tree_path = tree_path - self.abs_path = os.path.join(tree_path, 'profiles', self.sub_path) - -profiles={} -valid_profile_types = frozenset(["dev", "exp", "stable"]) -descfile=portdir+"/profiles/profiles.desc" -if os.path.exists(descfile): - for i, x in enumerate(open(descfile)): - if x[0]=="#": - continue - arch=x.split() - if len(arch) == 0: - continue - if len(arch)!=3: - err("wrong format: \"" + bad(x.strip()) + "\" in " + \ - descfile + " line %d" % (i+1, )) - elif arch[0] not in kwlist: - err("invalid arch: \"" + bad(arch[0]) + "\" in " + \ - descfile + " line %d" % (i+1, )) - elif arch[2] not in valid_profile_types: - err("invalid profile type: \"" + bad(arch[2]) + "\" in " + \ - descfile + " line %d" % (i+1, )) - profile_desc = ProfileDesc(arch[2], arch[1], portdir) - if not os.path.isdir(profile_desc.abs_path): - print "Invalid "+arch[2]+" profile ("+arch[1]+") for arch "+arch[0] - continue - profiles.setdefault(arch[0], []).append(profile_desc) - - for x in repoman_settings.archlist(): - if x[0] == "~": - continue - if x not in profiles: - print red("\""+x+"\" doesn't have a valid profile listed in profiles.desc.") - print red("You need to either \"cvs update\" your profiles dir or follow this") - print red("up with the "+x+" team.") - print -else: - print red("profiles.desc does not exist: "+descfile) - print red("You need to do \"cvs update\" in profiles dir.") - print - sys.exit(1) - def dev_keywords(profiles): """ Create a set of KEYWORDS values that exist in 'dev' |