diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-01-06 11:49:04 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-01-06 11:49:04 +0100 |
| commit | fab4d6d442ebbf081ead7e747f04b61e01ae9db2 (patch) | |
| tree | 3dd9aad0f429f4229e500db503bbf8b7155f9c38 /setup/package.py | |
| parent | 7fea986fd9f6f3ce1cc6c015a2523fdd23cf814d (diff) | |
| parent | ea54d4af9f75e518c5871213a668a9f516e56830 (diff) | |
[MERGE] forward port of branch 8.0 up to ea54d4a
Diffstat (limited to 'setup/package.py')
| -rwxr-xr-x | setup/package.py | 111 |
1 files changed, 43 insertions, 68 deletions
diff --git a/setup/package.py b/setup/package.py index 3047be9dc64..7de6b48fba8 100755 --- a/setup/package.py +++ b/setup/package.py @@ -41,23 +41,15 @@ from tempfile import NamedTemporaryFile #---------------------------------------------------------- execfile(join(dirname(__file__), '..', 'openerp', 'release.py')) version = version.split('-')[0] +timestamp = time.strftime("%Y%m%d", time.gmtime()) GPGPASSPHRASE = os.getenv('GPGPASSPHRASE') GPGID = os.getenv('GPGID') -timestamp = time.strftime("%Y%m%d", time.gmtime()) PUBLISH_DIRS = { 'debian': 'deb', 'redhat': 'rpm', 'tarball': 'src', 'windows': 'exe', } -EXTENSIONS = [ - '.tar.gz', - '.deb', - '.dsc', - '.changes', - '.noarch.rpm', - '.exe', -] def mkdir(d): if not os.path.isdir(d): @@ -96,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.") raise Exception("Installation of package failed") -def publish(o, type, releases): +def publish(o, type, extensions): def _publish(o, release): arch = '' 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_filename = 'odoo_%s.%s%s%s' % (version, timestamp, arch, extension) - release_path = join(o.pub, release_dir, release_filename) + release_path = join(o.pub, release_dir, filename) system('mkdir -p %s' % join(o.pub, release_dir)) shutil.move(join(o.build_dir, release), release_path) @@ -133,11 +111,9 @@ def publish(o, type, releases): return release_path published = [] - if isinstance(releases, basestring): - published.append(_publish(o, releases)) - elif isinstance(releases, list): - for release in releases: - published.append(_publish(o, release)) + for extension in extensions: + release = glob("%s/odoo_*.%s" % (o.build_dir, extension))[0] + published.append(_publish(o, release)) return published class OdooDocker(object): @@ -269,10 +245,14 @@ def _prepare_build_dir(o): shutil.move(i, join(o.build_dir, 'openerp/addons')) def build_tgz(o): - system(['python2', 'setup.py', '--quiet', 'sdist'], o.build_dir) - system(['cp', glob('%s/dist/odoo-*.tar.gz' % o.build_dir)[0], '%s/odoo.tar.gz' % o.build_dir]) + system(['python2', 'setup.py', 'sdist', '--quiet', '--formats=gztar,zip'], 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(['mv', glob('%s/dist/odoo-*.zip' % o.build_dir)[0], '%s/odoo_%s.%s.zip' % (o.build_dir, version, timestamp)]) 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.logfile = stdout deb.expect_exact('Enter passphrase: ', timeout=1200) @@ -287,24 +267,36 @@ def build_deb(o): def build_rpm(o): 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): 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 #---------------------------------------------------------- +def _prepare_testing(o): + if not o.no_tarball or not o.no_debian: + subprocess.call(["mkdir", "docker_debian"], cwd=o.build_dir) + subprocess.call(["cp", "package.dfdebian", os.path.join(o.build_dir, "docker_debian", "Dockerfile")], + cwd=os.path.join(o.odoo_dir, "setup")) + # Use rsync to copy requirements.txt in order to keep original permissions + subprocess.call(["rsync", "-a", "requirements.txt", os.path.join(o.build_dir, "docker_debian")], + cwd=os.path.join(o.odoo_dir)) + subprocess.call(["docker", "build", "-t", "odoo-debian-nightly-tests", "."], + cwd=os.path.join(o.build_dir, "docker_debian")) + if not o.no_rpm: + subprocess.call(["mkdir", "docker_centos"], cwd=o.build_dir) + subprocess.call(["cp", "package.dfcentos", os.path.join(o.build_dir, "docker_centos", "Dockerfile")], + cwd=os.path.join(o.odoo_dir, "setup")) + subprocess.call(["docker", "build", "-t", "odoo-centos-nightly-tests", "."], + cwd=os.path.join(o.build_dir, "docker_centos")) + def test_tgz(o): - with docker('debian:stable', o.build_dir, o.pub) as wheezy: - wheezy.release = 'odoo.tar.gz' - wheezy.system('apt-get update -qq && apt-get upgrade -qq -y') - wheezy.system("apt-get install postgresql python-dev postgresql-server-dev-all python-pip build-essential libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libssl-dev libjpeg-dev -y") + with docker('odoo-debian-nightly-tests', o.build_dir, o.pub) as wheezy: + wheezy.release = '*.tar.gz' wheezy.system("service postgresql start") - wheezy.system('su postgres -s /bin/bash -c "pg_dropcluster --stop 9.1 main"') - wheezy.system('su postgres -s /bin/bash -c "pg_createcluster --start -e UTF-8 9.1 main"') - wheezy.system('pip install -r /opt/release/requirements.txt') wheezy.system('/usr/local/bin/pip install /opt/release/%s' % wheezy.release) wheezy.system("useradd --system --no-create-home odoo") wheezy.system('su postgres -s /bin/bash -c "createuser -s odoo"') @@ -315,13 +307,9 @@ def test_tgz(o): wheezy.system('su odoo -s /bin/bash -c "odoo.py --addons-path=/usr/local/lib/python2.7/dist-packages/openerp/addons -d mycompany &"') def test_deb(o): - with docker('debian:stable', o.build_dir, o.pub) as wheezy: + with docker('odoo-debian-nightly-tests', o.build_dir, o.pub) as wheezy: wheezy.release = '*.deb' - wheezy.system('/usr/bin/apt-get update -qq && /usr/bin/apt-get upgrade -qq -y') - wheezy.system("apt-get install postgresql -y") wheezy.system("service postgresql start") - wheezy.system('su postgres -s /bin/bash -c "pg_dropcluster --stop 9.1 main"') - wheezy.system('su postgres -s /bin/bash -c "pg_createcluster --start -e UTF-8 9.1 main"') wheezy.system('su postgres -s /bin/bash -c "createdb mycompany"') wheezy.system('/usr/bin/dpkg -i /opt/release/%s' % wheezy.release) wheezy.system('/usr/bin/apt-get install -f -y') @@ -329,18 +317,9 @@ def test_deb(o): wheezy.system('su odoo -s /bin/bash -c "odoo.py -c /etc/odoo/openerp-server.conf -d mycompany &"') def test_rpm(o): - with docker('centos:centos7', o.build_dir, o.pub) as centos7: - centos7.release = 'odoo.noarch.rpm' - # Dependencies - centos7.system('yum install -d 0 -e 0 epel-release -y') - centos7.system('yum update -d 0 -e 0 -y') - # Manual install/start of postgres - centos7.system('yum install -d 0 -e 0 postgresql postgresql-server postgresql-libs postgresql-contrib postgresql-devel -y') - centos7.system('mkdir -p /var/lib/postgres/data') - centos7.system('chown -R postgres:postgres /var/lib/postgres/data') - centos7.system('chmod 0700 /var/lib/postgres/data') - centos7.system('su postgres -c "initdb -D /var/lib/postgres/data -E UTF-8"') - centos7.system('cp /usr/share/pgsql/postgresql.conf.sample /var/lib/postgres/data/postgresql.conf') + with docker('odoo-centos-nightly-tests', o.build_dir, o.pub) as centos7: + centos7.release = '*.noarch.rpm' + # Start postgresql centos7.system('su postgres -c "/usr/bin/pg_ctl -D /var/lib/postgres/data start"') centos7.system('sleep 5') centos7.system('su postgres -c "createdb mycompany"') @@ -445,13 +424,15 @@ def options(): def main(): o = options() _prepare_build_dir(o) + if not o.no_testing: + _prepare_testing(o) try: if not o.no_tarball: build_tgz(o) try: if not o.no_testing: test_tgz(o) - published_files = publish(o, 'tarball', ['odoo.tar.gz']) + published_files = publish(o, 'tarball', ['tar.gz', 'zip']) except Exception, e: print("Won't publish the tgz release.\n Exception: %s" % str(e)) if not o.no_debian: @@ -459,13 +440,7 @@ def main(): try: if not o.no_testing: test_deb(o) - - 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) + published_files = publish(o, 'debian', ['deb', 'dsc', 'changes', 'tar.gz']) gen_deb_package(o, published_files) except Exception, e: print("Won't publish the deb release.\n Exception: %s" % str(e)) @@ -474,7 +449,7 @@ def main(): try: if not o.no_testing: 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]) except Exception, e: print("Won't publish the rpm release.\n Exception: %s" % str(e)) @@ -483,7 +458,7 @@ def main(): try: if not o.no_testing: test_exe(o) - published_files = publish(o, 'windows', ['odoo.exe']) + published_files = publish(o, 'windows', ['exe']) except Exception, e: print("Won't publish the exe release.\n Exception: %s" % str(e)) except: |
