Package: git-buildpackage
Version: 0.4.63
Tags: patch
git-buildpackage fails when --git-export specifies a version whose
upstream version is not the same as HEAD's upstream version. Transcript:
# head -1 debian/changelog
python-pysqlite2 (2.5.5-3) unstable; urgency=low
# git-buildpackage --git-pristine-tar --git-export-dir=../build
--git-export=debian/2.4.1-1
dh_testdir
dh_testroot
rm -f build*stamp dbg-build*stamp
rm -rf build
find . -name '*.pyc' | xargs rm -f
dh_clean
pristine-tar: successfully generated
/root/git/build/python-pysqlite2_2.5.5.orig.tar.gz
Exporting 'debian/2.4.1-1' to '/root/git/build/python-pysqlite2-tmp'
This package has a Debian revision number but there does not seem to be
an appropriate original tar file or .orig directory in the parent directory;
(expected one of python-pysqlite2_2.4.1.orig.tar.gz,
python-pysqlite2_2.4.1.orig.tar.bz2,
python-pysqlite2_2.4.1.orig.tar.lzma or python-pysqlite2-2.5.5.orig)
continue anyway? (y/n)
As can be seen above, git-buildpackage creates the original tar file
from HEAD's upstream version, which of course leads to failure.
Attached is a patch that fixes the problem for me. It's not heavily
tested, but works for me and my use cases. I have not tried the overlay
feature or other exotic option combinations.
Regards,
Joel
--- /usr/bin/git-buildpackage.orig 2010-01-11 22:26:54.000000000 +0100
+++ /usr/bin/git-buildpackage 2010-01-11 23:00:03.000000000 +0100
@@ -278,21 +278,6 @@
print >>sys.stderr, "You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)
raise GbpError, "Use --git-ignore-new to ignore or --git-debian-branch to set the branch name."
- try:
- cp = du.parse_changelog(changelog)
- version = cp['Version']
- version_no_epoch = cp['NoEpoch-Version']
- if du.is_native(cp):
- major = cp['Debian-Version']
- else:
- major = cp['Upstream-Version']
- except du.NoChangelogError:
- raise GbpError, "'%s' does not exist, not a debian package" % changelog
- except du.ParseChangeLogError, err:
- raise GbpError, "Error parsing Changelog: %s" % err
- except KeyError:
- raise GbpError, "Can't parse version from changelog"
-
if not options.tag_only:
output_dir = prepare_output_dir(options.export_dir)
if options.tarball_dir:
@@ -300,21 +285,13 @@
else:
tarball_dir = output_dir
- # Get/build the orig.tar.gz if necessary:
- if not du.is_native(cp):
- orig_file = du.orig_file(cp, options.comp_type)
-
- # look in tarball_dir first, if found force a symlink to it
- if options.tarball_dir:
- print "Looking for orig tarball '%s' at '%s'" % (orig_file, tarball_dir)
- if not du.symlink_orig(cp, options.comp_type, tarball_dir, output_dir, force=True):
- print "Orig tarball '%s' not found at '%s'" % (orig_file, tarball_dir)
- else:
- print "Orig tarball '%s' found at '%s'" % (orig_file, tarball_dir)
- # build an orig unless the user forbidds it
- if not options.no_create_orig and not du.has_orig(cp, options.comp_type, output_dir):
- if not pristine_tar_build_orig(repo, cp, output_dir, options):
- git_archive_build_orig(repo, cp, output_dir, options)
+ # Parse changelog just to get source package name.
+ try:
+ cp = du.parse_changelog(changelog)
+ except du.NoChangelogError:
+ raise GbpError, "'%s' does not exist, not a debian package" % changelog
+ except du.ParseChangeLogError, err:
+ raise GbpError, "Error parsing Changelog: %s" % err
# Export to another build dir if requested:
if options.export_dir:
@@ -337,16 +314,49 @@
print "Exporting '%s' to '%s'" % (options.export, tmp_dir)
dump_tree(tmp_dir, tree)
- cp = du.parse_changelog(os.path.join(tmp_dir, 'debian', 'changelog'))
+ changelog = os.path.join(tmp_dir, changelog)
+
+ # Now parse the correct changelog to get hold of the version.
+ try:
+ cp = du.parse_changelog(changelog)
+ version = cp['Version']
+ version_no_epoch = cp['NoEpoch-Version']
+ except du.NoChangelogError:
+ raise GbpError, "'%s' does not exist, not a debian package" % changelog
+ except du.ParseChangeLogError, err:
+ raise GbpError, "Error parsing Changelog: %s" % err
+ except KeyError:
+ raise GbpError, "Can't parse version from changelog"
+
+ # Continue exporting if requested.
+ if options.export_dir:
+ if du.is_native(cp):
+ major = cp['Debian-Version']
+ else:
+ major = cp['Upstream-Version']
export_dir = os.path.join(output_dir, "%s-%s" % (cp['Source'], major))
move_old_export(export_dir)
os.rename(tmp_dir, export_dir)
-
- if options.export_dir:
build_dir = export_dir
else:
build_dir = repo_dir
+ # Get/build the orig.tar.gz if necessary:
+ if not du.is_native(cp):
+ orig_file = du.orig_file(cp, options.comp_type)
+
+ # look in tarball_dir first, if found force a symlink to it
+ if options.tarball_dir:
+ print "Looking for orig tarball '%s' at '%s'" % (orig_file, tarball_dir)
+ if not du.symlink_orig(cp, options.comp_type, tarball_dir, output_dir, force=True):
+ print "Orig tarball '%s' not found at '%s'" % (orig_file, tarball_dir)
+ else:
+ print "Orig tarball '%s' found at '%s'" % (orig_file, tarball_dir)
+ # build an orig unless the user forbidds it
+ if not options.no_create_orig and not du.has_orig(cp, options.comp_type, output_dir):
+ if not pristine_tar_build_orig(repo, cp, output_dir, options):
+ git_archive_build_orig(repo, cp, output_dir, options)
+
# Finally build the package:
RunAtCommand(options.builder, dpkg_args, shell=True,
extra_env={'GBP_BUILD_DIR': build_dir})(dir=build_dir)