-
Notifications
You must be signed in to change notification settings - Fork 0
/
inmanta.spec
99 lines (77 loc) · 3.01 KB
/
inmanta.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Use release 0 for prerelease version.
%define release 1
%define version 1.0.0
%define buildid %{nil}
%define buildid_egg %{nil}
%define venv inmanta-venv
%define _p3 %{venv}/bin/python3
%define site_packages_dir %{venv}/lib/python3.6/site-packages
%define _unique_build_ids 0
%define _debugsource_packages 0
%define _debuginfo_subpackages 0
%define _enable_debug_packages 0
%define debug_package %{nil}
%define sourceversion %{version}%{?buildid}
%define sourceversion_egg %{version}%{?buildid_egg}
Name: python3-inmanta-ui
Version: %{version}
Release: %{release}%{?buildid}%{?tag}%{?dist}
Summary: Inmanta User Interface extension
Group: Development/Languages
License: EULA
URL: http://inmanta.com
Source0: inmanta-ui-%{sourceversion_egg}.tar.gz
Source1: deps-%{sourceversion}.tar.gz
Source2: inmanta-web-console-%{web_console_version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: python3-inmanta
BuildRequires: systemd
BuildRequires: nodejs
Requires: python3-inmanta
# Use the correct python for bycompiling
%define __python %{_p3}
%description
%prep
%setup -q -n inmanta-ui-%{sourceversion_egg}
%setup -T -D -a 1 -n inmanta-ui-%{sourceversion_egg}
%build
%install
# Copy the inmanta venv to BUILD directory to work around ownership issue
cp -r --no-preserve=ownership /opt/inmanta %{venv}
chmod -x LICENSE
# Save packages installed by python3-inmanta
files=$(find %{site_packages_dir} -maxdepth 1 -mindepth 1 ! -path %{site_packages_dir}/inmanta_ext)
# Install inmanta-ui
%{_p3} -m pip install --pre --no-index --find-links dependencies .
# Only keep new packages
rm -rf ${files}
# Remove inmanta_ext/core separately, to retain inmanta_ext/ui
find "%{site_packages_dir}/inmanta_ext" -maxdepth 1 -mindepth 1 ! -path "%{site_packages_dir}/inmanta_ext/ui" |xargs rm -rf
# Byte-compile source code
packages_to_bytecompile=("inmanta_ui" "inmanta_ext")
for p in "${packages_to_bytecompile[@]}"; do
find "%{site_packages_dir}/${p}" -name '*.py' |xargs -I file_name python3.6 -c 'import py_compile; py_compile.compile(file="file_name", cfile="file_namec", doraise=True)'
find "%{site_packages_dir}/${p}" -name '*.py' |xargs rm -f
find "%{site_packages_dir}/${p}" -name '__pycache__' |xargs rm -rf
done
mkdir -p %{buildroot}/opt/inmanta/
cp -r %{venv}/lib/ %{buildroot}/opt/inmanta/
# Install web-console
mkdir -p %{buildroot}/usr/share/inmanta/web-console
tar -xf %{SOURCE2} --strip-components=2 --directory %{buildroot}/usr/share/inmanta/web-console
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%doc LICENSE
/opt/inmanta/lib/
/usr/share/inmanta/web-console
%preun
# Stop and disable the inmanta-server service before this package is uninstalled
%systemd_preun inmanta-server.service
%postun
# Restart the inmanta-server service after an upgrade of this package
%systemd_postun_with_restart inmanta-server.service
%changelog
* Tue Dec 03 2019 Andras Kovari <andras.kovari@inmanta.com> - 0.1
- Initial release