From 5c0718d81fcb264515e41c2cfe4030e2095b5faa Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Fri, 3 Apr 2009 23:11:57 +0200 Subject: [PATCH] generate-releases move the actual writing of the "sub"-release files into a function. Signed-off-by: Joerg Jaspert --- dak/generate_releases.py | 49 +++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 137c8447..8f86758e 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -121,6 +121,31 @@ def print_sha1_files (tree, files): def print_sha256_files (tree, files): print_md5sha_files (tree, files, apt_pkg.sha256sum) +def write_release_file (relpath, suite, component, origin, label, arch, version="", suite_suffix="", notautomatic=""): + try: + if os.access(relpath, os.F_OK): + if os.stat(relpath).st_nlink > 1: + os.unlink(relpath) + release = open(relpath, "w") + except IOError: + utils.fubar("Couldn't write to " + relpath) + + release.write("Archive: %s\n" % (suite)) + if version != "": + release.write("Version: %s\n" % (version)) + + if suite_suffix: + release.write("Component: %s/%s\n" % (suite_suffix,component)) + else: + release.write("Component: %s\n" % (component)) + + release.write("Origin: %s\n" % (origin)) + release.write("Label: %s\n" % (label)) + if notautomatic != "": + release.write("NotAutomatic: %s\n" % (notautomatic)) + release.write("Architecture: %s\n" % (arch)) + release.close() + ################################################################################ def main (): @@ -269,29 +294,7 @@ def main (): else: rel = "%s/binary-%s/Release" % (sec, arch) relpath = Cnf["Dir::Root"]+tree+"/"+rel - - try: - if os.access(relpath, os.F_OK): - if os.stat(relpath).st_nlink > 1: - os.unlink(relpath) - release = open(relpath, "w") - #release = open(longsuite.replace("/","_") + "_" + arch + "_" + sec + "_Release", "w") - except IOError: - utils.fubar("Couldn't write to " + relpath) - - release.write("Archive: %s\n" % (suite)) - if version != "": - release.write("Version: %s\n" % (version)) - if suite_suffix: - release.write("Component: %s/%s\n" % (suite_suffix,sec)) - else: - release.write("Component: %s\n" % (sec)) - release.write("Origin: %s\n" % (origin)) - release.write("Label: %s\n" % (label)) - if notautomatic != "": - release.write("NotAutomatic: %s\n" % (notautomatic)) - release.write("Architecture: %s\n" % (arch)) - release.close() + write_release_file(relpath, suite, sec, origin, label, arch, version, suite_suffix, notautomatic) files.append(rel) if AptCnf.has_key("tree::%s/main" % (tree)): -- 2.39.5