--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -23,6 +23,7 @@
import logging
import string
import re
+from subprocess import Popen
from difflib import SequenceMatcher
from hashlib import sha1
from datetime import datetime
@@ -1342,4 +1343,18 @@
roots.append(child)
assert not graph, 'Cycle detected'
+
+def zip(source, zipfile, exclude=None):
+ """Create zip archive using zip binary."""
+ zipbin = tg.config.get('scm.repos.tarball.zip_binary', '/usr/bin/zip')
+ source = source.rstrip('/')
+ # this is needed to get proper prefixes inside zip-file
+ working_dir = os.path.dirname(source)
+ source_fn = os.path.basename(source)
+ command = [zipbin, '-r', zipfile, source_fn]
+ if exclude:
+ command += ['-x', exclude]
+ Popen(command, cwd=working_dir).communicate()
+
+
Mapper.compile_all()