mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 13:24:52 +00:00
include latest commit info in source tarball
This commit is contained in:
@@ -5,14 +5,13 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import re
|
import commands
|
||||||
import subprocess
|
import subprocess
|
||||||
import atexit
|
import atexit
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
### Common helper functions
|
### Common helper functions
|
||||||
####################
|
####################
|
||||||
@@ -80,7 +79,7 @@ def must_copy(src, dst):
|
|||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
error('failed to copy %s to %s: %s' % (src, dst, e))
|
error('failed to copy %s to %s: %s' % (src, dst, e))
|
||||||
|
|
||||||
def must_move(src, dst):
|
def must_move(src, dst):
|
||||||
'''Copy src to dst, exit on failure'''
|
'''Copy src to dst, exit on failure'''
|
||||||
try:
|
try:
|
||||||
@@ -113,15 +112,17 @@ def parse_args():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return options.version, options.branch
|
return options.version, options.branch
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parse_args()
|
parse_args()
|
||||||
version, branch = parse_args()
|
version, branch = parse_args()
|
||||||
|
|
||||||
if not exist_in_path('django-admin') and not exist_in_path('django-admin.py'):
|
if not exist_in_path('django-admin') and not exist_in_path('django-admin.py'):
|
||||||
error('django-admin scripts not found in PATH')
|
error('django-admin scripts not found in PATH')
|
||||||
|
|
||||||
|
latest_commit_info = commands.getoutput('git log %s -1' % branch)
|
||||||
|
|
||||||
# begin
|
# begin
|
||||||
tmpdir = tempfile.mkdtemp()
|
tmpdir = tempfile.mkdtemp()
|
||||||
info('tmpdir is %s' % tmpdir)
|
info('tmpdir is %s' % tmpdir)
|
||||||
@@ -130,27 +131,31 @@ def main():
|
|||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
atexit.register(remove_tmpdir)
|
atexit.register(remove_tmpdir)
|
||||||
os.chdir(tmpdir)
|
os.chdir(tmpdir)
|
||||||
|
|
||||||
tarball_name = 'seahub-%s.tar.gz' % version
|
tarball_name = 'seahub-%s.tar.gz' % version
|
||||||
tmp_tarball = os.path.join(tmpdir, tarball_name)
|
tmp_tarball = os.path.join(tmpdir, tarball_name)
|
||||||
|
|
||||||
cmd = 'git archive --prefix=seahub-%(version)s/ -o %(tarball)s %(branch)s' \
|
cmd = 'git archive --prefix=seahub-%(version)s/ -o %(tarball)s %(branch)s' \
|
||||||
% dict(version=version, tarball=tmp_tarball, branch=branch)
|
% dict(version=version, tarball=tmp_tarball, branch=branch)
|
||||||
|
|
||||||
if run(cmd, cwd=cwd) != 0:
|
if run(cmd, cwd=cwd) != 0:
|
||||||
error('failed to "git archive"')
|
error('failed to "git archive"')
|
||||||
|
|
||||||
# uncompress the tarball
|
# uncompress the tarball
|
||||||
if run('tar xf %s' % tmp_tarball) != 0:
|
if run('tar xf %s' % tmp_tarball) != 0:
|
||||||
error('failed to uncompress the tarball')
|
error('failed to uncompress the tarball')
|
||||||
|
|
||||||
seahub_dir = os.path.join(tmpdir, 'seahub-%s' % version)
|
seahub_dir = os.path.join(tmpdir, 'seahub-%s' % version)
|
||||||
if run('./i18n.sh compile-all', cwd=seahub_dir) != 0:
|
if run('./i18n.sh compile-all', cwd=seahub_dir) != 0:
|
||||||
error('failed to compile messages')
|
error('failed to compile messages')
|
||||||
|
|
||||||
|
with open(os.path.join(seahub_dir, 'latest_commit'), 'w') as fp:
|
||||||
|
fp.write(latest_commit_info)
|
||||||
|
fp.write('\n')
|
||||||
|
|
||||||
if run('tar czvf %s seahub-%s' % (tarball_name, version)) != 0:
|
if run('tar czvf %s seahub-%s' % (tarball_name, version)) != 0:
|
||||||
error('failed to generate tarball')
|
error('failed to generate tarball')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user