-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathhelpers.spec
100 lines (86 loc) · 3.23 KB
/
helpers.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
100
# !!! Following list of variables must be defined before this file is included.
# - package
# Cat debian/package.dirs, set buildroot prefix and create directories.
%define debian_dirs cat debian/%{name}.dirs | grep -v '^\\s*#' | sed 's~^~%{buildroot}/~' | \
while read dir_path; do \
mkdir -p "${dir_path}" \
done \
%{nil}
# Cat debian/package.links, set buildroot prefix and create symlinks.
%define debian_links cat debian/%{name}.links | grep -v '^\\s*#' | \
sed -r -e 's~\\b~/~' -e 's~\\s+\\b~ %{buildroot}/~' | \
while read link_rule; do \
linkpath=$(echo "$link_rule" | cut -f2 -d' ') && [ -d $(dirname "$linkpath") ] || \
mkdir -p $(dirname "$linkpath") && ln -s $link_rule \
done \
%{nil}
# Cat debian/install, set buildroot prefix and copy files.
%define debian_install cat debian/install | grep -v '^\s*#' | sed -r 's~ +~ %{buildroot}/~' | \
while read copy_rule; do \
parent=$(echo "$copy_rule" | cut -f2 -d' ') \
[ -d "$parent" ] || install -d "$parent" && cp -r $copy_rule \
done \
%{nil}
# We hate duplication right :)?, so let's use debian files
%define default_install \
%debian_dirs \
%debian_install \
%debian_links \
%make_install \
%{nil}
## Clean up RECORD and some other files left by python, which may contain
# absolute buildroot paths.
%define cleanup_python_abspath \
find %{buildroot} -name RECORD -o -name '*.egg-link' -o -name '*.pth' | \
xargs -I{} -n1 sed -i 's@%{buildroot}@@' {} \
%{nil}
#Cleanup .so files that contain buildroot
%define cleanup_so_abspath \
for f in `find %{venv_dir}/lib -type f -name "*.so" | \
xargs grep -l %{buildroot} `; do strip $f; done \
%{nil}
# Define use_systemd to know if we on a systemd system
#
%if 0%{?_unitdir:1}
%define use_systemd 1
%endif
## St2 package version parsing
# if package name starts with st2 then it's st2 component.
#
%if %(PKG=%{package}; [ "${PKG##st2}" != "$PKG" ] && echo 1 || echo 0 ) == 1
%define st2pkg_version %(python3 -c "from %{package} import __version__; print(__version__),")
%endif # st2 package version parsing
# Redefine and to drop python brp bytecompile
#
%define __os_install_post() \
/usr/lib/rpm/brp-compress \
%{!?__debug_package:/usr/lib/rpm/brp-strip %{__strip}} \
/usr/lib/rpm/brp-strip-static-archive %{__strip} \
/usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump} \
%{nil}
# Install systemd service into the package
#
%define service_install() \
for svc in %{?*}; do \
install -D -p -m0644 %{SOURCE0}/rpm/$svc.service %{buildroot}%{_unitdir}/$svc.service \
[ -f %{SOURCE0}/rpm/$svc.socket ] && install -D -p -m0644 %{SOURCE0}/rpm/$svc.socket %{buildroot}%{_unitdir}/$svc.socket \
done \
%{nil}
# Service post stage action
# enables used to enforce the policy, which seems to be disabled by default
#
%define service_post() \
%{expand: %systemd_post %%{?*}} \
systemctl --no-reload enable %{?*} >/dev/null 2>&1 || : \
%{nil}
# Service preun stage action
#
%define service_preun() \
%{expand: %systemd_preun %%{?*}} \
%{nil}
# Service postun stage action
# ($1 > 1 on package upgrade)
#
%define service_postun() \
%{expand: %systemd_postun_with_restart %%{?*}} \
%{nil}