From: Benjamin Drung Date: Tue, 26 Aug 2014 10:00:18 +0000 (+0200) Subject: debian_build.py: Fix import re-definitions. X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=697f591b90c2844bc546ada3e7309aa6c266947e;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: Fix import re-definitions. --- diff --git a/debian_build.py b/debian_build.py index fc13a0c..6e5ebfb 100755 --- a/debian_build.py +++ b/debian_build.py @@ -9,14 +9,13 @@ import git import optparse import os import re -import socket import subprocess import sys from pprint import pformat # import 3rd parties +import debian.changelog import debian.debian_support -from debian import changelog # import local modules from add_liveboot_request import add_liveboot_request @@ -232,12 +231,12 @@ def main(): # this should be part of 'git' lib, but it isn't right now gitrepo.remotes = {} for remote in gitrepo.git.remote('-v').split('\n'): - name, url, type = remote.split() - type = type.strip('()') + name, url, git_type = remote.split() + git_type = git_type.strip('()') if name not in gitrepo.remotes: - gitrepo.remotes.update({name: {type: url}}) + gitrepo.remotes.update({name: {git_type: url}}) else: - gitrepo.remotes[name].update({type: url}) + gitrepo.remotes[name].update({git_type: url}) # this would also be helpful, but is not yet included in git lib repo_name = gitrepo.remotes['origin']['fetch'].split('/')[-1].strip('.git') else: @@ -263,16 +262,16 @@ def main(): exit_error() # .. content related - cl = changelog.Changelog() - cl.parse_changelog(open('debian/changelog')) - curr_name = cl.package - curr_version = cl.full_version - curr_dist = cl.distributions + changelog = debian.changelog.Changelog() + changelog.parse_changelog(open('debian/changelog')) + curr_name = changelog.package + curr_version = changelog.full_version + curr_dist = changelog.distributions if curr_version == "UNRELEASED": # Search for the last release (where distribution is not UNRELEASED) - for block in cl: - curr_version = cl.distributions + for block in changelog: + curr_version = changelog.distributions if curr_version != "UNRELEASED": break @@ -357,7 +356,7 @@ def main(): exit_error() alexandria_dist = 'unstable' new_dist = curr_dist + '-dev' - if cl.distributions == "UNRELEASED": + if changelog.distributions == "UNRELEASED": pattern = "{debversion}~develop{time:%Y%m%d+%H%M}+{build}+{git-commit}" else: pattern = "{debversion}+develop{time:%Y%m%d+%H%M}+{build}+{git-commit}" @@ -387,7 +386,7 @@ def main(): alexandria_dist = "wheezy-dev-{0}".format(local_branch.replace("/", "-")) else: alexandria_dist = 'dev-{0}'.format(local_branch.replace("/", "-")) - if cl.distributions == "UNRELEASED": + if changelog.distributions == "UNRELEASED": pattern = "{debversion}~experimental{time:%Y%m%d+%H%M}+{build}+{git-commit}" else: pattern = "{debversion}+experimental{time:%Y%m%d+%H%M}+{build}+{git-commit}" @@ -503,7 +502,7 @@ def main(): # .. and also cleanup existing *orig.tar.gz if os.path.isdir(BUILD_AREA): files = [ - os.path.join(BUILD_AREA, file) for file in fnmatch.filter( + os.path.join(BUILD_AREA, source_file) for source_file in fnmatch.filter( os.listdir(BUILD_AREA), '*.orig.tar.gz' ) ] @@ -573,9 +572,9 @@ def main(): logger.debug(gitrepo.git.push('origin', 'master')) logger.info('Changelog autoincremented and pushed back by Jenkins!') - cl = changelog.Changelog() - cl.parse_changelog(open('debian/changelog')) - new_version = cl.full_version + changelog = debian.changelog.Changelog() + changelog.parse_changelog(open('debian/changelog')) + new_version = changelog.full_version new_tag = new_version.replace('~', '_').replace(':', ',') except Exception as error: logger.error('Autoincrement failed. Standard error returned:\n\n%s\n' % @@ -585,9 +584,10 @@ def main(): # .. or set approriate versions for our development candidates else: logger.info('Project is not respected by autoincrement.') - cl = changelog.Changelog() - cl.parse_changelog(open('debian/changelog')) - add_changelog_entry = new_dist != cl.distributions or new_version != cl.full_version + changelog = debian.changelog.Changelog() + changelog.parse_changelog(open('debian/changelog')) + add_changelog_entry = (new_dist != changelog.distributions or + new_version != changelog.full_version) if add_changelog_entry: cmd = [ BIN_DCH, @@ -634,20 +634,22 @@ def main(): logger.info('Changelog updated by Jenkins using debian_build.py!') # let me see the first two entries or our adjusted changelog: - cl = changelog.Changelog() - cl.parse_changelog(open('debian/changelog')) + changelog = debian.changelog.Changelog() + changelog.parse_changelog(open('debian/changelog')) logger.info('New changelog:') count = 2 - changelog = "" - for block in cl: - changelog += str(block) + changelog_part = "" + for block in changelog: + changelog_part += str(block) count -= 1 if count == 0: break - for line in changelog.rstrip().split('\n'): + for line in changelog_part.rstrip().split('\n'): logger.info(' ' + line) - logger.info("Distribution is {dist} and version is {version}".format(dist=cl.distributions, - version=cl.version)) + logger.info("Distribution is {dist} and version is {version}".format( + dist=changelog.distributions, + version=changelog.version + )) # # ACT IV: preparations are done, let's build the source