diff options
-rw-r--r-- | bin/git-pbuilder | 3 | ||||
-rw-r--r-- | gbp/pkg/__init__.py | 61 | ||||
-rw-r--r-- | gbp/scripts/common/import_orig.py | 124 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 27 | ||||
-rwxr-xr-x | gbp/scripts/pq_rpm.py | 4 | ||||
-rw-r--r-- | packaging/git-buildpackage.spec | 1 |
6 files changed, 16 insertions, 204 deletions
diff --git a/bin/git-pbuilder b/bin/git-pbuilder index a9104d7a..a003b266 100644 --- a/bin/git-pbuilder +++ b/bin/git-pbuilder @@ -228,8 +228,7 @@ update|create|login) sudo "$BUILDER" --"$action" --distribution "$DIST" \ --othermirror "$OTHERMIRROR" "${OPTIONS[@]}" "$@" else - sudo "$BUILDER" --"$action" --distribution "$DIST" \ - "${OPTIONS[@]}" "$@" + sudo "$BUILDER" --"$action" --distribution "$DIST" "${OPTIONS[@]}" "$@" fi fi exit $? diff --git a/gbp/pkg/__init__.py b/gbp/pkg/__init__.py index 79067982..941b0f63 100644 --- a/gbp/pkg/__init__.py +++ b/gbp/pkg/__init__.py @@ -142,67 +142,6 @@ class PkgPolicy(object): return True return False - @classmethod - def guess_upstream_src_version(cls, filename, extra_regex=r''): - """ - Guess the package name and version from the filename of an upstream - archive. - - @param filename: filename (archive or directory) from which to guess - @type filename: C{string} - @param extra_regex: additional regex to apply, needs a 'package' and a - 'version' group - @return: (package name, version) or ('', '') - @rtype: tuple - - >>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.orig.tar.gz') - ('foo-bar', '0.2') - >>> PkgPolicy.guess_upstream_src_version('foo-Bar_0.2.orig.tar.gz') - ('foo-Bar', '0.2.orig') - >>> PkgPolicy.guess_upstream_src_version('git-bar-0.2.tar.gz') - ('git-bar', '0.2') - >>> PkgPolicy.guess_upstream_src_version('git-bar-0.2-rc1.tar.gz') - ('git-bar', '0.2-rc1') - >>> PkgPolicy.guess_upstream_src_version('git-bar-0.2:~-rc1.tar.gz') - ('git-bar', '0.2:~-rc1') - >>> PkgPolicy.guess_upstream_src_version('git-Bar-0A2d:rc1.tar.bz2') - ('git-Bar', '0A2d:rc1') - >>> PkgPolicy.guess_upstream_src_version('git-1.tar.bz2') - ('git', '1') - >>> PkgPolicy.guess_upstream_src_version('kvm_87+dfsg.orig.tar.gz') - ('kvm', '87+dfsg') - >>> PkgPolicy.guess_upstream_src_version('foo-Bar-a.b.tar.gz') - ('', '') - >>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.orig.tar.xz') - ('foo-bar', '0.2') - >>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.tar.gz') - ('foo-bar', '0.2') - >>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.orig.tar.lzma') - ('foo-bar', '0.2') - >>> PkgPolicy.guess_upstream_src_version('foo-bar-0.2.zip') - ('foo-bar', '0.2') - >>> PkgPolicy.guess_upstream_src_version('foo-bar-0.2.tlz') - ('foo-bar', '0.2') - """ - version_chars = r'[a-zA-Z\d\.\~\-\:\+]' - basename = parse_archive_filename(os.path.basename(filename))[0] - - version_filters = map ( lambda x: x % version_chars, - ( # Debian upstream tarball: package_'<version>.orig.tar.gz' - r'^(?P<package>[a-z\d\.\+\-]+)_(?P<version>%s+)\.orig', - # Upstream 'package-<version>.tar.gz' - # or Debian native 'package_<version>.tar.gz' - # or directory 'package-<version>': - r'^(?P<package>[a-zA-Z\d\.\+\-]+)(-|_)(?P<version>[0-9]%s*)')) - if extra_regex: - version_filters = extra_regex + version_filters - - for filter in version_filters: - m = re.match(filter, basename) - if m: - return (m.group('package'), m.group('version')) - return ('', '') - @staticmethod def guess_upstream_src_version(filename, extra_regex=r''): """ diff --git a/gbp/scripts/common/import_orig.py b/gbp/scripts/common/import_orig.py index 304dfd77..45e71c57 100644 --- a/gbp/scripts/common/import_orig.py +++ b/gbp/scripts/common/import_orig.py @@ -78,59 +78,6 @@ def ask_package_version(default, ver_validator_func, err_msg): # bit clearer. gbp.log.warn("\nNot a valid upstream version: '%s'.\n%s" % (version, err_msg)) - -def prepare_pristine_tar(source, pkg_name, pkg_version, pristine_commit_name, - filters=None, prefix=None, tmpdir=None): - """ - Prepare the upstream sources for pristine-tar import - - @param source: original upstream sources - @type source: C{UpstreamSource} - @param pkg_name: package name - @type pkg_name: C{str} - @param pkg_version: upstream version of the package - @type pkg_version: C{str} - @param pristine_commit_name: archive filename to commit to pristine-tar - @type pristine_commit_name: C{str} or C{None} - @param filters: filter to exclude files - @type filters: C{list} of C{str} or C{None} - @param prefix: prefix (i.e. leading directory of files) to use in - pristine-tar, set to C{None} to not mangle orig archive - @type prefix: C{str} or C{None} - @param tmpdir: temporary working dir (cleanup left to caller) - @type tmpdir: C{str} - @return: prepared source archive - @rtype: C{UpstreamSource} - """ - need_repack = False - if source.is_dir(): - if prefix is None: - prefix = '%s-%s' % (pkg_name, pkg_version) - gbp.log.info("Using guessed prefix '%s/' for pristine-tar" % prefix) - need_repack = True - else: - if prefix is not None and prefix == source.prefix: - prefix = None - comp = parse_archive_filename(pristine_commit_name)[2] - if filters or prefix is not None or source.compression != comp: - if not source.unpacked: - unpack_dir = tempfile.mkdtemp(prefix='pristine_unpack_', - dir=tmpdir) - source.unpack(unpack_dir) - need_repack = True - pristine_path = os.path.join(tmpdir, pristine_commit_name) - if need_repack: - gbp.log.debug("Packing '%s' from '%s' for pristine-tar" % - (pristine_path, source.unpacked)) - pristine = source.pack(pristine_path, filters, prefix) - else: - # Just create symlink for mangling the pristine tarball name - os.symlink(source.path, pristine_path) - pristine = source.__class__(pristine_path) - - return pristine - - def prepare_sources(source, pkg_name, pkg_version, pristine_commit_name, filters, filter_pristine, prefix, tmpdir): """ @@ -200,6 +147,7 @@ def prepare_sources(source, pkg_name, pkg_version, pristine_commit_name, tmpdir) pristine_path = pristine.path if pristine else '' return (filtered.unpacked, pristine_path) + def repack_source(source, new_name, unpack_dir, filters, new_prefix=None): """Repack the source tree""" repacked = source.pack(new_name, filters, new_prefix) @@ -262,73 +210,3 @@ def prepare_pristine_tar(source, pkg_name, pkg_version, pristine_commit_name, return pristine -def prepare_sources(source, pkg_name, pkg_version, pristine_commit_name, - filters, filter_pristine, prefix, tmpdir): - """ - Prepare upstream sources for importing - - Unpack, filter and repack sources for importing to git and to pristine-tar. - - @param source: original upstream sources - @type source: C{UpstreamSource} - @param pkg_name: package name - @type pkg_name: C{str} - @param pkg_version: upstream version of the package - @type pkg_version: C{str} - @param pristine_commit_name: archive filename to commit to pristine-tar - @type pristine_commit_name: C{str} or C{None} - @param filters: filter to exclude files - @type filters: C{list} of C{str} - @param filter_pristine: filter pristine-tar, too - @type filter_pristine: C{bool} - @param prefix: prefix (i.e. leading directory of files) to use in - pristine-tar, set to C{None} to not mangle orig archive - @type prefix: C{str} or C{None} - @param tmpdir: temporary working dir (cleanup left to caller) - @type tmpdir: C{str} - @return: path to prepared source tree and tarball to commit to pristine-tar - @rtype: C{tuple} of C{str} - """ - pristine = None - # Determine parameters for pristine tar - pristine_filters = filters if filters and filter_pristine else None - pristine_prefix = None - if prefix is not None and prefix != 'auto': - prefix_subst = {'name': pkg_name, - 'version': pkg_version, - 'upstreamversion': pkg_version} - pristine_prefix = prefix % prefix_subst - # Handle unpacked sources, i.e. importing a directory - if source.is_dir(): - if pristine_commit_name: - gbp.log.warn('Preparing unpacked sources for pristine-tar') - pristine = prepare_pristine_tar(source, pkg_name, pkg_version, - pristine_commit_name, - pristine_filters, pristine_prefix, - tmpdir) - if filters: - # Re-use sources packed for pristine-tar, if available - if pristine: - packed = pristine - else: - packed_fn = tempfile.mkstemp(prefix="packed_", dir=tmpdir, - suffix='.tar')[1] - gbp.log.debug("Packing '%s' to '%s'" % (source.path, packed_fn)) - packed = source.pack(packed_fn) - unpack_dir = tempfile.mkdtemp(prefix='filtered_', dir=tmpdir) - filtered = packed.unpack(unpack_dir, filters) - else: - filtered = source - # Handle source archives - else: - unpack_dir = tempfile.mkdtemp(prefix='filtered_', dir=tmpdir) - gbp.log.debug("Unpacking '%s' to '%s'" % (source.path, unpack_dir)) - filtered = source.unpack(unpack_dir, filters) - if pristine_commit_name: - pristine = prepare_pristine_tar(source, pkg_name, pkg_version, - pristine_commit_name, - pristine_filters, pristine_prefix, - tmpdir) - pristine_path = pristine.path if pristine else '' - return (filtered.unpacked, pristine_path) - diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 6ec50021..65ff7c4a 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -32,10 +32,9 @@ from gbp.errors import GbpError from gbp.format import format_msg import gbp.log from gbp.pkg import compressor_opts -from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree, - ask_package_name, ask_package_version, - repack_source, is_link_target) - +from gbp.scripts.common.import_orig import (cleanup_tmp_tree, ask_package_name, + sk_package_version, + prepare_sources) def prepare_pristine_tar(archive, pkg, version): """ @@ -309,21 +308,13 @@ 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(): - unpack_dir = tempfile.mkdtemp(prefix='unpack', dir=tmpdir) - source = source.unpack(unpack_dir, 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)) - repack_dir = tempfile.mkdtemp(prefix='repack', dir=tmpdir) - repack_name = repacked_tarball_name(source, sourcepackage, version) - source = repack_source(source, repack_name, repack_dir, options.filters) - - (pristine_orig, linked) = prepare_pristine_tar(source.path, - sourcepackage, - version) + # Prepare sources for importing + pristine_name = pristine_tarball_name(source, pkg_name, version) + prepare_pristine = pristine_name if options.pristine_tar else None + unpacked_orig, pristine_orig = prepare_sources( + source, pkg_name, version, prepare_pristine, options.filters, + options.filter_pristine_tar, None, tmpdir) # Don't mess up our repo with git metadata from an upstream tarball try: if os.path.isdir(os.path.join(unpacked_orig, '.git/')): diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py index c33e67b2..a329edd5 100755 --- a/gbp/scripts/pq_rpm.py +++ b/gbp/scripts/pq_rpm.py @@ -643,6 +643,10 @@ def main(argv): try: parser = GbpOptionParserRpm(command=os.path.basename(argv[0]), prefix='', usage=USAGE_STRING) + except ConfigParser.ParsingError as err: + gbp.log.err('Invalid config file: %s' % err) + return 1 + parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers") parser.add_option("-v", "--verbose", action="store_true", dest="verbose", diff --git a/packaging/git-buildpackage.spec b/packaging/git-buildpackage.spec index a9a034df..f44750ac 100644 --- a/packaging/git-buildpackage.spec +++ b/packaging/git-buildpackage.spec @@ -163,6 +163,7 @@ GIT_CEILING_DIRECTORIES=%{_builddir} \ %install rm -rf %{buildroot} WITHOUT_NOSETESTS=1 %{__python} ./setup.py install --root=%{buildroot} --prefix=/usr +rm -rf %{buildroot}%{python_sitelib}/*info %if %{with docs} # Install man pages |