mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-09 01:55:04 +00:00
[Packaging] Simplify release script using sdist
* setup.py sdist now creates a pristine tar which can be used for release. * Uses the version currently checked-out in git. * Removed unneeded lines in manifest.
This commit is contained in:
parent
3f13c24362
commit
51bde704b5
@ -1,11 +1,9 @@
|
|||||||
include AUTHORS ChangeLog DEPENDS LICENSE RELEASE-VERSION README.rst
|
include AUTHORS ChangeLog DEPENDS LICENSE RELEASE-VERSION README.rst
|
||||||
include msgfmt.py minify_web_js.py version.py gen_web_gettext.py
|
include msgfmt.py minify_web_js.py version.py gen_web_gettext.py
|
||||||
exclude .* tox.ini
|
|
||||||
|
|
||||||
graft docs/man
|
graft docs/man
|
||||||
|
|
||||||
include deluge/i18n/*.po
|
include deluge/i18n/*.po
|
||||||
recursive-exclude deluge/i18n LC_MESSAGES *.mo
|
|
||||||
|
|
||||||
graft deluge/plugins
|
graft deluge/plugins
|
||||||
recursive-exclude deluge/plugins create_dev_link.sh *.pyc *.egg
|
recursive-exclude deluge/plugins create_dev_link.sh *.pyc *.egg
|
||||||
|
@ -7,17 +7,11 @@
|
|||||||
# the additional special exception to link portions of this program with the OpenSSL library.
|
# the additional special exception to link portions of this program with the OpenSSL library.
|
||||||
# See LICENSE for more details.
|
# See LICENSE for more details.
|
||||||
#
|
#
|
||||||
|
from __future__ import print_function, unicode_literals
|
||||||
|
|
||||||
import contextlib
|
import os.path
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import tarfile
|
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from subprocess import STDOUT, CalledProcessError, call, check_output
|
from subprocess import call, check_output
|
||||||
|
|
||||||
|
|
||||||
sys.path.append('.')
|
|
||||||
from version import get_version # NOQA, isort: skip,
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import lzma
|
import lzma
|
||||||
@ -25,54 +19,34 @@ except ImportError:
|
|||||||
try:
|
try:
|
||||||
from backports import lzma
|
from backports import lzma
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print('backports.lzma not installed, falling back to `tar`')
|
print('backports.lzma not installed, falling back to xz shell command')
|
||||||
lzma = None
|
lzma = None
|
||||||
|
|
||||||
|
# Compress WebUI javascript and gettext.js
|
||||||
"""Get latest annotated tag"""
|
|
||||||
try:
|
|
||||||
release_tag = check_output('git describe --exact-match --abbrev=0'.split(), stderr=STDOUT)
|
|
||||||
except CalledProcessError:
|
|
||||||
# Fallback to dev build tag.
|
|
||||||
dev_tag = check_output('git describe --tags'.split()).strip()
|
|
||||||
release_tag = dev_tag
|
|
||||||
|
|
||||||
version = release_tag.split('deluge-')[1]
|
|
||||||
version_alt = get_version(prefix='deluge-', suffix='.dev0')
|
|
||||||
release_dir = 'release'
|
|
||||||
source_dir = os.path.join(release_dir, release_tag)
|
|
||||||
|
|
||||||
# TODO: tag found/not found continue? (add option to specify tag)
|
|
||||||
|
|
||||||
# TODO: Verify version and date changed in Changelog?
|
|
||||||
# if check_output(('git grep -l "%s" | grep -v ChangeLog' % version).split()):
|
|
||||||
# sys.exit(1)
|
|
||||||
|
|
||||||
"""Create release archive"""
|
|
||||||
try:
|
|
||||||
os.mkdir(release_dir)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
print('Creating release archive for ' + release_tag)
|
|
||||||
call('git archive --format=tar --prefix={tag}/ {tag} | tar -x -C {_dir}'.format(
|
|
||||||
tag=release_tag, _dir=release_dir), shell=True)
|
|
||||||
|
|
||||||
"""Compress WebUI javascript"""
|
|
||||||
call(['python', 'minify_web_js.py'])
|
call(['python', 'minify_web_js.py'])
|
||||||
|
call(['python', 'gen_web_gettext.py'])
|
||||||
|
|
||||||
"""Create source release tarball."""
|
version = check_output(['python', 'version.py']).strip()
|
||||||
tarball = release_tag + '.tar.xz'
|
|
||||||
tarball_path = os.path.join(release_dir, tarball)
|
# Create release archive
|
||||||
|
release_dir = 'dist/release-%s' % version
|
||||||
|
print('Creating release archive for ' + version)
|
||||||
|
call('python setup.py --quiet egg_info --egg-base /tmp sdist --formats=tar --dist-dir=%s' % release_dir, shell=True)
|
||||||
|
|
||||||
|
# Compress release archive with xz
|
||||||
|
tar_path = os.path.join(release_dir, 'deluge-%s.tar' % version)
|
||||||
|
tarxz_path = tar_path + '.xz'
|
||||||
|
print('Compressing tar (%s) with xz' % tar_path)
|
||||||
if lzma:
|
if lzma:
|
||||||
with contextlib.closing(lzma.LZMAFile(tarball_path, mode='w')) as xz_file:
|
with open(tar_path, 'rb') as tar_file, open(tarxz_path, 'wb') as xz_file:
|
||||||
with tarfile.open(fileobj=xz_file, mode='w') as _file:
|
xz_file.write(lzma.compress(bytes(tar_file.read()), preset=9 | lzma.PRESET_EXTREME))
|
||||||
_file.add(source_dir, arcname=release_tag)
|
|
||||||
else:
|
else:
|
||||||
call(['tar', '-cJf', tarball_path, '-C', release_dir, release_tag])
|
call(['xz', '-e9zkf', tar_path])
|
||||||
|
|
||||||
"""Calculate shasum and add to SHASUMS256.txt"""
|
# Calculate shasum and add to sha256sums.txt
|
||||||
with open(tarball_path, 'rb') as _file:
|
with open(tarxz_path, 'rb') as _file:
|
||||||
sha256sum = '%s %s' % (sha256(_file.read()).hexdigest(), tarball)
|
sha256sum = '%s %s' % (sha256(_file.read()).hexdigest(), os.path.basename(tarxz_path))
|
||||||
with open(os.path.join(release_dir, 'SHASUMS256.txt'), 'w') as _file:
|
with open(os.path.join(release_dir, 'sha256sums.txt'), 'w') as _file:
|
||||||
_file.write(sha256sum + '\n')
|
_file.write(sha256sum + '\n')
|
||||||
|
|
||||||
|
print('Complete: %s' % release_dir)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user