diff options
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/deb/dscfile.py | 4 | ||||
-rw-r--r-- | gbp/deb/upstreamsource.py | 28 | ||||
-rw-r--r-- | gbp/pkg/__init__.py | 5 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage.py | 6 | ||||
-rw-r--r-- | gbp/scripts/common/import_orig.py | 41 | ||||
-rw-r--r-- | gbp/scripts/import_dsc.py | 4 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 7 |
7 files changed, 61 insertions, 34 deletions
diff --git a/gbp/deb/dscfile.py b/gbp/deb/dscfile.py index e2492dc..0671328 100644 --- a/gbp/deb/dscfile.py +++ b/gbp/deb/dscfile.py @@ -20,12 +20,12 @@ import os import re from gbp.errors import GbpError -from gbp.pkg import UpstreamSource +from gbp.deb.upstreamsource import DebianUpstreamSource from gbp.deb.policy import DebianPkgPolicy class DscFile(object): """Keeps all needed data read from a dscfile""" - compressions = r"(%s)" % '|'.join(UpstreamSource.known_compressions()) + compressions = r"(%s)" % '|'.join(DebianUpstreamSource.known_compressions()) pkg_re = re.compile(r'Source:\s+(?P<pkg>.+)\s*') version_re = re.compile(r'Version:\s((?P<epoch>\d+)\:)?' '(?P<version>[%s]+)\s*$' diff --git a/gbp/deb/upstreamsource.py b/gbp/deb/upstreamsource.py new file mode 100644 index 0000000..7eb555a --- /dev/null +++ b/gbp/deb/upstreamsource.py @@ -0,0 +1,28 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2013 Intel Corporation <markus.lehtonen@linux.intel.com> +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +"""Debian-specific upstream sources""" + +from gbp.pkg import UpstreamSource +from gbp.deb.policy import DebianPkgPolicy + + +class DebianUpstreamSource(UpstreamSource): + """Upstream source class for Debian""" + def __init__(self, name, unpacked=None): + super(DebianUpstreamSource, self).__init__(name, + unpacked, + DebianPkgPolicy) diff --git a/gbp/pkg/__init__.py b/gbp/pkg/__init__.py index 1fd1741..2e24648 100644 --- a/gbp/pkg/__init__.py +++ b/gbp/pkg/__init__.py @@ -179,8 +179,9 @@ class UpstreamSource(object): @cvar _unpacked: path to the unpacked source tree @type _unpacked: string """ - def __init__(self, name, unpacked=None): + def __init__(self, name, unpacked=None, pkg_policy=PkgPolicy): self._orig = False + self._pkg_policy = pkg_policy self._path = name self.unpacked = unpacked @@ -317,7 +318,7 @@ class UpstreamSource(object): except gbpc.CommandExecFailed: # repackArchive already printed an error raise GbpError - return UpstreamSource(newarchive) + return type(self)(newarchive) @staticmethod def known_compressions(): diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py index 8d79e8b..457673c 100755 --- a/gbp/scripts/buildpackage.py +++ b/gbp/scripts/buildpackage.py @@ -30,6 +30,7 @@ from gbp.config import (GbpOptionParserDebian, GbpOptionGroup) from gbp.deb.git import (GitRepositoryError, DebianGitRepository) from gbp.deb.source import DebianSource, DebianSourceError from gbp.git.vfs import GitVfs +from gbp.deb.upstreamsource import DebianUpstreamSource from gbp.errors import GbpError import gbp.log import gbp.notifications @@ -37,8 +38,7 @@ from gbp.scripts.common.buildpackage import (index_name, wc_name, 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, treeish, comp_type, comp_level, with_submodules): "create a compressed orig tarball in output_dir using git_archive" @@ -172,7 +172,7 @@ def extract_orig(orig_tarball, dest_dir): gbp.log.info("Extracting %s to '%s'" % (os.path.basename(orig_tarball), dest_dir)) move_old_export(dest_dir) - upstream = UpstreamSource(orig_tarball) + upstream = DebianUpstreamSource(orig_tarball) upstream.unpack(dest_dir) # Check if tarball extracts into a single folder or not: diff --git a/gbp/scripts/common/import_orig.py b/gbp/scripts/common/import_orig.py index c2c53a6..8e18e97 100644 --- a/gbp/scripts/common/import_orig.py +++ b/gbp/scripts/common/import_orig.py @@ -32,29 +32,26 @@ except ImportError: pass -class OrigUpstreamSource(UpstreamSource): - """Upstream source that will be imported""" - - def needs_repack(self, 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)): +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 not self.is_orig(): - if len(options.filters): - return True - elif options.pristine_tar: - return True - return False + elif options.pristine_tar: + return True + return False def cleanup_tmp_tree(tree): diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py index 600b394..ce97fcb 100644 --- a/gbp/scripts/import_dsc.py +++ b/gbp/scripts/import_dsc.py @@ -26,8 +26,8 @@ import glob import pipes import time import gbp.command_wrappers as gbpc -from gbp.pkg import UpstreamSource from gbp.deb.dscfile import DscFile +from gbp.deb.upstreamsource import DebianUpstreamSource from gbp.deb.git import (DebianGitRepository, GitRepositoryError) from gbp.deb.changelog import ChangeLog from gbp.git import rfc822_date_to_git @@ -328,7 +328,7 @@ def main(argv): set_bare_repo_options(options) dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..')) - upstream = UpstreamSource(src.tgz) + upstream = DebianUpstreamSource(src.tgz) upstream.unpack(dirs['tmp'], options.filters) format = [(options.upstream_tag, "Upstream"), (options.debian_tag, "Debian")][src.native] diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 542896e..f81d249 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -23,13 +23,14 @@ import sys import tempfile import gbp.command_wrappers as gbpc from gbp.deb import (DebianPkgPolicy, parse_changelog_repo) +from gbp.deb.upstreamsource import DebianUpstreamSource from gbp.deb.uscan import (Uscan, UscanError) from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.deb.git import (GitRepositoryError, DebianGitRepository) from gbp.config import GbpOptionParserDebian, GbpOptionGroup, no_upstream_branch_msg from gbp.errors import GbpError import gbp.log -from gbp.scripts.common.import_orig import (OrigUpstreamSource, cleanup_tmp_tree, +from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree, ask_package_name, ask_package_version, repack_source, is_link_target) @@ -167,7 +168,7 @@ def find_source(use_uscan, args): elif len(args) == 0: raise GbpError("No archive to import specified. Try --help.") else: - archive = OrigUpstreamSource(args[0]) + archive = DebianUpstreamSource(args[0]) return archive @@ -300,7 +301,7 @@ def main(argv): source.unpack(tmpdir, options.filters) gbp.log.debug("Unpacked '%s' to '%s'" % (source.path, source.unpacked)) - if source.needs_repack(options): + 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) |