[FIX] packaging: create rpm repo from container

The createrepo Debian package is not available in Ubuntu anymore, this
can cause problems on Ubuntu based build systems.

In order to solve that once and for all, with this commit the rpm repo is
generated from a Docker container.

Fixes #63419

closes odoo/odoo#63585

X-original-commit: 8f5c5e585572facd8768e9f9dfc0de9e301f0c93
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
This commit is contained in:
Christophe Monniez
2020-12-18 13:17:13 +00:00
parent 5ec51e1642
commit 5cb543651e
2 changed files with 23 additions and 18 deletions
+1
View File
@@ -7,6 +7,7 @@ MAINTAINER Odoo S.A. <info@odoo.com>
RUN dnf update -d 0 -e 0 -y && \
dnf install -d 0 -e 0 \
babel \
createrepo \
pychart \
pyparsing \
python3-babel \
+22 -18
View File
@@ -145,28 +145,14 @@ def gen_deb_package(args, published_files):
# ---------------------------------------------------------
# Generates an RPM repo
# ---------------------------------------------------------
def gen_rpm_repo(args, file_name):
def rpm_sign(args, file_name):
"""Genereate a rpm repo in publish directory"""
# Sign the RPM
rpmsign = pexpect.spawn('/bin/bash', ['-c', 'rpm --resign %s' % file_name], cwd=os.path.join(args.pub, 'rpm'))
rpmsign.expect_exact('Enter pass phrase: ')
rpmsign.expect_exact('Enter passphrase: ')
rpmsign.send(GPGPASSPHRASE + '\r\n')
rpmsign.expect(pexpect.EOF)
# Removes the old repodata
shutil.rmtree(os.path.join(args.pub, 'rpm', 'repodata'))
# Copy files to a temp directory (required because the working directory must contain only the
# files of the last release)
temp_path = tempfile.mkdtemp(suffix='rpmPackages')
shutil.copy(file_name, temp_path)
run_cmd(['createrepo', temp_path]).check_returncode() # creates a repodata folder in temp_path
shutil.copytree(os.path.join(temp_path, "repodata"), os.path.join(args.pub, 'rpm', 'repodata'))
# Remove temp directory
shutil.rmtree(temp_path)
def _prepare_build_dir(args, win32=False, move_addons=True):
"""Copy files to the build directory"""
@@ -185,7 +171,7 @@ def _prepare_build_dir(args, win32=False, move_addons=True):
except shutil.Error as e:
logging.warning("Warning '%s' while moving addon '%s", e, addon_path)
if addon_path.startswith(args.build_dir) and os.path.isdir(addon_path):
logging.info("Removing ''".format(addon_path))
logging.info("Removing '{}'".format(addon_path))
try:
shutil.rmtree(addon_path)
except shutil.Error as rm_error:
@@ -373,6 +359,21 @@ class DockerRpm(Docker):
self.test_odoo()
logging.info('Finished testing rpm package')
def gen_rpm_repo(self, args, rpm_filepath):
# Removes the old repodata
shutil.rmtree(os.path.join(args.pub, 'rpm', 'repodata'))
# Copy files to a temp directory (required because the working directory must contain only the
# files of the last release)
temp_path = tempfile.mkdtemp(suffix='rpmPackages')
shutil.copy(rpm_filepath, temp_path)
logging.info('Start creating rpm repo')
self.run('createrepo /data/src/', temp_path, 'odoo-rpm-createrepo-%s' % TSTAMP)
shutil.copytree(os.path.join(temp_path, "repodata"), os.path.join(args.pub, 'rpm', 'repodata'))
# Remove temp directory
shutil.rmtree(temp_path)
# KVM stuffs
class KVM(object):
@@ -539,7 +540,10 @@ def main(args):
docker_rpm.start_test()
published_files = publish(args, 'rpm', ['rpm'])
if args.sign:
gen_rpm_repo(args, published_files[0])
logging.info('Signing rpm package')
rpm_sign(args, published_files[0])
logging.info('Generate rpm repo')
docker_rpm.gen_rpm_repo(args, published_files[0])
except Exception as e:
logging.error("Won't publish the rpm release.\n Exception: %s" % str(e))
if args.build_deb: