]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: Add support for rebuilds via REBUILD_DIST.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 26 Aug 2014 09:19:38 +0000 (11:19 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 26 Aug 2014 09:19:38 +0000 (11:19 +0200)
debian_build.py

index 7e26cdd25cc4317bc1ad1b071552a6bbb6f2d8fb..f1828e59ea92986f4fa4c7a9c9dbb8e3566f1f39 100755 (executable)
@@ -35,6 +35,7 @@ logger = logger_init(re.match('^(.*/jenkins_build_script/)(.*)', __file__).group
 ENV.setdefault('NO_UPLOAD', '')
 ENV.setdefault('BUILD_TRIGGERS', '')
 ENV.setdefault('VERSION_SUFFIX', '')
+ENV.setdefault('REBUILD_DIST', '')
 ENV.setdefault('GIT_BRANCH_NAME', ENV['GIT_BRANCH'])
 if ENV['GIT_BRANCH'] != ENV['GIT_BRANCH_NAME']:
     ENV['GIT_BRANCH'] = ENV['GIT_BRANCH_NAME']
@@ -44,6 +45,14 @@ if ENV['GIT_BRANCH'] != ENV['GIT_BRANCH_NAME']:
 # local constants
 BUILD_START = datetime.datetime.now()
 
+SUPPORTED_DISTRIBUTIONS = ('squeeze', 'wheezy', 'jessie')
+
+DISTRO_SUFFIX = {
+    'squeeze': '~deb6',
+    'wheezy': '~deb7',
+    'jessie': '~deb8',
+}
+
 AUTO_CHANGELOG_REPONAMES = (
     'so-docs',
     'infrastructure-docs',
@@ -271,8 +280,21 @@ if __name__ == '__main__':
                 break
 
     # Act II: make decissions
+    # change the distribution if REBUILD_DIST is set in the environment
+    rebuild_suffix = ''
+    if ENV['REBUILD_DIST'] in SUPPORTED_DISTRIBUTIONS:
+        logger.info('REBUILD_DIST is set. Change distribution {old} => {new}.'
+                    .format(old=curr_dist, new=ENV['REBUILD_DIST']))
+        curr_dist = ENV['REBUILD_DIST']
+        rebuild_suffix = DISTRO_SUFFIX[ENV['REBUILD_DIST']]
+    elif ENV['REBUILD_DIST']:
+        logger.warn('REBUILD_DIST {dist} not supported. Please select from: {supported}'.format(
+            dist=ENV['REBUILD_DIST'],
+            supported=", ".join(SUPPORTED_DISTRIBUTIONS)
+        ))
+
     # compatibility until call_jenkins was replaced
-    if curr_dist not in ('squeeze', 'wheezy', 'jessie'):
+    if curr_dist not in SUPPORTED_DISTRIBUTIONS:
         logger.warn('Compatibility Mode: Change distribution {old} => {new}.'.format(
             old=curr_dist,
             new='squeeze'
@@ -287,7 +309,7 @@ if __name__ == '__main__':
             exit_error()
         new_dist = curr_dist
         alexandria_dist = 'stable'
-        new_version = curr_version + options.version_suffix
+        new_version = curr_version + options.version_suffix + rebuild_suffix
         reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist)
         apt_target = "repo01-debian"
         additional_repos = []