Skip to content

Commit c26d35d

Browse files
committed
Python3: Update package dependencies
It is also auto generate the documentation and spec/control files according to dependencies.yaml file which contains all the package dependencies Signed-off-by: Aline Manera <[email protected]>
1 parent 2ca1067 commit c26d35d

27 files changed

+363
-219
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build-aux/config.sub
1515
build-aux/install-sh
1616
build-aux/missing
1717
build-aux/py-compile
18+
build-aux/*-pkg-deps
1819
configure
1920
config.log
2021
config.py

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ repos:
99
hooks:
1010
- id: trailing-whitespace
1111
- id: end-of-file-fixer
12+
exclude: '\.list$'
1213
#- id: check-docstring-first
1314
- id: check-json
1415
#- id: check-added-large-files

Makefile.am

+7-6
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,14 @@ deb: contrib/make-deb.sh
134134
$(top_srcdir)/contrib/make-deb.sh
135135

136136
kimchi.spec: contrib/kimchi.spec.fedora contrib/kimchi.spec.suse
137-
@if test -e /etc/redhat-release; then \
138-
ln -sf contrib/kimchi.spec.fedora $@ ; \
139-
elif test -e /etc/SuSE-release; then \
140-
ln -sf contrib/kimchi.spec.suse $@ ; \
137+
OS_DISTRO=`sed -n -e '/^ID=/p' /etc/os-release | sed 's/ID=//g; s|["'\'']||g'`
138+
@if [[ $OS_DISTRO == "fedora" ]]; then \
139+
ln -sf contrib/wok.spec.fedora $@ ; \
140+
elif [[ $OS_DISTRO == "opensuse-leap" ]]; then \
141+
ln -sf contrib/wok.spec.suse $@ ; \
141142
else \
142-
echo "Unable to select a spec file for RPM build" ; \
143-
/bin/false ; \
143+
echo "Unable to select a spec file for RPM build" ; \
144+
/bin/false ; \
144145
fi
145146

146147
rpm: dist kimchi.spec

build-aux/generateDepsFiles.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
5+
import yaml
6+
7+
DOC_HEADER = """# File auto-generated on build process. Do not change it.
8+
# Add new dependencies to dependencies.yaml file instead.
9+
#
10+
"""
11+
12+
13+
def generate_files(os_distro):
14+
current_dir = os.path.dirname(os.path.abspath(__file__))
15+
with open(os.path.join(current_dir, '../dependencies.yaml')) as fd:
16+
content = yaml.safe_load(fd)
17+
18+
dev_deps = content.get('development-deps', {})
19+
dev_deps = dev_deps.get('common', []) + dev_deps.get(os_distro, [])
20+
21+
runtime_deps = content.get('runtime-deps', {})
22+
runtime_deps = runtime_deps.get('common', []) + runtime_deps.get(os_distro, [])
23+
24+
if os_distro == 'ubuntu':
25+
pkg_deps = 'Depends: ' + ',\n\t'.join(runtime_deps)
26+
pkg_deps += '\nBuild-Depends: ' + ',\n\t'.join(dev_deps)
27+
28+
elif os_distro in ['fedora', 'opensuse-leap']:
29+
pkg_deps = '\n'.join(['Requires:\t' + d for d in runtime_deps])
30+
pkg_deps += '\n' + '\n'.join(['BuildRequires:\t' + d for d in dev_deps])
31+
32+
else:
33+
raise Exception('Unsupported OS distribution')
34+
35+
with open(f'{current_dir}/{os_distro}-pkg-deps', 'w') as fd:
36+
fd.write(pkg_deps)
37+
38+
with open(f'{current_dir}/../{os_distro}-dev-deps.list', 'w') as fd:
39+
fd.write(DOC_HEADER + '\n'.join(dev_deps))
40+
41+
with open(f'{current_dir}/../{os_distro}-runtime-deps.list', 'w') as fd:
42+
fd.write(DOC_HEADER + '\n'.join(runtime_deps))
43+
44+
45+
if __name__ == '__main__':
46+
for os_distro in ['ubuntu', 'fedora', 'opensuse-leap']:
47+
try:
48+
generate_files(os_distro)
49+
except Exception:
50+
sys.exit(1)
51+
52+
sys.exit(0)

configure.ac

+11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ AC_SUBST([PACKAGE_VERSION],
2525
AC_SUBST([PACKAGE_RELEASE],
2626
[m4_esyscmd([./build-aux/pkg-version --release])])
2727

28+
AC_CONFIG_COMMANDS([generate_deps], [./build-aux/generateDepsFiles.py])
29+
30+
AC_SUBST_FILE([UBUNTU_DEPS])
31+
UBUNTU_DEPS=./build-aux/ubuntu-pkg-deps
32+
33+
AC_SUBST_FILE([FEDORA_DEPS])
34+
FEDORA_DEPS=./build-aux/fedora-pkg-deps
35+
36+
AC_SUBST_FILE([SUSE_DEPS])
37+
SUSE_DEPS=./build-aux/opensuse-leap-pkg-deps
38+
2839
# Testing for version and release
2940
AS_IF([test "x$PACKAGE_VERSION" = x],
3041
AC_MSG_ERROR([package version not defined]))

contrib/DEBIAN/control.in

+2-26
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,6 @@ Version: @PACKAGE_VERSION@
33
Section: base
44
Priority: optional
55
Architecture: all
6-
Depends: wok (>= 2.1.0),
7-
python-imaging | python-pil,
8-
python-configobj,
9-
novnc,
10-
python-jsonschema (>= 1.3.0),
11-
python-libvirt,
12-
gettext,
13-
libvirt-clients,
14-
nfs-common,
15-
qemu-kvm,
16-
python-parted,
17-
python-psutil (>= 0.6.0),
18-
python-ethtool,
19-
sosreport,
20-
python-ipaddr,
21-
python-lxml,
22-
open-iscsi,
23-
python-guestfs,
24-
libguestfs-tools,
25-
spice-html5,
26-
python-magic,
27-
python-paramiko
28-
Build-Depends: xsltproc,
29-
gettext,
30-
python-lxml
31-
Maintainer: Aline Manera <[email protected]>
6+
@UBUNTU_DEPS@
7+
Maintainer: Aline Manera <[email protected]>
328
Description: Kimchi web application

contrib/kimchi.spec.fedora.in

+2-35
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,12 @@ BuildArch: noarch
77
Group: System Environment/Base
88
License: LGPL/ASL2
99
Source0: %{name}-%{version}.tar.gz
10-
Requires: wok >= 2.1.0
11-
Requires: qemu-kvm
12-
Requires: gettext
13-
Requires: libvirt
14-
Requires: libvirt-python
15-
Requires: libvirt-daemon-config-network
16-
Requires: python-configobj
17-
Requires: novnc
18-
Requires: python-pillow
19-
Requires: pyparted
20-
Requires: python-psutil >= 0.6.0
21-
Requires: python-jsonschema >= 1.3.0
22-
Requires: python-ethtool
23-
Requires: sos
24-
Requires: python-ipaddr
25-
Requires: python-lxml
26-
Requires: nfs-utils
27-
Requires: iscsi-initiator-utils
28-
Requires: python-libguestfs
29-
Requires: libguestfs-tools
30-
Requires: python-magic
31-
Requires: python-paramiko
32-
BuildRequires: gettext-devel
33-
BuildRequires: libxslt
34-
BuildRequires: python-lxml
35-
36-
%if 0%{?rhel} >= 6 || 0%{?fedora} >= 19
37-
Requires: spice-html5
38-
%endif
10+
@FEDORA_DEPS@
3911

4012
%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
4113
%global with_systemd 1
4214
%endif
4315

44-
%if 0%{?rhel} == 6
45-
Requires: python-ordereddict
46-
Requires: python-imaging
47-
BuildRequires: python-unittest2
48-
%endif
49-
5016
%description
5117
Web application to manage KVM/Qemu virtual machines
5218

@@ -67,6 +33,7 @@ make
6733
%install
6834
rm -rf %{buildroot}
6935
make DESTDIR=%{buildroot} install
36+
pip3 install -r requirements-FEDORA.tx %{buildroot}
7037

7138

7239
%clean

contrib/kimchi.spec.suse.in

+2-29
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,7 @@ BuildArch: noarch
77
Group: System Environment/Base
88
License: LGPL/ASL2
99
Source0: %{name}-%{version}.tar.gz
10-
Requires: wok >= 2.1.0
11-
Requires: kvm
12-
Requires: gettext-tools
13-
Requires: libvirt
14-
Requires: libvirt-python
15-
Requires: libvirt-daemon-config-network
16-
Requires: python-configobj
17-
Requires: novnc
18-
Requires: python-Pillow
19-
Requires: python-parted
20-
Requires: python-psutil >= 0.6.0
21-
Requires: python-jsonschema >= 1.3.0
22-
Requires: python-ethtool
23-
Requires: python-ipaddr
24-
Requires: python-lxml
25-
Requires: python-xml
26-
Requires: nfs-client
27-
Requires: open-iscsi
28-
Requires: python-libguestfs
29-
Requires: guestfs-tools
30-
Requires: python-magic
31-
Requires: python-paramiko
32-
BuildRequires: gettext-tools
33-
BuildRequires: libxslt-tools
34-
BuildRequires: python-lxml
35-
36-
%if 0%{?suse_version} == 1100
37-
Requires: python-ordereddict
38-
%endif
10+
@SUSE_DEPS@
3911

4012
%if 0%{?suse_version} > 1140
4113
%global with_systemd 1
@@ -54,6 +26,7 @@ make
5426
%install
5527
rm -rf %{buildroot}
5628
make DESTDIR=%{buildroot} install
29+
pip3 install -r requirements-OPENSUSE-LEAP.txt %{buildroot}
5730

5831

5932
%clean

contrib/make-deb.sh.in

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ fi
2929
TMPDIR=`mktemp -d`
3030

3131
make DESTDIR=$TMPDIR install-deb
32+
pip3 install -r requirements-UBUNTU.txt $TMPDIR
3233
dpkg-deb -b $TMPDIR kimchi-${VERSION}-${RELEASE}.noarch.deb
3334
rm -rf $TMPDIR

dependencies.yaml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
development-deps:
2+
common:
3+
- gcc
4+
- make
5+
- autoconf
6+
- automake
7+
- git
8+
- python3-pip
9+
- python3-requests
10+
- python3-mock
11+
ubuntu:
12+
- gettext
13+
- pkgconf
14+
- xsltproc
15+
- python3-dev
16+
- pep8
17+
- pyflakes
18+
- python3-yaml
19+
fedora:
20+
- gettext-devel
21+
- rpm-build
22+
- libxslt
23+
- gcc-c++
24+
- python3-devel
25+
- python2-pep8
26+
- python3-pyflakes
27+
- rpmlint
28+
- python3-pyyaml
29+
opensuse-leap:
30+
- gettext-tools
31+
- rpm-build
32+
- libxslt-tools
33+
- gcc-c++
34+
- python3-devel
35+
- python3-pep8
36+
- python3-pyflakes
37+
- rpmlint
38+
- python3-PyYAML
39+
- python3-distro
40+
41+
runtime-deps:
42+
common:
43+
- python3-configobj
44+
- python3-lxml
45+
- python3-magic
46+
- python3-paramiko
47+
- python3-ldap
48+
- spice-html5
49+
- novnc
50+
- qemu-kvm
51+
ubuntu:
52+
- python3-libvirt
53+
- python3-parted
54+
- python3-guestfs
55+
- python3-pil
56+
- python3-cherrypy3
57+
- python3-pam
58+
-
59+
- libvirt-bin
60+
- nfs-common
61+
- sosreport
62+
- open-iscsi
63+
- libguestfs-tools
64+
fedora:
65+
- python3-libvirt
66+
- python3-pyparted
67+
- python3-ethtool
68+
- python3-pillow
69+
- python3-cherrypy
70+
- python3-pam
71+
- python3-libguestfs
72+
- libvirt
73+
- libvirt-daemon-config-network
74+
- iscsi-initiator-utils
75+
- libguestfs-tools
76+
- sos
77+
- nfs-utils
78+
opensuse-leap:
79+
- python3-libvirt-python
80+
- python-parted
81+
- python3-ethtool
82+
- python3-Pillow
83+
- python3-CherryPy
84+
- python3-python-pam
85+
- python3-ipaddr
86+
- python3-libguestfs
87+
- libvirt
88+
- libvirt-daemon-config-network
89+
- open-iscsi
90+
- guestfs-tools
91+
- nfs-client

docs/Makefile.am

+25
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,29 @@
1919

2020
docdir = $(datadir)/kimchi/doc
2121

22+
all:
23+
@for os_distro in ubuntu fedora opensuse-leap; do \
24+
case $$os_distro in \
25+
ubuntu) \
26+
PKG_MGNT_TOOL="apt install -y"; \
27+
;; \
28+
fedora) \
29+
PKG_MGNT_TOOL="dnf install -y"; \
30+
;; \
31+
opensuse-leap) \
32+
PKG_MGNT_TOOL="zypper install -y"; \
33+
;; \
34+
*) \
35+
PKG_MGNT_TOOL="error"; \
36+
;; \
37+
esac; \
38+
echo $${PKG_MGNT_TOOL}; \
39+
DEV_DEPS=`grep "^[^#;]" ../$${os_distro}-dev-deps.list` ;\
40+
RUNTIME_DEPS=`grep "^[^#;]" ../$${os_distro}-runtime-deps.list` ;\
41+
sed -e "s|[@]DISTRO[@]|$${os_distro^^}|g" \
42+
-e "s|[@]PKG_MGNT_TOOL[@]|$${PKG_MGNT_TOOL}|g" \
43+
-e "s|[@]DEV_DEPS[@]|`echo $${DEV_DEPS}`|g" \
44+
-e "s|[@]RUNTIME_DEPS[@]|`echo $${RUNTIME_DEPS}`|g" deps.md.tmpl > $${os_distro}-deps.md ;\
45+
done
46+
2247
dist_doc_DATA = $(wildcard *.md) $(wildcard *.png) $(NULL)

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ before starting up the wokd service.
3939

4040
* [RHEL/Fedora systems](/docs/fedora-deps.md)
4141
* [Debian/Ubuntu systems](/docs/ubuntu-deps.md)
42-
* [openSUSE systems](/docs/opensuse-deps.md)
42+
* [openSUSE systems](/docs/opensuse-leap-deps.md)
4343

4444
Build and Install
4545
-----------------

docs/deps.md.tmpl

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@DISTRO@ dependencies for Kimchi
2+
================================
3+
4+
* [Build Dependencies](#development-dependencies)
5+
* [Runtime Dependencies](#runtime-dependencies)
6+
7+
Development Dependencies
8+
--------------------
9+
10+
$ sudo -H pip3 install -r requirements-dev.txt
11+
$ sudo @PKG_MGNT_TOOL@ @DEV_DEPS@
12+
13+
Runtime Dependencies
14+
--------------------
15+
16+
$ sudo -H pip3 install -r requirements-@[email protected]
17+
$ sudo @PKG_MGNT_TOOL@ @RUNTIME_DEPS@

0 commit comments

Comments
 (0)