Skip to content

Commit

Permalink
[FIX] packaging: fix rpm package and stop using bdist_rpm
Browse files Browse the repository at this point in the history
The rpm package failed recently on a file name containing a space.
This issue is fixed by protecting file names with double quotes in the
installed files list.

Also, during this fix, it was discovered that the bdist_rpm is
deprecated in setuptools [0].

For that reason, the rpm is now generated from the package.py script.

[0] pypa/setuptools#2780
  • Loading branch information
d-fence committed Feb 16, 2022
1 parent 9fbf706 commit 8d47e1d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
1 change: 1 addition & 0 deletions setup/package.dffedora
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN dnf update -d 0 -e 0 -y && \
python3-babel \
python3-dateutil \
python3-decorator \
python3-devel \
python3-docutils \
python3-freezegun \
python3-gevent \
Expand Down
12 changes: 11 additions & 1 deletion setup/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,17 @@ class DockerRpm(Docker):

def build(self):
logging.info('Start building fedora rpm package')
self.run('python3 setup.py --quiet bdist_rpm', self.args.build_dir, 'odoo-rpm-build-%s' % TSTAMP)
rpmbuild_dir = '/var/lib/odoo/rpmbuild'
cmds = [
'cd /data/src',
'mkdir -p dist',
'rpmdev-setuptree -d',
f'cp -a /data/src/setup/rpm/odoo.spec {rpmbuild_dir}/SPECS/',
f'tar --transform "s/^\\./odoo-{VERSION}/" -c -z -f {rpmbuild_dir}/SOURCES/odoo-{VERSION}.tar.gz .',
f'rpmbuild -bb --define="%version {VERSION}" /data/src/setup/rpm/odoo.spec',
f'mv {rpmbuild_dir}/RPMS/noarch/odoo*.rpm /data/src/dist/'
]
self.run(' && '.join(cmds), self.args.build_dir, f'odoo-rpm-build-{TSTAMP}')
os.rename(glob('%s/dist/odoo-*.noarch.rpm' % self.args.build_dir)[0], '%s/odoo_%s.%s.rpm' % (self.args.build_dir, VERSION, TSTAMP))
logging.info('Finished building fedora rpm package')

Expand Down
4 changes: 0 additions & 4 deletions setup/redhat/install.sh

This file was deleted.

45 changes: 43 additions & 2 deletions setup/redhat/postinstall.sh → setup/rpm/odoo.spec
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
%global name odoo
%global release 1
%global unmangled_version %{version}

Summary: Odoo Server
Name: %{name}
Version: %{version}
Release: %{release}
Source0: %{name}-%{unmangled_version}.tar.gz
License: LGPL-3
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Prefix: %{_prefix}
BuildArch: noarch
Vendor: Odoo S.A. <[email protected]>
Requires: sassc
BuildRequires: python3-devel
Url: https://www.odoo.com

%description
Odoo is a complete ERP and CRM. The main features are accounting (analytic
and financial), stock management, sales and purchases management, tasks
automation, marketing campaigns, help desk, POS, etc. Technical features include
a distributed server, an object database, a dynamic GUI,
customizable reports, and XML-RPC interfaces.

%prep
%autosetup

%build
%py3_build

%install
%py3_install

%post
#!/bin/sh

set -e
Expand All @@ -9,7 +45,6 @@ ODOO_GROUP="odoo"
ODOO_LOG_DIR=/var/log/odoo
ODOO_LOG_FILE=$ODOO_LOG_DIR/odoo-server.log
ODOO_USER="odoo"
ABI=$(rpm -q --provides python3 | uniq | awk '/abi/ {print $NF}')

if ! getent passwd | grep -q "^odoo:"; then
groupadd $ODOO_GROUP
Expand All @@ -29,7 +64,7 @@ db_host = False
db_port = False
db_user = $ODOO_USER
db_password = False
addons_path = /usr/lib/python${ABI}/site-packages/odoo/addons
addons_path = %{python3_sitelib}/odoo/addons
" > $ODOO_CONFIGURATION_FILE
chown $ODOO_USER:$ODOO_GROUP $ODOO_CONFIGURATION_FILE
chmod 0640 $ODOO_CONFIGURATION_FILE
Expand Down Expand Up @@ -60,3 +95,9 @@ KillMode=mixed
[Install]
WantedBy=multi-user.target
EOF


%files
%{_bindir}/odoo
%{python3_sitelib}/%{name}-*.egg-info
%{python3_sitelib}/%{name}

0 comments on commit 8d47e1d

Please sign in to comment.