13
13
"precise": {'version': "12.04", 'devname': "Precise Pangolin"},
14
14
"quantal": {'version': "12.10", 'devname': "Quantal Quetzal"},
15
15
"raring": {'version': "13.04", 'devname': "Raring Ringtail"},
16
"saucy": {'version': "13.10", 'devname': "Saucy Salamander"},
18
19
RELEASES = [k for k in REL2VER if k != "hardy"]
27
29
if rel in ("lucid", "oneiric"):
28
30
# lucid, oneiric do not have -root.tar.gz
30
if rel == "precise" and cmp(serial, "20120202") <= 0:
32
if rel == "precise" and serial <= "20120202":
31
33
# precise got -root.tar.gz after alpha2
34
36
if repl == "-disk1.img":
37
if rel == "oneiric" and cmp(serial, "20110802.2") <= 0:
39
if rel == "oneiric" and serial <= "20110802.2":
38
40
# oneiric got -disk1.img after alpha3
41
43
#if some data in /query is not truely available, fill up this array
42
44
#to skip it. ex: export BROKEN="precise/20121212.1 quantal/20130128.1"
43
broken = os.environ.get("BROKEN","").split(" ")
45
broken = os.environ.get("BROKEN", "").split(" ")
44
46
if "%s/%s" % (rel, serial) in broken:
45
print "Known broken: %s/%s" % (rel, serial)
47
print("Known broken: %s/%s" % (rel, serial))
50
53
def load_query_download(path, builds=None, rels=None):
64
66
latest_f = "%s/%s.latest.txt" % (path, stream)
66
68
# get the builds and releases
67
with open(latest_f) as fp:
69
with open(latest_f, "r") as fp:
68
70
for line in fp.readlines():
69
71
(rel, build, _stream, _serial) = line.split("\t")
71
73
if ((len(builds) and build not in builds) or
72
(len(rels) and rel not in rels)):
74
(len(rels) and rel not in rels)):
75
77
dl_files.append("%s/%s/%s/%s-dl.txt" %
76
(path, rel, build, stream))
78
(path, rel, build, stream))
80
82
# stream/build/release/arch
81
83
for dl_file in dl_files:
82
olines = open(dl_file).readlines()
84
olines = open(dl_file, "r").readlines()
84
86
# download files in /query only contain '.tar.gz' (uec tarball)
85
87
# file. So we have to make up other entries.
120
122
latest_f = "%s/%s.latest.txt" % (path, stream)
122
124
# get the builds and releases
123
with open(latest_f) as fp:
125
with open(latest_f, "r") as fp:
124
126
for line in fp.readlines():
125
127
(rel, build, _stream, _serial) = line.split("\t")
127
129
if ((len(builds) and build not in builds) or
128
(len(rels) and rel not in rels)):
130
(len(rels) and rel not in rels)):
131
133
id_files.append("%s/%s/%s/%s.txt" %
132
(path, rel, build, stream))
134
(path, rel, build, stream))
134
136
for id_file in id_files:
135
lines = reversed(open(id_file).readlines())
137
lines = reversed(open(id_file, "r").readlines())
137
139
last_serial = None
138
140
for line in lines:
156
def get_sign_cmd(path, output=None, clearsign=False, armor=True):
158
defkey = os.environ.get('SS_GPG_DEFAULT_KEY')
160
cmd.extend(['--default-key', defkey])
162
batch = os.environ.get('SS_GPG_BATCH', "1").lower()
163
if batch not in ("0", "false"):
164
cmd.append('--batch')
167
cmd.extend(['--output', output])
170
cmd.append('--clearsign')
173
cmd.append('--armor')
180
def signfile(path, output=None):
182
output = path + ".gpg"
184
if os.path.exists(output):
187
subprocess.check_output(get_sign_cmd(path, output))
190
def signfile_inline(path, output=None):
194
# sign "in place" by using a temp file.
195
tmpfile = "%s.tmp" % path
196
os.rename(path, tmpfile)
199
elif os.path.exists(output):
202
subprocess.check_output(get_sign_cmd(infile, output, clearsign=True))
208
def signjs_file(fname, status_cb=None):
158
def signjson_file(fname, status_cb=None):
159
# input fname should be .json
160
# creates .json.gpg and .sjson
210
with open(fname) as fp:
162
with open(fname, "r") as fp:
211
163
content = fp.read()
212
data = json.loads(content)
213
fmt = data.get("format")
214
sjs = fname[0:-len(".js")] + ".sjs"
216
if status_cb is None:
217
def null_cb(fname, fmt):
221
if fmt == "products:1.0":
222
status_cb(fname, fmt)
224
signfile_inline(fname, sjs)
225
elif fmt == "index:1.0":
226
status_cb(fname, fmt)
228
for _content_id, content in data.get('index').iteritems():
229
path = content.get('path')
230
if path.endswith(".js"):
231
content['path'] = path[0:-len(".js")] + ".sjs"
232
with open(sjs, "w") as fp:
233
fp.write(json.dumps(data, indent=1))
164
(changed, scontent) = util.make_signed_content_paths(content)
169
util.sign_file(fname, inline=False)
171
util.sign_content(scontent, util.signed_fname(fname, inline=True),
237
status_cb(fname, fmt)
174
util.sign_file(fname, inline=True)
240
179
# vi: ts=4 expandtab syntax=python