-
Notifications
You must be signed in to change notification settings - Fork 13
/
ovirt-node-ng.spec.in
184 lines (148 loc) · 4.99 KB
/
ovirt-node-ng.spec.in
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
%global _product_name oVirt Node Next
%global _product_id ovirt-node-ng
%global _node_image_dir /usr/share/%{name}/image/
%global _node_image_file %{_node_image_dir}/%{name}-@PLACEHOLDER_RPM_VERSION@-@PLACEHOLDER_RPM_RELEASE@.squashfs.img
%global _node_tools_dir /usr/share/%{name}/tools/
%global with_image @WITH_IMAGE@
# Hardcode the dist to el7, because this is what the image contains
# This is also hardcoded, because currently the el7 rpms are built
# on F22 builders. Thus the dist would be wrong.
%global dist .el7
%global with_docs @DOCS@
%global with_tools @TOOLS@
# Disable compression, because the image is already compressed
%define _source_payload w0.gzdio
%define _binary_payload w0.gzdio
Name: %{_product_id}
Version: @PACKAGE_RPM_VERSION@
Release: @PACKAGE_RPM_RELEASE@%{?dist}%{?extra_release}
License: GPLv2
Summary: %{_product_name}
URL: http://www.ovirt.org/node/
Source0: %{name}-@PACKAGE_VERSION@.tar.gz
%if 0%{?with_image}
Source1: @IMAGENAME@.squashfs.img
Source2: product.img
%endif
BuildArch: noarch
BuildRequires: autoconf
BuildRequires: automake
%description
This package provides some tooling around building %{_product_name}.
Currently the main package is empty.
%if 0%{?with_image}
# IMPORTANT
# The image and image-updat version and release are inherited
# from the ovirt-node-ng-image-update-placeholder package
# There is a lot of fu to support this.
%package image-update
Summary: %{_product_name} Image Update
Version: @PLACEHOLDER_RPM_VERSION@
Release: @PLACEHOLDER_RPM_RELEASE@
Requires: imgbased >= 0.7.2
Obsoletes: %{_product_id}-image-update-placeholder < %{version}-%{release}
Provides: %{_product_id}-image-update-placeholder = %{version}-%{release}
Obsoletes: %{_product_id}-image < %{version}-%{release}
Provides: %{_product_id}-image = %{version}-%{release}
%description image-update
This package will update an %{_product_name} host with the new image.
%endif
%if 0%{?with_docs}
%package docs
Summary: Documentation for %{_product_name}
%description docs
Subpackage for docs related to %{_product_name}
%endif
%if 0%{?with_tools}
%package tools
Summary: Tools for %{_product_name}
%description tools
Subpackage for tools related to %{_product_name}
%endif
%package nodectl
Summary: nodectl for %{name}
Requires: imgbased
%description nodectl
Subpackage for nodectl for %{name}
%prep
%setup -q -n %{name}-@PACKAGE_VERSION@
%build
%configure
make %{?_smp_mflags}
%install
install -Dm 0755 scripts/nodectl-motd.sh %{buildroot}%{_sysconfdir}/profile.d/nodectl-motd.sh
install -Dm 0755 scripts/nodectl-run-banner.sh %{buildroot}%{_sysconfdir}/profile.d/nodectl-run-banner.sh
%make_install
%if 0%{?with_image}
# Install the image
/usr/bin/install -d %{buildroot}/%{_node_image_dir}
/usr/bin/install -m 644 %{SOURCE1} %{buildroot}/%{_node_image_file}
/usr/bin/install -m 644 %{SOURCE2} %{buildroot}/%{_node_image_dir}/product.img
%pre image-update
local_sds=($(find / -xdev -name "__DIRECT_IO_TEST__"))
if [ "$local_sds" ]; then
echo "Local storage domains were found on the same filesystem as / ! Please migrate the data to a new LV before upgrading, or you will lose the VMs"
echo "See: https://bugzilla.redhat.com/show_bug.cgi?id=1550205#c3"
echo "Storage domains were found in:"
for sd in "${local_sds[@]}"; do
echo -e "\t$(dirname $sd)"
done
exit 1
fi
%post image-update
set -e
# Some magic to ensure that imgbase from
# the new image is used for updates
export MNTDIR="$(mktemp -d)"
mount "%{_node_image_file}" "$MNTDIR"
mount "$MNTDIR"/LiveOS/rootfs.img "$MNTDIR"
export PYTHONPATH="$MNTDIR"/usr/lib/python2.7/site-packages/:$PYTHONPATH
imgbase --debug update --format liveimg %{_node_image_file} >> /tmp/imgbased.log 2>&1
VOL=$(imgbase layer --volume-path $(imgbase layer --latest))
umount "$MNTDIR"
umount "$MNTDIR"
UPDATERPM="/tmp/updaterpm.path"
lsof | grep image-update | awk '{print $9}' > $UPDATERPM
UPDATELOG="/tmp/image-update.log"
echo "List of open files:" > $UPDATELOG
lsof > $UPDATELOG
mount "$VOL" "$MNTDIR"
rpm -Uvh --quiet --justdb --root "${MNTDIR}" $(cat ${UPDATERPM}) > /dev/null 2>&1
RC=$?
umount "${MNTDIR}"
rm "${UPDATERPM}"
[ $RC = 0 ] && rm "${UPDATELOG}"
rmdir "${MNTDIR}"
%files image-update
%dir %{_node_image_dir}
%{_node_image_file}
%{_node_image_dir}/product.img
%endif
%files nodectl
%{_mandir}/man8/nodectl.8.gz
%{_sysconfdir}/profile.d/nodectl-motd.sh
%{_sysconfdir}/profile.d/nodectl-run-banner.sh
%{_sbindir}/nodectl
%{python_sitelib}/nodectl
%if 0%{?with_docs}
%files docs
%{_docdir}/%{name}/*
%else
%exclude %{_docdir}/%{name}/*
%endif
%if 0%{?with_tools}
%files tools
%dir %{_node_tools_dir}
%{_node_tools_dir}/*
%{_bindir}/create-node-installation-iso
%else
%exclude %{_node_tools_dir}/*
%exclude %{_bindir}/create-node-installation-iso
%endif
%changelog
* Wed Sep 7 2016 Ryan Barry <rbarry@redhat.com>
- Rename nodectl to ovirt-node-ng-nodectl
* Sat Jul 9 2016 Ryan Barry <rbarry@redhat.com>
- Add nodectl
* Mon Jan 25 2016 Douglas Schilling Landgraf <dougsland@redhat.com>
- Initial build