]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: Add additional repos for develop and feature branches.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 24 Jul 2014 00:24:46 +0000 (02:24 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 24 Jul 2014 00:24:46 +0000 (02:24 +0200)
debian_build.py
lib/sbuild.py

index ed2dc9537af3154000139ac733d2abd91df9b171..f1398dd50fba764e9601fc33aab5ef022b6fabbd 100755 (executable)
@@ -281,6 +281,7 @@ if __name__ == '__main__':
         new_version = curr_version + options.version_suffix
         reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist)
         apt_target = "repo01-debian"
+        additional_repos = []
 
         # replace valid debian version chars that are invalid for git tagging
         new_tag = curr_version.replace('~', '_').replace(':', ',')
@@ -336,6 +337,11 @@ if __name__ == '__main__':
         new_version = version_substitution(logger, pattern, curr_commit)
         reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist)
         apt_target = "repo01-debian-dev"
+        additional_repos = [
+            "deb http://repo.pb.local/pb-debian-dev {dist} main non-free contrib".format(
+                dist=new_dist
+            )
+        ]
         # reset actions
         # .. always include successful build packages into CIDB
         if curr_dist == 'squeeze':
@@ -361,6 +367,21 @@ if __name__ == '__main__':
         new_version = version_substitution(logger, pattern, curr_commit)
         reprepro_base = '/srv/dev-{dist}'.format(dist=curr_dist)
         apt_target = "repo01-debian-dev"
+        additional_repos = [
+            "deb http://repo.pb.local/pb-debian-dev {dist} main non-free contrib".format(
+                dist=curr_dist+'-dev'
+            ),
+        ]
+        release_file = "http://repo.pb.local/pb-debian-dev/dists/" + new_dist + "/Release"
+        check_cmd = ['wget', '-q', '--spider', release_file]
+        if subprocess.call(check_cmd) == 0:
+            logger.info('Distribution {dist} found in http://repo.pb.local/pb-debian-dev'
+                        .format(dist=new_dist))
+            additional_repos.append("deb http://repo.pb.local/pb-debian-dev "
+                                    "{dist} main non-free contrib".format(dist=new_dist))
+        else:
+            logger.info('Distribution {dist} not found in http://repo.pb.local/pb-debian-dev'
+                        .format(dist=new_dist))
 
     else:
         logger.error('Don\'t know how to handle branch "{branch}".'.format(
@@ -601,7 +622,8 @@ if __name__ == '__main__':
         dsc_file=source_builder.dsc_file,
         dist=new_dist,
         chroot='pb-'+curr_dist,
-        arch='amd64'
+        arch='amd64',
+        additional_repos=additional_repos,
     )
     if ret == 0:
         logger.info('Current environment:\n\n{env}\n'.format(env=builder.env))
@@ -634,7 +656,7 @@ export {builder_env} FORCE_SHELL=TRUE
 ###
 '''.format(hostname=socket.gethostname(),
            jenkins_user=ENV['USER'],
-           jenkins_workspace=ENV['WORKSPACE'],
+           jenkins_workspace=builder.dsc_dir,
            builder_env=' '.join(['{k}="{v}"'.format(k=key, v=builder.env[key],)
                                  for key in builder.env.keys()]),
            command=' '.join(builder.command),
index 60de654ca973b2122ea5cbe21182aec441bbbaf7..4a2674b13527820685a3a03691dffe998e063106 100644 (file)
@@ -11,7 +11,7 @@ SBUILD = 'sbuild'
 
 
 class Sbuild(object):
-    def __init__(self, dsc_file=None, dist=None, chroot=None, arch=None):
+    def __init__(self, dsc_file=None, dist=None, chroot=None, arch=None, additional_repos=None):
         '''
         TODO
         '''
@@ -20,6 +20,7 @@ class Sbuild(object):
         self.arch = arch
         self.chroot = chroot
         self.dist = dist
+        self.additional_repos = additional_repos
 
     @property
     def env(self):
@@ -39,9 +40,9 @@ class Sbuild(object):
             '-n',
             '--arch=' + self.arch,
             '-d', self.dist,
-            '-c', self.chroot,
-            self.dsc_file,
-        ]
+            '-c', self.chroot
+        ] + ['--extra-repository="' + repo + '"' for repo in self.additional_repos] + \
+            [self.dsc_file]
         return result
 
     @property