Change zonesPath and ExecStart command in service
[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 %config /etc/vasum/zones/*.conf
49 %attr(755,root,root) /etc/vasum/lxc-templates/*.sh
50 %config /etc/vasum/templates/*.conf
51 %{_unitdir}/vasum.service
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 Conflicts:        vasum
162
163 %description zone-support
164 Zones support installed inside every zone.
165
166 %files zone-support
167 %manifest packaging/vasum-zone-support.manifest
168 %defattr(644,root,root,755)
169 /etc/dbus-1/system.d/org.tizen.vasum.zone.conf
170
171
172 ## Zone Daemon Package ####################################################
173 # TODO move to a separate repository
174 %package zone-daemon
175 Summary:          Vasum Zones Daemon
176 Group:            Security/Other
177 Requires:         vasum-zone-support = %{version}-%{release}
178
179 %description zone-daemon
180 Daemon running inside every zone.
181
182 %files zone-daemon
183 %manifest packaging/vasum-zone-daemon.manifest
184 %defattr(644,root,root,755)
185 %attr(755,root,root) %{_bindir}/vasum-zone-daemon
186 /etc/dbus-1/system.d/org.tizen.vasum.zone.daemon.conf
187
188
189 ## Command Line Interface ######################################################
190 %package cli
191 Summary:          Vasum Command Line Interface
192 Group:            Security/Other
193 Requires:         vasum-client = %{version}-%{release}
194
195 %description cli
196 Command Line Interface for vasum.
197
198 %files cli
199 %defattr(644,root,root,755)
200 %attr(755,root,root) %{_bindir}/vasum-cli
201
202
203 ## Test Package ################################################################
204 %package tests
205 Summary:          Vasum Tests
206 Group:            Development/Libraries
207 Requires:         vasum = %{version}-%{release}
208 Requires:         vasum-client = %{version}-%{release}
209 Requires:         python
210 Requires:         python-xml
211 Requires:         boost-test
212
213 %description tests
214 Unit tests for both: server and client and integration tests.
215
216 %files tests
217 %manifest packaging/vasum-server-tests.manifest
218 %defattr(644,root,root,755)
219 %attr(755,root,root) %{_bindir}/vasum-server-unit-tests
220 %attr(755,root,root) %{script_dir}/vsm_all_tests.py
221 %attr(755,root,root) %{script_dir}/vsm_int_tests.py
222 %attr(755,root,root) %{script_dir}/vsm_launch_test.py
223 %{script_dir}/vsm_test_parser.py
224 %{_datadir}/vasum/tests
225 %attr(755,root,root) %{_datadir}/vasum/lxc-templates
226 %{python_sitelib}/vsm_integration_tests
227 /etc/dbus-1/system.d/org.tizen.vasum.tests.conf