diff options
author | Jun Wang <junbill.wang@samsung.com> | 2016-01-26 21:55:12 +0800 |
---|---|---|
committer | Jun Wang <junbill.wang@samsung.com> | 2016-01-26 21:55:12 +0800 |
commit | a9e607b87666d237108f7e1040e4fe2712cd4e95 (patch) | |
tree | bde2346bc9f668db0c7ac5b81a8e2d9b43a56fa7 | |
parent | dcbb169efc46c3a79e60ca16c90f8dcd04ae0bad (diff) | |
parent | dbfc6276c4aa50b79f1cf27cfc24badc0b18da8f (diff) | |
download | git-buildpackage-a9e607b87666d237108f7e1040e4fe2712cd4e95.tar.gz git-buildpackage-a9e607b87666d237108f7e1040e4fe2712cd4e95.tar.bz2 git-buildpackage-a9e607b87666d237108f7e1040e4fe2712cd4e95.zip |
Merge from devel dbfc6276c4aa50b79f1cf27cfc24badc0b18da8f
-rwxr-xr-x | gbp/scripts/buildpackage.py | 3 | ||||
-rw-r--r-- | gbp/scripts/common/import_orig.py | 22 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 58 |
3 files changed, 78 insertions, 5 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 95ecefe0..da53fe92 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -38,8 +38,7 @@ from gbp.scripts.common.buildpackage import (index_name, wc_names, git_archive_submodules, git_archive_single, dump_tree, write_wc, drop_index) -from gbp.pkg import (UpstreamSource, compressor_opts, compressor_aliases, - parse_archive_filename) +from gbp.pkg import compressor_opts, compressor_aliases, parse_archive_filename def git_archive(repo, cp, output_dir, tmpdir_base, treeish, comp_type, comp_level, with_submodules): diff --git a/gbp/scripts/common/import_orig.py b/gbp/scripts/common/import_orig.py index adbfff5e..3d01f9e9 100644 --- a/gbp/scripts/common/import_orig.py +++ b/gbp/scripts/common/import_orig.py @@ -33,6 +33,28 @@ except ImportError: pass +def orig_needs_repack(upstream_source, options): + """ + Determine if the upstream sources needs to be repacked + + We repack if + 1. we want to filter out files and use pristine tar since we want + to make a filtered tarball available to pristine-tar + 2. when we don't have a suitable upstream tarball (e.g. zip archive or unpacked dir) + and want to use filters + 3. when we don't have a suitable upstream tarball (e.g. zip archive or unpacked dir) + and want to use pristine-tar + """ + if ((options.pristine_tar and options.filter_pristine_tar and len(options.filters) > 0)): + return True + elif not upstream_source.is_orig(): + if len(options.filters): + return True + elif options.pristine_tar: + return True + return False + + def cleanup_tmp_tree(tree): """remove a tree of temporary files""" try: diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 78bbf476..fb6070e9 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -31,9 +31,49 @@ from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch from gbp.errors import GbpError import gbp.log from gbp.pkg import compressor_opts -from gbp.scripts.common.import_orig import (cleanup_tmp_tree, ask_package_name, - ask_package_version, - prepare_sources) +from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree, + ask_package_name, ask_package_version, + repack_source, is_link_target) + + +def prepare_pristine_tar(archive, pkg, version): + """ + Prepare the upstream source for pristine tar import. + + This checks if the upstream source is actually a tarball + and creates a symlink from I{archive} + to I{<pkg>_<version>.orig.tar.<ext>} so pristine-tar will + see the correct basename. + + @param archive: the upstream source's name + @type archive: C{str} + @param pkg: the source package's name + @type pkg: C{str} + @param version: the upstream version number + @type version: C{str} + @rtype: C{str} + """ + linked = False + if os.path.isdir(archive): + return None + + ext = os.path.splitext(archive)[1] + if ext in ['.tgz', '.tbz2', '.tlz', '.txz' ]: + ext = ".%s" % ext[2:] + + link = "../%s_%s.orig.tar%s" % (pkg, version, ext) + + if os.path.basename(archive) != os.path.basename(link): + try: + if not is_link_target(archive, link): + os.symlink(os.path.abspath(archive), link) + linked = True + except OSError as err: + raise GbpError("Cannot symlink '%s' to '%s': %s" % (archive, link, err[1])) + return (link, linked) + else: + return (archive, linked) +>>>>>>> dbfc6276c4aa50b79f1cf27cfc24badc0b18da8f def upstream_import_commit_msg(options, version): @@ -269,6 +309,18 @@ def main(argv): unpacked_orig, pristine_orig = prepare_sources( source, pkg_name, version, prepare_pristine, options.filters, options.filter_pristine_tar, None, tmpdir) + if not source.is_dir(): + tmpdir = tempfile.mkdtemp(dir='../') + source.unpack(tmpdir, options.filters) + gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked)) + + if orig_needs_repack(source, options): + gbp.log.debug("Filter pristine-tar: repacking '%s' from '%s'" % (source.path, source.unpacked)) + (source, tmpdir) = repack_source(source, sourcepackage, version, tmpdir, options.filters) + + (pristine_orig, linked) = prepare_pristine_tar(source.path, + sourcepackage, + version) # Don't mess up our repo with git metadata from an upstream tarball try: |