Rename security containers to vasum
[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 containers
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 containers - start, stop and switch
36 between them. A process from inside a container can request a switch of context
37 (display, input devices) to the other container.
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/containers
45 %dir /etc/vasum/lxc-templates
46 %dir /etc/vasum/templates
47 %config /etc/vasum/daemon.conf
48 %config /etc/vasum/containers/*.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.containers.host.conf
54
55 %prep
56 %setup -q
57
58 %build
59 %{!?build_type:%define build_type "RELEASE"}
60
61 %if %{build_type} == "DEBUG" || %{build_type} == "PROFILING"
62     CFLAGS="$CFLAGS -Wp,-U_FORTIFY_SOURCE"
63     CXXFLAGS="$CXXFLAGS -Wp,-U_FORTIFY_SOURCE"
64 %endif
65
66 %cmake . -DVERSION=%{version} \
67          -DCMAKE_BUILD_TYPE=%{build_type} \
68          -DSCRIPT_INSTALL_DIR=%{script_dir} \
69          -DSYSTEMD_UNIT_DIR=%{_unitdir} \
70          -DPYTHON_SITELIB=%{python_sitelib} \
71          -DVASUM_USER=%{vsm_user} \
72          -DINPUT_EVENT_GROUP=%{input_event_group} \
73          -DDISK_GROUP=%{disk_group} \
74          -DTTY_GROUP=%{tty_group}
75 make -k %{?jobs:-j%jobs}
76
77 %install
78 %make_install
79 mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants
80 ln -s ../vasum.service %{buildroot}/%{_unitdir}/multi-user.target.wants/vasum.service
81
82 %clean
83 rm -rf %{buildroot}
84
85 %post
86 # Refresh systemd services list after installation
87 if [ $1 == 1 ]; then
88     systemctl daemon-reload || :
89 fi
90 # set needed caps on the binary to allow restart without loosing them
91 setcap CAP_SYS_ADMIN,CAP_MAC_OVERRIDE,CAP_SYS_TTY_CONFIG+ei %{_bindir}/vasum-server
92
93 %preun
94 # Stop the service before uninstall
95 if [ $1 == 0 ]; then
96      systemctl stop vasum.service || :
97 fi
98
99 %postun
100 # Refresh systemd services list after uninstall/upgrade
101 systemctl daemon-reload || :
102 if [ $1 -ge 1 ]; then
103     # TODO: at this point an appropriate notification should show up
104     eval `systemctl show vasum --property=MainPID`
105     if [ -n "$MainPID" -a "$MainPID" != "0" ]; then
106         kill -USR1 $MainPID
107     fi
108     echo "Vasum updated. Reboot is required for the changes to take effect..."
109 else
110     echo "Vasum removed. Reboot is required for the changes to take effect..."
111 fi
112
113 ## Client Package ##############################################################
114 %package client
115 Summary:          Vasum Client
116 Group:            Development/Libraries
117 Requires:         vasum = %{version}-%{release}
118 Requires(post):   /sbin/ldconfig
119 Requires(postun): /sbin/ldconfig
120
121 %description client
122 Library interface to the vasum daemon
123
124 %files client
125 %manifest packaging/libvasum-client.manifest
126 %defattr(644,root,root,755)
127 %attr(755,root,root) %{_libdir}/libvasum.so.0.0.1
128 %{_libdir}/libvasum.so.0
129
130 %post client -p /sbin/ldconfig
131
132 %postun client -p /sbin/ldconfig
133
134
135 ## Devel Package ###############################################################
136 %package devel
137 Summary:          Vasum Client Devel
138 Group:            Development/Libraries
139 Requires:         vasum = %{version}-%{release}
140 Requires:         vasum-client = %{version}-%{release}
141
142 %description devel
143 Development package including the header files for the client library
144
145 %files devel
146 %manifest packaging/vasum.manifest
147 %defattr(644,root,root,755)
148 %{_libdir}/libvasum.so
149 %{_includedir}/vasum
150 %{_libdir}/pkgconfig/*.pc
151
152
153 ## Container Support Package ###################################################
154 # TODO move to a separate repository
155 %package container-support
156 Summary:          Vasum Support
157 Group:            Security/Other
158 Conflicts:        vasum
159
160 %description container-support
161 Containers support installed inside every container.
162
163 %files container-support
164 %manifest packaging/vasum-container-support.manifest
165 %defattr(644,root,root,755)
166 /etc/dbus-1/system.d/org.tizen.containers.zone.conf
167
168
169 ## Container Daemon Package ####################################################
170 # TODO move to a separate repository
171 %package container-daemon
172 Summary:          Vasum Containers Daemon
173 Group:            Security/Other
174 Requires:         vasum-container-support = %{version}-%{release}
175
176 %description container-daemon
177 Daemon running inside every container.
178
179 %files container-daemon
180 %manifest packaging/vasum-container-daemon.manifest
181 %defattr(644,root,root,755)
182 %attr(755,root,root) %{_bindir}/vasum-container-daemon
183 /etc/dbus-1/system.d/org.tizen.containers.zone.daemon.conf
184
185
186 ## Command Line Interface ######################################################
187 %package cli
188 Summary:          Vasum Command Line Interface
189 Group:            Security/Other
190 Requires:         vasum-client = %{version}-%{release}
191
192 %description cli
193 Command Line Interface for vasum.
194
195 %files cli
196 %defattr(644,root,root,755)
197 %attr(755,root,root) %{_bindir}/vasum-cli
198
199
200 ## Test Package ################################################################
201 %package tests
202 Summary:          Vasum Tests
203 Group:            Development/Libraries
204 Requires:         vasum = %{version}-%{release}
205 Requires:         vasum-client = %{version}-%{release}
206 Requires:         python
207 Requires:         python-xml
208 Requires:         boost-test
209
210 %description tests
211 Unit tests for both: server and client and integration tests.
212
213 %files tests
214 %manifest packaging/vasum-server-tests.manifest
215 %defattr(644,root,root,755)
216 %attr(755,root,root) %{_bindir}/vasum-server-unit-tests
217 %attr(755,root,root) %{script_dir}/vsm_all_tests.py
218 %attr(755,root,root) %{script_dir}/vsm_int_tests.py
219 %attr(755,root,root) %{script_dir}/vsm_launch_test.py
220 %{script_dir}/vsm_test_parser.py
221 %{_datadir}/vasum/tests
222 %attr(755,root,root) %{_datadir}/vasum/lxc-templates
223 %{python_sitelib}/vsm_integration_tests
224 /etc/dbus-1/system.d/org.tizen.containers.tests.conf