]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
support building for staging too
authorHolger Levsen <holger@layer-acht.org>
Sat, 17 Sep 2011 15:41:57 +0000 (17:41 +0200)
committerHolger Levsen <holger@layer-acht.org>
Sat, 17 Sep 2011 15:41:57 +0000 (17:41 +0200)
debian_build.py

index f493eedb9e3e82bd71df6088e5545f672d6a1f35..ba2eebfb9b6173fb552d48d4a4cf2940a54714e8 100755 (executable)
@@ -379,9 +379,7 @@ if __name__ == '__main__':
         cmd = ['/usr/bin/git', 'commit', '-a', '-m', 'add changelog']
         subprocess.check_call(cmd)
     else:
-       # so we're in the master branch...
-       # (or maybe in other branches, but thats not specified _yet_)
-       # TODO errorchecking etc
+       # so we're in the master or release branches
         cmd = ['dpkg-parsechangelog']
        parse_changelog =  subprocess.Popen(
                 cmd,
@@ -398,12 +396,41 @@ if __name__ == '__main__':
             )
            exit_error()
 
-       cmd = ['grep-dctrl', '-n', '-s', 'Version', '']
+        changelog = parse_changelog.stdout
+
+       cmd = ['grep-dctrl', '-n', '-s', 'Distribution', '']
+       grep_dctrl =  subprocess.Popen(
+                cmd,
+                shell=False,
+                close_fds=True,
+               stdin=changelog,
+                stdout=subprocess.PIPE,
+                stderr=sys.stderr,
+                cwd=os.getcwd()
+        )
+       ret = grep_dctrl.wait()
+        if ret:
+            raise Exception(
+                    '%s was not successfull, return code was %s ' % (' '.join(cmd), ret)
+            )
+           exit_error()
+
+        distribution = grep_dctrl.stdout.readline()
+       distribution = distribution.strip()
+       logger.info('Packet distribution is %s' % (distribution))
+        if (options.distribution in ('testing', 'staging') and not distribution in ('testing', 'staging')) or (options.distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates') and distribution in ('stable', 'stable-proposed-updates', 'production', 'production-proposed-updates')):
+            raise Exception(
+                    'Distribution %s in debian/changelog did not match branch %s' % (distribution, GIT_UPSTREAM_BRANCH)
+            )
+           exit_error()
+
+        # FIXME this is code duplication, we should only rungrep-dctrl once here... (see above)
+        cmd = ['grep-dctrl', '-n', '-s', 'Version', '']
        grep_dctrl =  subprocess.Popen(
                 cmd,
                 shell=False,
                 close_fds=True,
-               stdin=parse_changelog.stdout,
+               stdin=changelog,
                 stdout=subprocess.PIPE,
                 stderr=sys.stderr,
                 cwd=os.getcwd()