Add systemd socket support
[platform/core/security/vasum.git] / packaging / vasum.spec
1 %define script_dir %{_sbindir}
2 # Vasum Server's user info - it should already exist in the system
3 %define vsm_user          security-containers
4 # The group that has read and write access to /dev/input/event* devices.
5 # It may vary between platforms.
6 %define input_event_group input
7 # The group has access to /dev/loop* devices.
8 %define disk_group disk
9 # The group that has write access to /dev/tty* devices.
10 %define tty_group tty
11
12 Name:           vasum
13 Version:        0.1.1
14 Release:        0
15 Source0:        %{name}-%{version}.tar.gz
16 License:        Apache-2.0
17 Group:          Security/Other
18 Summary:        Daemon for managing zones
19 BuildRequires:  cmake
20 BuildRequires:  boost-devel
21 BuildRequires:  libjson-devel >= 0.10
22 BuildRequires:  libcap-ng-devel
23 BuildRequires:  lxc-devel
24 BuildRequires:  pkgconfig(libConfig)
25 BuildRequires:  pkgconfig(libLogger)
26 BuildRequires:  pkgconfig(libSimpleDbus)
27 BuildRequires:  pkgconfig(glib-2.0)
28 BuildRequires:  pkgconfig(libsystemd-journal)
29 BuildRequires:  pkgconfig(libsystemd-daemon)
30 BuildRequires:  pkgconfig(sqlite3)
31 Requires(post): libcap-tools
32 Requires:       bridge-utils
33
34 %description
35 This package provides a daemon used to manage zones - start, stop and switch
36 between them. A process from inside a zone can request a switch of context
37 (display, input devices) to the other zone.
38
39 %files
40 %manifest packaging/vasum.manifest
41 %defattr(644,root,root,755)
42 %attr(755,root,root) %{_bindir}/vasum-server
43 %dir /etc/vasum
44 %dir /etc/vasum/zones
45 %dir /etc/vasum/lxc-templates
46 %dir /etc/vasum/templates
47 %config /etc/vasum/daemon.conf
48 %attr(755,root,root) /etc/vasum/lxc-templates/*.sh
49 %config /etc/vasum/templates/*.conf
50 %{_unitdir}/vasum.service
51 %{_unitdir}/vasum.socket
52 %{_unitdir}/multi-user.target.wants/vasum.service
53 /etc/dbus-1/system.d/org.tizen.vasum.host.conf
54 %dir %{_datadir}/.zones
55
56 %prep
57 %setup -q
58
59 %build
60 %{!?build_type:%define build_type "RELEASE"}
61
62 %if %{build_type} == "DEBUG" || %{build_type} == "PROFILING"
63     CFLAGS="$CFLAGS -Wp,-U_FORTIFY_SOURCE"
64     CXXFLAGS="$CXXFLAGS -Wp,-U_FORTIFY_SOURCE"
65 %endif
66
67 %cmake . -DVERSION=%{version} \
68          -DCMAKE_BUILD_TYPE=%{build_type} \
69          -DSCRIPT_INSTALL_DIR=%{script_dir} \
70          -DSYSTEMD_UNIT_DIR=%{_unitdir} \
71          -DDATA_DIR=%{_datadir} \
72          -DPYTHON_SITELIB=%{python_sitelib} \
73          -DVASUM_USER=%{vsm_user} \
74          -DINPUT_EVENT_GROUP=%{input_event_group} \
75          -DDISK_GROUP=%{disk_group} \
76          -DTTY_GROUP=%{tty_group}
77 make -k %{?jobs:-j%jobs}
78
79 %install
80 %make_install
81 mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants
82 ln -s ../vasum.service %{buildroot}/%{_unitdir}/multi-user.target.wants/vasum.service
83 mkdir -p %{buildroot}/%{_datadir}/.zones
84
85 %clean
86 rm -rf %{buildroot}
87
88 %post
89 # Refresh systemd services list after installation
90 if [ $1 == 1 ]; then
91     systemctl daemon-reload || :
92 fi
93 # set needed caps on the binary to allow restart without loosing them
94 setcap CAP_SYS_ADMIN,CAP_MAC_OVERRIDE,CAP_SYS_TTY_CONFIG+ei %{_bindir}/vasum-server
95
96 %preun
97 # Stop the service before uninstall
98 if [ $1 == 0 ]; then
99      systemctl stop vasum.service || :
100 fi
101
102 %postun
103 # Refresh systemd services list after uninstall/upgrade
104 systemctl daemon-reload || :
105 if [ $1 -ge 1 ]; then
106     # TODO: at this point an appropriate notification should show up
107     eval `systemctl show vasum --property=MainPID`
108     if [ -n "$MainPID" -a "$MainPID" != "0" ]; then
109         kill -USR1 $MainPID
110     fi
111     echo "Vasum updated. Reboot is required for the changes to take effect..."
112 else
113     echo "Vasum removed. Reboot is required for the changes to take effect..."
114 fi
115
116 ## Client Package ##############################################################
117 %package client
118 Summary:          Vasum Client
119 Group:            Development/Libraries
120 Requires:         vasum = %{version}-%{release}
121 Requires(post):   /sbin/ldconfig
122 Requires(postun): /sbin/ldconfig
123
124 %description client
125 Library interface to the vasum daemon
126
127 %files client
128 %manifest packaging/libvasum-client.manifest
129 %defattr(644,root,root,755)
130 %attr(755,root,root) %{_libdir}/libvasum.so.0.0.1
131 %{_libdir}/libvasum.so.0
132
133 %post client -p /sbin/ldconfig
134
135 %postun client -p /sbin/ldconfig
136
137
138 ## Devel Package ###############################################################
139 %package devel
140 Summary:          Vasum Client Devel
141 Group:            Development/Libraries
142 Requires:         vasum = %{version}-%{release}
143 Requires:         vasum-client = %{version}-%{release}
144
145 %description devel
146 Development package including the header files for the client library
147
148 %files devel
149 %manifest packaging/vasum.manifest
150 %defattr(644,root,root,755)
151 %{_libdir}/libvasum.so
152 %{_includedir}/vasum
153 %{_libdir}/pkgconfig/*.pc
154
155
156 ## Zone Support Package ###################################################
157 # TODO move to a separate repository
158 %package zone-support
159 Summary:          Vasum Support
160 Group:            Security/Other
161
162 %description zone-support
163 Zones support installed inside every zone.
164
165 %files zone-support
166 %manifest packaging/vasum-zone-support.manifest
167 %defattr(644,root,root,755)
168 /etc/dbus-1/system.d/org.tizen.vasum.zone.conf
169
170
171 ## Zone Daemon Package ####################################################
172 # TODO move to a separate repository
173 %package zone-daemon
174 Summary:          Vasum Zones Daemon
175 Group:            Security/Other
176 Requires:         vasum-zone-support = %{version}-%{release}
177
178 %description zone-daemon
179 Daemon running inside every zone.
180
181 %files zone-daemon
182 %manifest packaging/vasum-zone-daemon.manifest
183 %defattr(644,root,root,755)
184 %attr(755,root,root) %{_bindir}/vasum-zone-daemon
185 /etc/dbus-1/system.d/org.tizen.vasum.zone.daemon.conf
186
187
188 ## Command Line Interface ######################################################
189 %package cli
190 Summary:          Vasum Command Line Interface
191 Group:            Security/Other
192 Requires:         vasum-client = %{version}-%{release}
193
194 %description cli
195 Command Line Interface for vasum.
196
197 %files cli
198 %defattr(644,root,root,755)
199 %attr(755,root,root) %{_bindir}/vasum-cli
200
201
202 ## Test Package ################################################################
203 %package tests
204 Summary:          Vasum Tests
205 Group:            Development/Libraries
206 Requires:         vasum = %{version}-%{release}
207 Requires:         vasum-client = %{version}-%{release}
208 Requires:         python
209 Requires:         python-xml
210 Requires:         boost-test
211
212 %description tests
213 Unit tests for both: server and client and integration tests.
214
215 %post tests
216 systemctl daemon-reload
217 systemctl enable vasum-socket-test.socket
218 systemctl start vasum-socket-test.socket
219
220 %preun tests
221 systemctl stop vasum-socket-test.socket
222 systemctl disable vasum-socket-test.socket
223
224 %postun tests
225 systemctl daemon-reload
226
227 %files tests
228 %manifest packaging/vasum-server-tests.manifest
229 %defattr(644,root,root,755)
230 %attr(755,root,root) %{_bindir}/vasum-server-unit-tests
231 %attr(755,root,root) %{_bindir}/vasum-socket-test
232 %attr(755,root,root) %{script_dir}/vsm_all_tests.py
233 %attr(755,root,root) %{script_dir}/vsm_int_tests.py
234 %attr(755,root,root) %{script_dir}/vsm_launch_test.py
235 %{script_dir}/vsm_test_parser.py
236 %{_datadir}/vasum/tests
237 %attr(755,root,root) %{_datadir}/vasum/lxc-templates
238 %{python_sitelib}/vsm_integration_tests
239 /etc/dbus-1/system.d/org.tizen.vasum.tests.conf
240 %{_unitdir}/vasum-socket-test.socket
241 %{_unitdir}/vasum-socket-test.service