[FIX] Packaging: debian: .dsc file reference to .tar.gz

Renamming logic (odoo_version.timestamp.extension) of published
files moved out of publish function
This commit is contained in:
Aaron Bohy 2014-12-30 13:22:49 +01:00
parent a8a8beb294
commit 6977c4daac
1 changed files with 19 additions and 47 deletions

View File

@ -41,24 +41,15 @@ from tempfile import NamedTemporaryFile
#---------------------------------------------------------- #----------------------------------------------------------
execfile(join(dirname(__file__), '..', 'openerp', 'release.py')) execfile(join(dirname(__file__), '..', 'openerp', 'release.py'))
version = version.split('-')[0] version = version.split('-')[0]
timestamp = time.strftime("%Y%m%d", time.gmtime())
GPGPASSPHRASE = os.getenv('GPGPASSPHRASE') GPGPASSPHRASE = os.getenv('GPGPASSPHRASE')
GPGID = os.getenv('GPGID') GPGID = os.getenv('GPGID')
timestamp = time.strftime("%Y%m%d", time.gmtime())
PUBLISH_DIRS = { PUBLISH_DIRS = {
'debian': 'deb', 'debian': 'deb',
'redhat': 'rpm', 'redhat': 'rpm',
'tarball': 'src', 'tarball': 'src',
'windows': 'exe', 'windows': 'exe',
} }
EXTENSIONS = [
'.tar.gz',
'.zip',
'.deb',
'.dsc',
'.changes',
'.noarch.rpm',
'.exe',
]
def mkdir(d): def mkdir(d):
if not os.path.isdir(d): if not os.path.isdir(d):
@ -97,27 +88,13 @@ def _rpc_count_modules(addr='http://127.0.0.1', port=8069, dbname='mycompany'):
print("Package test: FAILED. Not able to install base.") print("Package test: FAILED. Not able to install base.")
raise Exception("Installation of package failed") raise Exception("Installation of package failed")
def publish(o, type, releases): def publish(o, type, extensions):
def _publish(o, release): def _publish(o, release):
arch = '' arch = ''
filename = release.split(os.path.sep)[-1] filename = release.split(os.path.sep)[-1]
extension = None
for EXTENSION in EXTENSIONS:
if filename.endswith(EXTENSION):
extension = EXTENSION
filename = filename.replace(extension, '')
break
if extension is None:
raise Exception("Extension of %s is not handled" % filename)
# keep _all or _amd64
if filename.count('_') > 1:
arch = '_' + filename.split('_')[-1]
release_dir = PUBLISH_DIRS[type] release_dir = PUBLISH_DIRS[type]
release_filename = 'odoo_%s.%s%s%s' % (version, timestamp, arch, extension) release_path = join(o.pub, release_dir, filename)
release_path = join(o.pub, release_dir, release_filename)
system('mkdir -p %s' % join(o.pub, release_dir)) system('mkdir -p %s' % join(o.pub, release_dir))
shutil.move(join(o.build_dir, release), release_path) shutil.move(join(o.build_dir, release), release_path)
@ -134,11 +111,9 @@ def publish(o, type, releases):
return release_path return release_path
published = [] published = []
if isinstance(releases, basestring): for extension in extensions:
published.append(_publish(o, releases)) release = glob("%s/odoo_*.%s" % (o.build_dir, extension))[0]
elif isinstance(releases, list): published.append(_publish(o, release))
for release in releases:
published.append(_publish(o, release))
return published return published
class OdooDocker(object): class OdooDocker(object):
@ -271,10 +246,13 @@ def _prepare_build_dir(o):
def build_tgz(o): def build_tgz(o):
system(['python2', 'setup.py', 'sdist', '--quiet', '--formats=gztar,zip'], o.build_dir) system(['python2', 'setup.py', 'sdist', '--quiet', '--formats=gztar,zip'], o.build_dir)
system(['cp', glob('%s/dist/odoo-*.tar.gz' % o.build_dir)[0], '%s/odoo.tar.gz' % o.build_dir]) system(['mv', glob('%s/dist/odoo-*.tar.gz' % o.build_dir)[0], '%s/odoo_%s.%s.tar.gz' % (o.build_dir, version, timestamp)])
system(['cp', glob('%s/dist/odoo-*.zip' % o.build_dir)[0], '%s/odoo.zip' % o.build_dir]) system(['mv', glob('%s/dist/odoo-*.zip' % o.build_dir)[0], '%s/odoo_%s.%s.zip' % (o.build_dir, version, timestamp)])
def build_deb(o): def build_deb(o):
# Append timestamp to version for the .dsc to refer the right .tar.gz
cmd=['sed', '-i', '1s/^.*$/odoo (%s.%s) stable; urgency=low/'%(version,timestamp), 'debian/changelog']
subprocess.call(cmd, cwd=o.build_dir)
deb = pexpect.spawn('dpkg-buildpackage -rfakeroot -k%s' % GPGID, cwd=o.build_dir) deb = pexpect.spawn('dpkg-buildpackage -rfakeroot -k%s' % GPGID, cwd=o.build_dir)
deb.logfile = stdout deb.logfile = stdout
deb.expect_exact('Enter passphrase: ', timeout=1200) deb.expect_exact('Enter passphrase: ', timeout=1200)
@ -289,11 +267,11 @@ def build_deb(o):
def build_rpm(o): def build_rpm(o):
system(['python2', 'setup.py', '--quiet', 'bdist_rpm'], o.build_dir) system(['python2', 'setup.py', '--quiet', 'bdist_rpm'], o.build_dir)
system(['cp', glob('%s/dist/odoo-*.noarch.rpm' % o.build_dir)[0], '%s/odoo.noarch.rpm' % o.build_dir]) system(['mv', glob('%s/dist/odoo-*.noarch.rpm' % o.build_dir)[0], '%s/odoo_%s.%s.noarch.rpm' % (o.build_dir, version, timestamp)])
def build_exe(o): def build_exe(o):
KVMWinBuildExe(o, o.vm_winxp_image, o.vm_winxp_ssh_key, o.vm_winxp_login).start() KVMWinBuildExe(o, o.vm_winxp_image, o.vm_winxp_ssh_key, o.vm_winxp_login).start()
system(['cp', glob('%s/openerp*.exe' % o.build_dir)[0], '%s/odoo.exe' % o.build_dir]) system(['cp', glob('%s/openerp*.exe' % o.build_dir)[0], '%s/odoo_%s.%s.exe' % (o.build_dir, version, timestamp)])
#---------------------------------------------------------- #----------------------------------------------------------
# Stage: testing # Stage: testing
@ -317,7 +295,7 @@ def _prepare_testing(o):
def test_tgz(o): def test_tgz(o):
with docker('odoo-debian-nightly-tests', o.build_dir, o.pub) as wheezy: with docker('odoo-debian-nightly-tests', o.build_dir, o.pub) as wheezy:
wheezy.release = 'odoo.tar.gz' wheezy.release = '*.tar.gz'
wheezy.system("service postgresql start") wheezy.system("service postgresql start")
wheezy.system('/usr/local/bin/pip install /opt/release/%s' % wheezy.release) wheezy.system('/usr/local/bin/pip install /opt/release/%s' % wheezy.release)
wheezy.system("useradd --system --no-create-home odoo") wheezy.system("useradd --system --no-create-home odoo")
@ -340,7 +318,7 @@ def test_deb(o):
def test_rpm(o): def test_rpm(o):
with docker('odoo-centos-nightly-tests', o.build_dir, o.pub) as centos7: with docker('odoo-centos-nightly-tests', o.build_dir, o.pub) as centos7:
centos7.release = 'odoo.noarch.rpm' centos7.release = '*.noarch.rpm'
# Start postgresql # Start postgresql
centos7.system('su postgres -c "/usr/bin/pg_ctl -D /var/lib/postgres/data start"') centos7.system('su postgres -c "/usr/bin/pg_ctl -D /var/lib/postgres/data start"')
centos7.system('sleep 5') centos7.system('sleep 5')
@ -454,7 +432,7 @@ def main():
try: try:
if not o.no_testing: if not o.no_testing:
test_tgz(o) test_tgz(o)
published_files = publish(o, 'tarball', ['odoo.tar.gz', 'odoo.zip']) published_files = publish(o, 'tarball', ['tar.gz', 'zip'])
except Exception, e: except Exception, e:
print("Won't publish the tgz release.\n Exception: %s" % str(e)) print("Won't publish the tgz release.\n Exception: %s" % str(e))
if not o.no_debian: if not o.no_debian:
@ -462,13 +440,7 @@ def main():
try: try:
if not o.no_testing: if not o.no_testing:
test_deb(o) test_deb(o)
published_files = publish(o, 'debian', ['deb', 'dsc', 'changes', 'tar.gz'])
to_publish = []
to_publish.append(glob("%s/odoo_*.deb" % o.build_dir)[0])
to_publish.append(glob("%s/odoo_*.dsc" % o.build_dir)[0])
to_publish.append(glob("%s/odoo_*.changes" % o.build_dir)[0])
to_publish.append(glob("%s/odoo_*.tar.gz" % o.build_dir)[0])
published_files = publish(o, 'debian', to_publish)
gen_deb_package(o, published_files) gen_deb_package(o, published_files)
except Exception, e: except Exception, e:
print("Won't publish the deb release.\n Exception: %s" % str(e)) print("Won't publish the deb release.\n Exception: %s" % str(e))
@ -477,7 +449,7 @@ def main():
try: try:
if not o.no_testing: if not o.no_testing:
test_rpm(o) test_rpm(o)
published_files = publish(o, 'redhat', ['odoo.noarch.rpm']) published_files = publish(o, 'redhat', ['noarch.rpm'])
gen_rpm_repo(o, published_files[0]) gen_rpm_repo(o, published_files[0])
except Exception, e: except Exception, e:
print("Won't publish the rpm release.\n Exception: %s" % str(e)) print("Won't publish the rpm release.\n Exception: %s" % str(e))
@ -486,7 +458,7 @@ def main():
try: try:
if not o.no_testing: if not o.no_testing:
test_exe(o) test_exe(o)
published_files = publish(o, 'windows', ['odoo.exe']) published_files = publish(o, 'windows', ['exe'])
except Exception, e: except Exception, e:
print("Won't publish the exe release.\n Exception: %s" % str(e)) print("Won't publish the exe release.\n Exception: %s" % str(e))
except: except: