Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, devscripts (>= 2.10.66~),
git (>= 1:1.7.0.4-2) | git-core (>= 1:1.5.0.1-1), python-dateutil
Recommends: pristine-tar (>= 0.5), cowbuilder
-Suggests: python-notify
+Suggests: python-notify, unzip
Description: Suite to help with Debian packages in Git repositories
This package contains the following tools:
* git-import-{dsc,dscs}: import existing Debian source packages into a git
Command.__call__(self, [dsc, output_dir])
+class UnpackZipArchive(Command):
+ """Wrap zip to Unpack a zip file"""
+ def __init__(self, archive, dir):
+ self.archive = archive
+ self.dir = dir
+
+ Command.__init__(self, 'unzip', [ "-q", archive, '-d', dir ])
+ self.run_error = 'Couldn\'t unpack "%s"' % self.archive
+
+
class GitCommand(Command):
"Mother/Father of all git commands"
def __init__(self, cmd, args=[], **kwargs):
unpackArchive = gbpc.UnpackTarArchive(archive, tmpdir, filters)
unpackArchive()
except gbpc.CommandExecFailed:
- print >>sys.stderr, "Unpacking of %s failed" % archive
+ # unpackArchive already printed an error message
raise GbpError
return unpackArchive.dir
+def unpack_upstream_source(archive, tmpdir, filters):
+ """
+ Unpack upstream sources into tmpdir
+
+ @return: Return true if the importet archive is suitable as an upstream
+ tarball
+ @rtype: boolean
+ """
+ ext = os.path.splitext(archive)[1]
+ if ext in [ ".zip", ".xpi" ]:
+ try:
+ gbpc.UnpackZipArchive(archive, tmpdir)()
+ except gbpc.CommandExecFailed:
+ raise GbpError, "Unpacking of %s failed" % archive
+ return False
+ else:
+ unpack_orig(archive, tmpdir, filters)
+ return True
+
+
def repack_orig(archive, tmpdir, dest):
"""
recreate a new .orig.tar.gz from tmpdir (useful when using filter option)
repackArchive = gbpc.RepackTarArchive(archive, tmpdir, dest)
repackArchive()
except gbpc.CommandExecFailed:
- print >>sys.stderr, "Failed to create %s" % archive
+ # repackArchive already printed an error
raise GbpError
return repackArchive.dir
import time
import tempfile
import gbp.command_wrappers as gbpc
-from gbp.deb import (parse_changelog, unpack_orig, repack_orig,
+from gbp.deb import (parse_changelog, unpack_upstream_source, repack_orig,
NoChangelogError, has_epoch, tar_toplevel,
guess_upstream_version, do_uscan,
parse_changelog_repo, is_valid_packagename,
if options.interactive:
version = ask_package_version(guessed_version)
else:
- version = guessed_version
+ if guessed_version:
+ version = guessed_version
+ else:
+ raise GbpError, "Couldn't determine upstream version. Use '-u<version>' or --interactive"
(clean, out) = repo.is_clean()
if not clean and not is_empty:
else:
if not options.fast_import:
tmpdir = tempfile.mkdtemp(dir='../')
- unpack_orig(archive, tmpdir, options.filters)
+ is_orig = unpack_upstream_source(archive, tmpdir, options.filters)
gbp.log.debug("Unpacked %s to '%s'" % (archive , tmpdir))
orig_dir = tar_toplevel(tmpdir)
- # Don't mess up or repo with git metadata from an upstream tarball
+ # If the upstream archive is not suitable as an upstream
+ # tarball we turn of pristine-tar for now
+ if not is_orig:
+ options.pristine_tar = False
+
+ # Don't mess up our repo with git metadata from an upstream tarball
try:
if os.path.isdir(os.path.join(orig_dir, '.git/')):
raise GbpError, "The orig tarball contains .git metadata - giving up."
os.path.basename(archive).replace(".tar", ".gbp.tar")
)
repack_orig(archive, tmpdir, os.path.basename(orig_dir))
- pristine_orig = symlink_orig(archive, sourcepackage, version)
-
+ if is_orig:
+ pristine_orig = symlink_orig(archive, sourcepackage, version)
try:
upstream_branch = [ options.upstream_branch, 'master' ][is_empty]
filter_msg = ["", " (filtering out %s)"