Skip to content

Commit 8d47e1d

Browse files
committed
[FIX] packaging: fix rpm package and stop using bdist_rpm
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
1 parent 9fbf706 commit 8d47e1d

File tree

4 files changed

+55
-7
lines changed

4 files changed

+55
-7
lines changed

setup/package.dffedora

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RUN dnf update -d 0 -e 0 -y && \
1717
python3-babel \
1818
python3-dateutil \
1919
python3-decorator \
20+
python3-devel \
2021
python3-docutils \
2122
python3-freezegun \
2223
python3-gevent \

setup/package.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,17 @@ class DockerRpm(Docker):
345345

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

setup/redhat/install.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup/redhat/postinstall.sh renamed to setup/rpm/odoo.spec

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
1+
%global name odoo
2+
%global release 1
3+
%global unmangled_version %{version}
4+
5+
Summary: Odoo Server
6+
Name: %{name}
7+
Version: %{version}
8+
Release: %{release}
9+
Source0: %{name}-%{unmangled_version}.tar.gz
10+
License: LGPL-3
11+
Group: Development/Libraries
12+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
13+
Prefix: %{_prefix}
14+
BuildArch: noarch
15+
Vendor: Odoo S.A. <[email protected]>
16+
Requires: sassc
17+
BuildRequires: python3-devel
18+
Url: https://www.odoo.com
19+
20+
%description
21+
Odoo is a complete ERP and CRM. The main features are accounting (analytic
22+
and financial), stock management, sales and purchases management, tasks
23+
automation, marketing campaigns, help desk, POS, etc. Technical features include
24+
a distributed server, an object database, a dynamic GUI,
25+
customizable reports, and XML-RPC interfaces.
26+
27+
%prep
28+
%autosetup
29+
30+
%build
31+
%py3_build
32+
33+
%install
34+
%py3_install
35+
36+
%post
137
#!/bin/sh
238

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

1449
if ! getent passwd | grep -q "^odoo:"; then
1550
groupadd $ODOO_GROUP
@@ -29,7 +64,7 @@ db_host = False
2964
db_port = False
3065
db_user = $ODOO_USER
3166
db_password = False
32-
addons_path = /usr/lib/python${ABI}/site-packages/odoo/addons
67+
addons_path = %{python3_sitelib}/odoo/addons
3368
" > $ODOO_CONFIGURATION_FILE
3469
chown $ODOO_USER:$ODOO_GROUP $ODOO_CONFIGURATION_FILE
3570
chmod 0640 $ODOO_CONFIGURATION_FILE
@@ -60,3 +95,9 @@ KillMode=mixed
6095
[Install]
6196
WantedBy=multi-user.target
6297
EOF
98+
99+
100+
%files
101+
%{_bindir}/odoo
102+
%{python3_sitelib}/%{name}-*.egg-info
103+
%{python3_sitelib}/%{name}

0 commit comments

Comments
 (0)