summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@fastmail.co.uk>2015-07-07 16:14:18 +0100
committerRichard Ipsum <richardipsum@fastmail.co.uk>2015-07-07 17:19:46 +0100
commit7a19a302773fc6c9e5911f53d36cc905f08bd531 (patch)
tree5ad30721eca0724f7ecad774661bd114ef958b3d
parentc08806278ac97da4d444fa96de047e3525093ce4 (diff)
downloadlorry-7a19a302773fc6c9e5911f53d36cc905f08bd531.tar.gz
Add zip support to lorry
Change-Id: I29368ddcc64c82bafcbb834c81db30018a144f64
-rwxr-xr-xlorry24
-rwxr-xr-x[-rw-r--r--]lorry.zip-importer5
2 files changed, 18 insertions, 11 deletions
diff --git a/lorry b/lorry
index 1ff6f69..da1e556 100755
--- a/lorry
+++ b/lorry
@@ -25,6 +25,7 @@ import sys
from datetime import datetime
import shutil
import traceback
+import functools
__version__ = '0.0'
@@ -190,7 +191,8 @@ class Lorry(cliapp.Application):
'git': self.mirror_git,
'hg': self.gitify_hg,
'svn': self.gitify_svn,
- 'tarball': self.gitify_tarball,
+ 'tarball': functools.partial(self.gitify_archive, 'tar'),
+ 'zip': functools.partial(self.gitify_archive, 'zip')
}
vcstype = spec['type']
if vcstype not in table:
@@ -477,32 +479,34 @@ class Lorry(cliapp.Application):
self.run_program(['hg-fast-export', '--quiet', '--force', '-r', '../hg'],
cwd=gitdir)
- def gitify_tarball(self, project_name, dirname, gitdir, spec):
+ def gitify_archive(self, archive_type, project_name, dirname, gitdir, spec):
+ assert archive_type in ['zip', 'tar']
+
url = spec['url']
url_path = urllib2.urlparse.urlparse(url)[2]
basename = os.path.basename(url_path)
- tardest = os.path.join(dirname, basename)
+ archive_dest = os.path.join(dirname, basename)
self.progress('.. checking if we need to fetch %s' % basename)
- if file_missing_or_empty(tardest):
+ if file_missing_or_empty(archive_dest):
self.progress('.. attempting to fetch.')
try:
- with open(tardest, 'w') as tarfile:
+ with open(archive_dest, 'w') as archive_file:
urlfile = urllib2.urlopen(spec['url'])
- tarfile.write(urlfile.read())
+ archive_file.write(urlfile.read())
urlfile.close()
except Exception as e:
- if os.path.exists(tardest):
- os.unlink(tardest)
+ if os.path.exists(archive_dest):
+ os.unlink(archive_dest)
raise
else:
self.progress('.. no need to run, nothing to do')
return
if not os.path.exists(gitdir):
self.run_program(['git', 'init', '--bare', gitdir])
- cmdline = ["%s.tar-importer" % lorry_path, tardest]
+
+ cmdline = ["%s.%s-importer" % (lorry_path, archive_type), archive_dest]
self.run_program(cmdline, cwd=gitdir)
self.needs_aggressive = True
-
def push_to_mirror_server(self, name, gitdir,
pushrefspecs=['refs/heads/*:refs/heads/*',
diff --git a/lorry.zip-importer b/lorry.zip-importer
index d12c296..c177d43 100644..100755
--- a/lorry.zip-importer
+++ b/lorry.zip-importer
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+## Note: Modified for Baserock lorry.
+
## zip archive frontend for git-fast-import
##
## For example:
@@ -22,7 +24,8 @@ if len(argv) < 2:
print 'usage:', argv[0], '<zipfile>...'
exit(1)
-branch_ref = 'refs/heads/import-zips'
+branch_name = 'master'
+branch_ref = 'refs/heads/%s' % branch_name
committer_name = 'Z Ip Creator'
committer_email = 'zip@example.com'