diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-11-27 23:44:51 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-11-28 22:29:48 +0100 |
commit | 7e6b0c86eff63077ead4c6658dfc90d2b9249249 (patch) | |
tree | 1b076ee6a8aae01bfda6151a3ed9966cf0da48af /gbp/scripts/buildpackage.py | |
parent | c9a1595a666cc83f9e9e523f0b4f27502f61b998 (diff) |
buildpackage.py: move changelog fetching into function
Diffstat (limited to 'gbp/scripts/buildpackage.py')
-rw-r--r-- | gbp/scripts/buildpackage.py | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 91347fe2..06285684 100644 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -270,6 +270,20 @@ def extract_orig(orig_tarball, dest_dir): os.rmdir(upstream.unpacked) #} +def fetch_changelog(options): + """Fetch the correct changelog based on the options given""" + try: + # FIXME: fetch correct changelog here in case of export-dir + cp = ChangeLog(filename=changelog) + except NoChangeLogError: + raise GbpError, "'%s' does not exist, not a debian package" % changelog + except ParseChangeLogError, err: + raise GbpError, "Error parsing Changelog: %s" % err + except KeyError: + raise GbpError, "Can't parse version from changelog" + return cp + + def prepare_output_dir(dir): """Prepare the directory where the build result will be put""" output_dir = dir @@ -504,19 +518,7 @@ def main(argv): gbp.log.err("You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)) raise GbpError, "Use --git-ignore-branch to ignore or --git-debian-branch to set the branch name." - try: - cp = ChangeLog(filename=changelog) - if cp.is_native(): - major = cp['Debian-Version'] - else: - major = cp['Upstream-Version'] - except NoChangeLogError: - raise GbpError, "'%s' does not exist, not a debian package" % changelog - except ParseChangeLogError, err: - raise GbpError, "Error parsing Changelog: %s" % err - except KeyError: - raise GbpError, "Can't parse version from changelog" - + cp = fetch_changelog(options) if not options.tag_only: output_dir = prepare_output_dir(options.export_dir) tarball_dir = options.tarball_dir or output_dir @@ -545,6 +547,7 @@ def main(argv): 'GBP_TMP_DIR': tmp_dir})(dir=tmp_dir) cp = ChangeLog(filename=os.path.join(tmp_dir, 'debian', 'changelog')) + major = (cp.debian_version if cp.is_native() else cp.upstream_version) export_dir = os.path.join(output_dir, "%s-%s" % (cp['Source'], major)) gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir)) move_old_export(export_dir) |