From: Mark Hymers <mhy@debian.org>
Date: Fri, 25 Mar 2011 18:15:42 +0000 (+0000)
Subject: Fix generate_release to include the Architecture: line in subrelease files.
X-Git-Tag: debian-r/squeeze~228^2~9^2~2
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fc3ac588d53dabdae2e8cd1678cb9050dd9c8a9e;p=dak.git

Fix generate_release to include the Architecture: line in subrelease files.

Also deal with the possiblity that files may have been hardlinked by
writing to a new file and renaming.

Signed-off-by: Mark Hymers <mhy@debian.org>
---

diff --git a/dak/generate_releases.py b/dak/generate_releases.py
index e67bd91f..a3ed5a4f 100755
--- a/dak/generate_releases.py
+++ b/dak/generate_releases.py
@@ -138,9 +138,9 @@ class ReleaseWriter(object):
                     ('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
@@ -187,7 +187,7 @@ class ReleaseWriter(object):
                     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:
@@ -198,8 +198,18 @@ class ReleaseWriter(object):
                         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()