Make the apt repo directory structure exist if it doesn't already.
[invirt/packages/invirt-dev.git] / invirtibuilder
index f5cdfb4..4849bee 100755 (executable)
@@ -20,12 +20,14 @@ Each queue file contains a file of the form
     pocket package hash principal
 
 where pocket is one of the pockets globally configured in
     pocket package hash principal
 
 where pocket is one of the pockets globally configured in
-git.pockets. For instance, the pockets in XVM are "prod" and "dev".
+build.pockets. For instance, the pockets in XVM are "prod" and "dev".
 
 principal is the Kerberos principal that requested the build.
 """
 
 
 
 principal is the Kerberos principal that requested the build.
 """
 
 
+from __future__ import with_statement
+
 import contextlib
 import os
 import re
 import contextlib
 import os
 import re
@@ -70,10 +72,14 @@ def getArches(package, ref):
 def getDscName(package, ref):
     """Return the .dsc file that will be generated for this package."""
     v = getVersion(package, ref)
 def getDscName(package, ref):
     """Return the .dsc file that will be generated for this package."""
     v = getVersion(package, ref)
-    return '%s_%s-%s.dsc' % (
+    if v.debian_version:
+        v_str = '%s-%s' % (v.upstream_version,
+                           v.debian_version)
+    else:
+        v_str = v.upstream_version
+    return '%s_%s.dsc' % (
         package,
         package,
-        version.upstream_version,
-        version.debian_version)
+        v_str)
 
 
 def sanitizeVersion(version):
 
 
 def sanitizeVersion(version):
@@ -81,19 +87,17 @@ def sanitizeVersion(version):
 
     This function strips the epoch from the version number and
     replaces any tildes with periods."""
 
     This function strips the epoch from the version number and
     replaces any tildes with periods."""
-    v = '%s-%s' % (version.upstream_version,
-                   version.debian_version)
+    if v.debian_version:
+        v = '%s-%s' % (version.upstream_version,
+                       version.debian_version)
+    else:
+        v = version.upstream_version
     return v.replace('~', '.')
 
 
 def aptCopy(packages, dst_pocket, src_pocket):
     """Copy a package from one pocket to another."""
     return v.replace('~', '.')
 
 
 def aptCopy(packages, dst_pocket, src_pocket):
     """Copy a package from one pocket to another."""
-    binaries = []
-    for line in b.getGitFile(package, commit, 'debian/control').split('\n'):
-        m = re.match('Package: (.*)$')
-        if m:
-            binaries.append(m.group(1))
-
+    binaries = getBinaries(package, commit)
     cpatureOutput(['reprepro-env', 'copy',
                    b.pocketToApt(dst_pocket),
                    b.pocketToApt(src_pocket),
     cpatureOutput(['reprepro-env', 'copy',
                    b.pocketToApt(dst_pocket),
                    b.pocketToApt(src_pocket),
@@ -133,13 +137,13 @@ def tagSubmodule(pocket, package, ref, principal):
     I'm sure that long description gives you great confidence in teh
     legitimacy of my reasoning.
     """
     I'm sure that long description gives you great confidence in teh
     legitimacy of my reasoning.
     """
-    if config.git.pockets[pocket].get('allow_backtracking', False):
+    if config.build.pockets[pocket].get('allow_backtracking', False):
         env = dict(os.environ)
         branch = b.pocketToGit(pocket)
         version = b.getVersion(package, ref)
 
         env = dict(os.environ)
         branch = b.pocketToGit(pocket)
         version = b.getVersion(package, ref)
 
-        env['GIT_COMMITTER_NAME'] = config.git.tagger.name
-        env['GIT_COMMITTER_EMAIL'] = config.git.tagger.email
+        env['GIT_COMMITTER_NAME'] = config.build.tagger.name
+        env['GIT_COMMITTER_EMAIL'] = config.build.tagger.email
         tag_msg = ('Tag %s of %s\n\n'
                    'Requested by %s' % (version.full_version,
                                         package,
         tag_msg = ('Tag %s of %s\n\n'
                    'Requested by %s' % (version.full_version,
                                         package,
@@ -178,7 +182,7 @@ def updateSuperrepo(pocket, package, commit, principal):
     Note that there's no locking issue here, because we disallow all
     pushes to the superrepo.
     """
     Note that there's no locking issue here, because we disallow all
     pushes to the superrepo.
     """
-    superrepo = os.path.join(b._REPO_DIR, 'packages.git')
+    superrepo = os.path.join(b._REPO_DIR, 'invirt/packages.git')
     branch = b.pocketToGit(pocket)
     tree = c.captureOutput(['git', 'ls-tree', branch],
                          cwd=superrepo)
     branch = b.pocketToGit(pocket)
     tree = c.captureOutput(['git', 'ls-tree', branch],
                          cwd=superrepo)