diff options
author | Ed Bartosh <eduard.bartosh@intel.com> | 2012-05-09 18:46:27 +0300 |
---|---|---|
committer | Ed Bartosh <eduard.bartosh@intel.com> | 2012-05-10 13:17:03 +0300 |
commit | 8b15365a5c2b0977af3e077fa7855bbdf0cc9132 (patch) | |
tree | 1fa5a3b2cfbe270d71cd5c2462d92a07203ed8c6 | |
parent | 627d6bb4cb30df77e0e831e66d5de5eb35af88c8 (diff) | |
download | git-buildpackage-8b15365a5c2b0977af3e077fa7855bbdf0cc9132.tar.gz git-buildpackage-8b15365a5c2b0977af3e077fa7855bbdf0cc9132.tar.bz2 git-buildpackage-8b15365a5c2b0977af3e077fa7855bbdf0cc9132.zip |
Implemented zip archive support
Change-Id: I96361b297c6583cdacddd4f4e99959c1b092ae2d
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
-rw-r--r-- | gbp/rpm/__init__.py | 22 | ||||
-rwxr-xr-x | gbp/scripts/buildpackage_rpm.py | 17 | ||||
-rw-r--r-- | gbp/scripts/common/buildpackage.py | 7 |
3 files changed, 29 insertions, 17 deletions
diff --git a/gbp/rpm/__init__.py b/gbp/rpm/__init__.py index e68d7d50..8b8119ec 100644 --- a/gbp/rpm/__init__.py +++ b/gbp/rpm/__init__.py @@ -92,7 +92,7 @@ class SrcRpmFile(object): srpmfp.close() self.rpmhdr = RpmHdrInfo(rpmhdr) self.srpmfile = os.path.abspath(srpmfile) - (self.orig_file, self.orig_comp) = self.guess_orig_file() + (self.orig_file, self.orig_format, self.orig_comp) = self.guess_orig_file() def _get_version(self): """ @@ -148,9 +148,12 @@ class SrcRpmFile(object): Try to guess the name of the primary upstream/source tarball returns a tuple with tarball filename and compression suffix """ - tarball_re = re.compile(r'(?P<name>%s)?.*tar\.?(?P<comp>(bz2|gz|xz|lzma|\b))$' % self.rpmhdr[rpm.RPMTAG_NAME]) + tarball_re = re.compile( + r'(?P<name>%s).*?\.(?P<format>tar|zip)\.?(?P<comp>(bz2|gz|xz|lzma|\b))$' % \ + self.rpmhdr[rpm.RPMTAG_NAME]) tarball = "" comp = "" + formt = "" # Take the first file that starts 'name' and has suffix like 'tar.*' for s in self.rpmhdr[rpm.RPMTAG_SOURCE]: @@ -159,14 +162,16 @@ class SrcRpmFile(object): # Take the first tarball that starts with pkg name if m.group('name'): tarball = s + formt = m.group('format') comp = m.group('comp') break # otherwise we take the first tarball elif not tarball: tarball = s + formt = m.group('format') comp = m.group('comp') # else don't accept - return (tarball, comp) + return (tarball, formt, comp) def debugprint(self): @@ -200,7 +205,7 @@ class SpecFile(object): self.specdir = os.path.dirname(self.specfile) self.patches = {} self.sources = {} - (self.orig_file, self.orig_base, self.orig_comp) = self.guess_orig_file() + (self.orig_file, self.orig_base, self.orig_format, self.orig_comp) = self.guess_orig_file() patchparser = OptionParser() patchparser.add_option("-p", dest="strip") @@ -416,8 +421,9 @@ class SpecFile(object): Try to guess the name of the primary upstream/source tarball returns a tuple with tarball filename and compression suffix """ - tarball_re = re.compile(r'(?P<base>(?P<name>%s)?.*)\.tar\.?(?P<comp>(bz2|gz|xz|lzma|\b))$' % - self.specinfo.packages[0].header[rpm.RPMTAG_NAME]) + tarball_re = re.compile( + r'(?P<base>(?P<name>%s)?.*)?\.(?P<format>tar|zip)\.?(?P<comp>(bz2|gz|xz|lzma|\b))$' % \ + self.specinfo.packages[0].header[rpm.RPMTAG_NAME]) tarball = "" base = "" comp = "" @@ -433,14 +439,16 @@ class SpecFile(object): tarball = name base = m.group('base') comp = m.group('comp') + formt = m.group('format') break # otherwise we only take the first tarball elif not tarball: tarball = name base = m.group('base') comp = m.group('comp') + formt = m.group('format') # else don't accept - return (tarball, base, comp) + return (tarball, base, formt, comp) def debugprint(self): diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index de50236b..3f0cbcfb 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -42,10 +42,12 @@ from gbp.pkg import (compressor_opts, compressor_aliases) def git_archive(repo, spec, output_dir, treeish, comp_type, comp_level, with_submodules): "create a compressed orig tarball in output_dir using git_archive" - try: - comp_opts = compressor_opts[comp_type][0] - except KeyError: - raise GbpError, "Unsupported compression type '%s'" % comp_type + comp_opts = '' + if spec.orig_format == 'tar': + try: + comp_opts = compressor_opts[comp_type][0] + except KeyError: + raise GbpError, "Unsupported compression type '%s'" % comp_type output = os.path.join(output_dir, os.path.basename(spec.orig_file)) prefix = spec.orig_base @@ -58,7 +60,7 @@ def git_archive(repo, spec, output_dir, treeish, comp_type, comp_level, with_sub else: git_archive_single(treeish, output, prefix, - comp_type, comp_level, comp_opts) + comp_type, comp_level, comp_opts, spec.orig_format) except CommandExecFailed: gbp.log.err("Error generating submodules' archives") return False @@ -185,8 +187,9 @@ def git_archive_build_orig(repo, spec, output_dir, options): upstream_tree = get_upstream_tree(repo, spec, options) gbp.log.info("%s does not exist, creating from '%s'" % (spec.orig_file, upstream_tree)) - gbp.log.debug("Building upstream tarball with compression '%s -%s'" % - (options.comp_type, options.comp_level)) + if options.comp_type: + gbp.log.debug("Building upstream tarball with compression '%s -%s'" % + (options.comp_type, options.comp_level)) if not git_archive(repo, spec, output_dir, upstream_tree, options.comp_type, options.comp_level, diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py index 921bc159..85420b7e 100644 --- a/gbp/scripts/common/buildpackage.py +++ b/gbp/scripts/common/buildpackage.py @@ -70,15 +70,16 @@ def git_archive_submodules(repo, treeish, output, prefix, comp_type, comp_level, shutil.rmtree(tempdir) -def git_archive_single(treeish, output, prefix, comp_type, comp_level, comp_opts): +def git_archive_single(treeish, output, prefix, comp_type, comp_level, comp_opts, formt='tar'): """ Create tar.gz of an archive without submodules Exception handling is left to the caller. """ pipe = pipes.Template() - pipe.prepend("git archive --format=tar --prefix=%s/ %s" % (prefix, treeish), '.-') - pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--') + pipe.prepend("git archive --format=%s --prefix=%s/ %s" % (formt, prefix, treeish), '.-') + if comp_type: + pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--') ret = pipe.copy('', output) if ret: raise GbpError("Error creating %s: %d" % (output, ret)) |