if arg:
results.append(arg)
-def sign_release_dir(dirname):
+def sign_release_dir(suite, dirname):
cnf = Config()
if cnf.has_key("Dinstall::SigningKeyring"):
keyring += " --keyring \"%s\"" % cnf["Dinstall::SigningPubKeyring"]
arguments = "--no-options --batch --no-tty --armour"
- signkeyids = cnf.signingkeyids.split()
relname = os.path.join(dirname, 'Release')
if os.path.exists(inlinedest):
os.unlink(inlinedest)
- for keyid in signkeyids:
- if keyid != "":
- defkeyid = "--default-key %s" % keyid
- else:
- defkeyid = ""
+ # We can only use one key for inline signing so use the first one in
+ # the array for consistency
+ firstkey = True
+
+ for keyid in suite.signingkeys:
+ defkeyid = "--default-key %s" % keyid
os.system("gpg %s %s %s --detach-sign <%s >>%s" %
(keyring, defkeyid, arguments, relname, dest))
- os.system("gpg %s %s %s --clearsign <%s >>%s" %
- (keyring, defkeyid, arguments, relname, inlinedest))
+ if firstkey:
+ os.system("gpg %s %s %s --clearsign <%s >>%s" %
+ (keyring, defkeyid, arguments, relname, inlinedest))
+ firstkey = False
class ReleaseWriter(object):
def __init__(self, suite):
('Codename', 'codename') )
# A "Sub" Release file has slightly different fields
- subattribs = ( ('Origin', 'origin'),
+ subattribs = ( ('Archive', 'suite_name'),
+ ('Origin', 'origin'),
('Label', 'label'),
- ('Archive', 'suite_name'),
('Version', 'version') )
# Boolean stuff. If we find it true in database, write out "yes" into the release file
cnf = Config()
- outfile = os.path.join(cnf["Dir::Root"], 'dists', suite.suite_name, "Release")
- print outfile
- out = open(outfile, "w")
+ suite_suffix = "%s" % (cnf.Find("Dinstall::SuiteSuffix"))
+
+ outfile = os.path.join(cnf["Dir::Root"], 'dists', "%s/%s" % (suite.suite_name, suite_suffix), "Release")
+ out = open(outfile + ".new", "w")
for key, dbfield in attribs:
if getattr(suite, dbfield) is not None:
- out.write("%s: %s\n" % (key, getattr(suite, dbfield)))
+ # TEMPORARY HACK HACK HACK until we change the way we store the suite names etc
+ if key == 'Suite' and getattr(suite, dbfield) == 'squeeze-updates':
+ out.write("Suite: stable-updates\n")
+ else:
+ out.write("%s: %s\n" % (key, getattr(suite, dbfield)))
out.write("Date: %s\n" % (time.strftime("%a, %d %b %Y %H:%M:%S UTC", time.gmtime(time.time()))))
out.write("Architectures: %s\n" % (" ".join([a.arch_string for a in architectures])))
- suite_suffix = "%s" % (cnf.Find("Dinstall::SuiteSuffix"))
-
## FIXME: Components need to be adjusted to whatever will be in the db
## Needs putting in the DB
components = ['main', 'contrib', 'non-free']
out.write("Description: %s\n" % suite.description)
for comp in components:
- for dirpath, dirnames, filenames in os.walk("%sdists/%s/%s" % (cnf["Dir::Root"], suite.suite_name, comp), topdown=True):
+ for dirpath, dirnames, filenames in os.walk("%sdists/%s/%s%s" % (cnf["Dir::Root"], suite.suite_name, suite_suffix, comp), topdown=True):
if not re_gensubrelease.match(dirpath):
continue
subfile = os.path.join(dirpath, "Release")
- subrel = open(subfile, "w")
+ subrel = open(subfile + '.new', "w")
for key, dbfield in subattribs:
if getattr(suite, dbfield) is not None:
subrel.write("%s: yes\n" % (key))
subrel.write("Component: %s%s\n" % (suite_suffix, comp))
+
+ # Urgh, but until we have all the suite/component/arch stuff in the DB,
+ # this'll have to do
+ arch = os.path.split(dirpath)[-1]
+ if arch.startswith('binary-'):
+ arch = arch[7:]
+
+ subrel.write("Architecture: %s\n" % (arch))
subrel.close()
+ os.rename(subfile + '.new', subfile)
+
# Now that we have done the groundwork, we want to get off and add the files with
# their checksums to the main Release file
oldcwd = os.getcwd()
- os.chdir("%sdists/%s" % (cnf["Dir::Root"], suite.suite_name))
+ os.chdir("%sdists/%s/%s" % (cnf["Dir::Root"], suite.suite_name, suite_suffix))
hashfuncs = { 'MD5Sum' : apt_pkg.md5sum,
'SHA1' : apt_pkg.sha1sum,
out.write(" %s %8d %s\n" % (fileinfo[filename][h], fileinfo[filename]['len'], filename))
out.close()
+ os.rename(outfile + '.new', outfile)
- sign_release_dir(os.path.dirname(outfile))
+ sign_release_dir(suite, os.path.dirname(outfile))
os.chdir(oldcwd)