1 |
Author: zmedico |
2 |
Date: 2009-04-30 07:18:07 +0000 (Thu, 30 Apr 2009) |
3 |
New Revision: 13515 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.6/bin/repoman |
7 |
Log: |
8 |
Support profiles.desc from overlays. (trunk r13359) |
9 |
|
10 |
Modified: main/branches/2.1.6/bin/repoman |
11 |
=================================================================== |
12 |
--- main/branches/2.1.6/bin/repoman 2009-04-30 07:17:50 UTC (rev 13514) |
13 |
+++ main/branches/2.1.6/bin/repoman 2009-04-30 07:18:07 UTC (rev 13515) |
14 |
@@ -540,6 +540,18 @@ |
15 |
def caterror(mycat): |
16 |
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.") |
17 |
|
18 |
+class ProfileDesc(object): |
19 |
+ __slots__ = ('abs_path', 'arch', 'status', 'sub_path', 'tree_path',) |
20 |
+ def __init__(self, arch, status, sub_path, tree_path): |
21 |
+ self.arch = arch |
22 |
+ self.status = status |
23 |
+ self.sub_path = normalize_path(sub_path.lstrip(os.sep)) |
24 |
+ self.tree_path = tree_path |
25 |
+ self.abs_path = os.path.join(tree_path, 'profiles', self.sub_path) |
26 |
+ |
27 |
+profile_list = [] |
28 |
+valid_profile_types = frozenset(['dev', 'exp', 'stable']) |
29 |
+ |
30 |
# get lists of valid keywords, licenses, and use |
31 |
kwlist = set() |
32 |
liclist = set() |
33 |
@@ -574,6 +586,60 @@ |
34 |
if x: |
35 |
uselist.add(use_prefix + x[0]) |
36 |
|
37 |
+ desc_path = os.path.join(path, 'profiles', 'profiles.desc') |
38 |
+ try: |
39 |
+ desc_file = codecs.open(desc_path, mode='r', errors='replace') |
40 |
+ except OSError: |
41 |
+ pass |
42 |
+ else: |
43 |
+ for i, x in enumerate(desc_file): |
44 |
+ if x[0] == "#": |
45 |
+ continue |
46 |
+ arch = x.split() |
47 |
+ if len(arch) == 0: |
48 |
+ continue |
49 |
+ if len(arch) != 3: |
50 |
+ err("wrong format: \"" + bad(x.strip()) + "\" in " + \ |
51 |
+ desc_path + " line %d" % (i+1, )) |
52 |
+ elif arch[0] not in kwlist: |
53 |
+ err("invalid arch: \"" + bad(arch[0]) + "\" in " + \ |
54 |
+ desc_path + " line %d" % (i+1, )) |
55 |
+ elif arch[2] not in valid_profile_types: |
56 |
+ err("invalid profile type: \"" + bad(arch[2]) + "\" in " + \ |
57 |
+ desc_path + " line %d" % (i+1, )) |
58 |
+ profile_desc = ProfileDesc(arch[0], arch[2], arch[1], portdir) |
59 |
+ if not os.path.isdir(profile_desc.abs_path): |
60 |
+ logging.error( |
61 |
+ "Invalid %s profile (%s) for arch %s in %s line %d", |
62 |
+ arch[2], arch[1], arch[0], desc_path, i+1) |
63 |
+ continue |
64 |
+ profile_list.append(profile_desc) |
65 |
+ desc_file.close() |
66 |
+ |
67 |
+repoman_settings['PORTAGE_ARCHLIST'] = ' '.join(sorted(kwlist)) |
68 |
+repoman_settings.backup_changes('PORTAGE_ARCHLIST') |
69 |
+ |
70 |
+# Ensure that profile sub_path attributes are unique. Process in reverse order |
71 |
+# so that profiles with duplicate sub_path from overlays will override |
72 |
+# profiles with the same sub_path from parent repos. |
73 |
+profiles = {} |
74 |
+profile_list.reverse() |
75 |
+profile_sub_paths = set() |
76 |
+for prof in profile_list: |
77 |
+ if prof.sub_path in profile_sub_paths: |
78 |
+ continue |
79 |
+ profile_sub_paths.add(prof.sub_path) |
80 |
+ profiles.setdefault(prof.arch, []).append(prof) |
81 |
+ |
82 |
+for x in repoman_settings.archlist(): |
83 |
+ if x[0] == "~": |
84 |
+ continue |
85 |
+ if x not in profiles: |
86 |
+ print red("\""+x+"\" doesn't have a valid profile listed in profiles.desc.") |
87 |
+ print red("You need to either \"cvs update\" your profiles dir or follow this") |
88 |
+ print red("up with the "+x+" team.") |
89 |
+ print |
90 |
+ |
91 |
if not liclist: |
92 |
logging.fatal("Couldn't find licenses?") |
93 |
sys.exit(1) |
94 |
@@ -620,53 +686,6 @@ |
95 |
|
96 |
logging.debug("Found the following packages to scan:\n%s" % '\n'.join(scanlist)) |
97 |
|
98 |
-class ProfileDesc(object): |
99 |
- __slots__ = ('abs_path', 'status', 'sub_path', 'tree_path',) |
100 |
- def __init__(self, status, sub_path, tree_path): |
101 |
- self.status = status |
102 |
- self.sub_path = normalize_path(sub_path.lstrip(os.sep)) |
103 |
- self.tree_path = tree_path |
104 |
- self.abs_path = os.path.join(tree_path, 'profiles', self.sub_path) |
105 |
- |
106 |
-profiles={} |
107 |
-valid_profile_types = frozenset(["dev", "exp", "stable"]) |
108 |
-descfile=portdir+"/profiles/profiles.desc" |
109 |
-if os.path.exists(descfile): |
110 |
- for i, x in enumerate(open(descfile)): |
111 |
- if x[0]=="#": |
112 |
- continue |
113 |
- arch=x.split() |
114 |
- if len(arch) == 0: |
115 |
- continue |
116 |
- if len(arch)!=3: |
117 |
- err("wrong format: \"" + bad(x.strip()) + "\" in " + \ |
118 |
- descfile + " line %d" % (i+1, )) |
119 |
- elif arch[0] not in kwlist: |
120 |
- err("invalid arch: \"" + bad(arch[0]) + "\" in " + \ |
121 |
- descfile + " line %d" % (i+1, )) |
122 |
- elif arch[2] not in valid_profile_types: |
123 |
- err("invalid profile type: \"" + bad(arch[2]) + "\" in " + \ |
124 |
- descfile + " line %d" % (i+1, )) |
125 |
- profile_desc = ProfileDesc(arch[2], arch[1], portdir) |
126 |
- if not os.path.isdir(profile_desc.abs_path): |
127 |
- print "Invalid "+arch[2]+" profile ("+arch[1]+") for arch "+arch[0] |
128 |
- continue |
129 |
- profiles.setdefault(arch[0], []).append(profile_desc) |
130 |
- |
131 |
- for x in repoman_settings.archlist(): |
132 |
- if x[0] == "~": |
133 |
- continue |
134 |
- if x not in profiles: |
135 |
- print red("\""+x+"\" doesn't have a valid profile listed in profiles.desc.") |
136 |
- print red("You need to either \"cvs update\" your profiles dir or follow this") |
137 |
- print red("up with the "+x+" team.") |
138 |
- print |
139 |
-else: |
140 |
- print red("profiles.desc does not exist: "+descfile) |
141 |
- print red("You need to do \"cvs update\" in profiles dir.") |
142 |
- print |
143 |
- sys.exit(1) |
144 |
- |
145 |
def dev_keywords(profiles): |
146 |
""" |
147 |
Create a set of KEYWORDS values that exist in 'dev' |