core-dom0.spec 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. #
  2. # This is the SPEC file for creating binary RPMs for the Dom0.
  3. #
  4. #
  5. # The Qubes OS Project, http://www.qubes-os.org
  6. #
  7. # Copyright (C) 2010 Joanna Rutkowska <joanna@invisiblethingslab.com>
  8. # Copyright (C) 2010 Rafal Wojtczuk <rafal@invisiblethingslab.com>
  9. #
  10. # This program is free software; you can redistribute it and/or
  11. # modify it under the terms of the GNU General Public License
  12. # as published by the Free Software Foundation; either version 2
  13. # of the License, or (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program; if not, write to the Free Software
  22. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  23. #
  24. #
  25. %{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
  26. %{!?version: %define version %(cat version)}
  27. %define _dracutmoddir /usr/lib/dracut/modules.d
  28. %if %{fedora} < 17
  29. %define _dracutmoddir /usr/share/dracut/modules.d
  30. %endif
  31. Name: qubes-core-dom0
  32. Version: %{version}
  33. Release: 1%{dist}
  34. Summary: The Qubes core files (Dom0-side)
  35. Group: Qubes
  36. Vendor: Invisible Things Lab
  37. License: GPL
  38. URL: http://www.qubes-os.org
  39. BuildRequires: ImageMagick
  40. BuildRequires: systemd-units
  41. Requires(post): systemd-units
  42. Requires(preun): systemd-units
  43. Requires(postun): systemd-units
  44. Requires: python, xen-runtime, pciutils, python-inotify, python-daemon
  45. Requires: qubes-core-dom0-linux >= 2.0.24
  46. Requires: python-lxml
  47. Requires: python-psutil
  48. # TODO: R: qubes-gui-dom0 >= 2.1.11
  49. Conflicts: qubes-gui-dom0 < 1.1.13
  50. Requires: libvirt-python
  51. %if x%{?backend_vmm} == xxen
  52. Requires: xen-hvm
  53. Requires: libvirt-daemon-driver-libxl
  54. %endif
  55. Requires: createrepo
  56. Requires: gnome-packagekit
  57. Requires: cronie
  58. # for qubes-hcl-report
  59. Requires: dmidecode
  60. # Prevent preupgrade from installation (it pretend to provide distribution upgrade)
  61. Obsoletes: preupgrade < 2.0
  62. Provides: preupgrade = 2.0
  63. %define _builddir %(pwd)
  64. %description
  65. The Qubes core files for installation on Dom0.
  66. %prep
  67. # we operate on the current directory, so no need to unpack anything
  68. # symlink is to generate useful debuginfo packages
  69. rm -f %{name}-%{version}
  70. ln -sf . %{name}-%{version}
  71. %setup -T -D
  72. %build
  73. python -m compileall core core-modules qmemman tests
  74. python -O -m compileall core dom/core-modules qmemman tests
  75. for dir in dispvm qmemman; do
  76. (cd $dir; make)
  77. done
  78. %install
  79. mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
  80. cp linux/systemd/qubes-block-cleaner.service $RPM_BUILD_ROOT%{_unitdir}
  81. cp linux/systemd/qubes-core.service $RPM_BUILD_ROOT%{_unitdir}
  82. cp linux/systemd/qubes-setupdvm.service $RPM_BUILD_ROOT%{_unitdir}
  83. cp linux/systemd/qubes-netvm.service $RPM_BUILD_ROOT%{_unitdir}
  84. cp linux/systemd/qubes-qmemman.service $RPM_BUILD_ROOT%{_unitdir}
  85. cp linux/systemd/qubes-vm@.service $RPM_BUILD_ROOT%{_unitdir}
  86. cp linux/systemd/qubes-reload-firewall@.service $RPM_BUILD_ROOT%{_unitdir}
  87. cp linux/systemd/qubes-reload-firewall@.timer $RPM_BUILD_ROOT%{_unitdir}
  88. mkdir -p $RPM_BUILD_ROOT/usr/bin/
  89. cp qvm-tools/qvm-* $RPM_BUILD_ROOT/usr/bin
  90. cp qvm-tools/qubes-* $RPM_BUILD_ROOT/usr/bin
  91. mkdir -p $RPM_BUILD_ROOT/etc/xen/scripts
  92. cp dispvm/block.qubes $RPM_BUILD_ROOT/etc/xen/scripts
  93. cp linux/system-config/vif-route-qubes $RPM_BUILD_ROOT/etc/xen/scripts
  94. cp linux/system-config/block-snapshot $RPM_BUILD_ROOT/etc/xen/scripts
  95. ln -s block-snapshot $RPM_BUILD_ROOT/etc/xen/scripts/block-origin
  96. mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes
  97. cp core/qubes.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  98. cp core/qubes.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  99. cp core/qubesutils.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  100. cp core/qubesutils.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  101. cp core/guihelpers.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  102. cp core/guihelpers.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  103. cp core/notify.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  104. cp core/notify.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  105. cp core/backup.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  106. cp core/backup.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  107. cp qmemman/qmemman*py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  108. cp qmemman/qmemman*py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  109. mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  110. cp core-modules/0*.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  111. cp core-modules/0*.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  112. cp core-modules/__init__.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  113. cp core-modules/__init__.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  114. mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes/tests
  115. cp tests/*.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/tests/
  116. cp tests/*.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/tests/
  117. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/qubes
  118. cp qmemman/qmemman.conf $RPM_BUILD_ROOT%{_sysconfdir}/qubes/
  119. mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
  120. cp linux/aux-tools/unbind-pci-device.sh $RPM_BUILD_ROOT/usr/lib/qubes
  121. cp linux/aux-tools/cleanup-dispvms $RPM_BUILD_ROOT/usr/lib/qubes
  122. cp linux/aux-tools/startup-dvm.sh $RPM_BUILD_ROOT/usr/lib/qubes
  123. cp linux/aux-tools/startup-misc.sh $RPM_BUILD_ROOT/usr/lib/qubes
  124. cp linux/aux-tools/prepare-volatile-img.sh $RPM_BUILD_ROOT/usr/lib/qubes
  125. cp qmemman/server.py $RPM_BUILD_ROOT/usr/lib/qubes/qmemman_daemon.py
  126. cp qubes-rpc/qubes-notify-tools $RPM_BUILD_ROOT/usr/lib/qubes/
  127. cp qubes-rpc/qubes-notify-updates $RPM_BUILD_ROOT/usr/lib/qubes/
  128. cp linux/aux-tools/vusb-ctl.py $RPM_BUILD_ROOT/usr/lib/qubes/
  129. cp linux/aux-tools/xl-qvm-usb-attach.py $RPM_BUILD_ROOT/usr/lib/qubes/
  130. cp linux/aux-tools/xl-qvm-usb-detach.py $RPM_BUILD_ROOT/usr/lib/qubes/
  131. cp linux/aux-tools/block-cleaner-daemon.py $RPM_BUILD_ROOT/usr/lib/qubes/
  132. cp linux/aux-tools/fix-dir-perms.sh $RPM_BUILD_ROOT/usr/lib/qubes/
  133. mkdir -p $RPM_BUILD_ROOT/etc/qubes-rpc/policy
  134. cp qubes-rpc-policy/qubes.Filecopy.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.Filecopy
  135. cp qubes-rpc-policy/qubes.GetImageRGBA.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.GetImageRGBA
  136. cp qubes-rpc-policy/qubes.OpenInVM.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.OpenInVM
  137. cp qubes-rpc-policy/qubes.VMShell.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.VMShell
  138. cp qubes-rpc-policy/qubes.NotifyTools.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.NotifyTools
  139. cp qubes-rpc/qubes.NotifyTools $RPM_BUILD_ROOT/etc/qubes-rpc/
  140. cp qubes-rpc-policy/qubes.NotifyUpdates.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.NotifyUpdates
  141. cp qubes-rpc/qubes.NotifyUpdates $RPM_BUILD_ROOT/etc/qubes-rpc/
  142. cp dispvm/xenstore-watch $RPM_BUILD_ROOT/usr/bin/xenstore-watch-qubes
  143. cp dispvm/qubes-prepare-saved-domain.sh $RPM_BUILD_ROOT/usr/lib/qubes
  144. cp dispvm/qubes-update-dispvm-savefile-with-progress.sh $RPM_BUILD_ROOT/usr/lib/qubes
  145. cp dispvm/qfile-daemon-dvm $RPM_BUILD_ROOT/usr/lib/qubes
  146. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
  147. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/vm-templates
  148. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/appvms
  149. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/servicevms
  150. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/vm-kernels
  151. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/backup
  152. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/dvmdata
  153. mkdir -p $RPM_BUILD_ROOT/usr/share/qubes
  154. cp xen-vm-config/vm-template.xml $RPM_BUILD_ROOT/usr/share/qubes/xen-vm-template.xml
  155. cp xen-vm-config/vm-template-hvm.xml $RPM_BUILD_ROOT/usr/share/qubes/
  156. mkdir -p $RPM_BUILD_ROOT/usr/bin
  157. mkdir -p $RPM_BUILD_ROOT/var/log/qubes
  158. mkdir -p $RPM_BUILD_ROOT/var/run/qubes
  159. install -d $RPM_BUILD_ROOT/etc/xdg/autostart
  160. install -m 0644 linux/system-config/qubes-guid.desktop $RPM_BUILD_ROOT/etc/xdg/autostart/
  161. %post
  162. # Create NetworkManager configuration if we do not have it
  163. if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
  164. echo '[main]' > /etc/NetworkManager/NetworkManager.conf
  165. echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
  166. echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
  167. fi
  168. sed '/^autoballoon=/d;/^lockfile=/d' -i /etc/xen/xl.conf
  169. echo 'autoballoon=0' >> /etc/xen/xl.conf
  170. echo 'lockfile="/var/run/qubes/xl-lock"' >> /etc/xen/xl.conf
  171. sed 's/^PRELINKING\s*=.*/PRELINKING=no/' -i /etc/sysconfig/prelink
  172. sed '/^\s*XENCONSOLED_LOG_\(HYPERVISOR\|GUESTS\)\s*=.*/d' -i /etc/sysconfig/xenconsoled
  173. echo XENCONSOLED_LOG_HYPERVISOR=yes >> /etc/sysconfig/xenconsoled
  174. echo XENCONSOLED_LOG_GUESTS=yes >> /etc/sysconfig/xenconsoled
  175. systemctl --no-reload enable qubes-core.service >/dev/null 2>&1
  176. systemctl --no-reload enable qubes-netvm.service >/dev/null 2>&1
  177. systemctl --no-reload enable qubes-setupdvm.service >/dev/null 2>&1
  178. # Conflicts with libxl stack, so disable it
  179. systemctl --no-reload disable xend.service >/dev/null 2>&1
  180. systemctl --no-reload disable xendomains.service >/dev/null 2>&1
  181. systemctl daemon-reload >/dev/null 2>&1 || :
  182. HAD_SYSCONFIG_NETWORK=yes
  183. if ! [ -e /etc/sysconfig/network ]; then
  184. HAD_SYSCONFIG_NETWORK=no
  185. # supplant empty one so NetworkManager init script does not complain
  186. touch /etc/sysconfig/network
  187. fi
  188. # Load evtchn module - xenstored needs it
  189. modprobe evtchn 2> /dev/null || modprobe xen-evtchn
  190. service xenstored start
  191. if ! [ -e /var/lib/qubes/qubes.xml ]; then
  192. # echo "Initializing Qubes DB..."
  193. umask 007; sg qubes -c qvm-init-storage
  194. qubes-prefs -s default-kernel `ls /var/lib/qubes/vm-kernels|head -n 1` 2> /dev/null
  195. fi
  196. # Because we now have an installer
  197. # this script is always executed during upgrade
  198. # and we decided not to restart core during upgrade
  199. #service qubes_core start
  200. if [ "x"$HAD_SYSCONFIG_NETWORK = "xno" ]; then
  201. rm -f /etc/sysconfig/network
  202. fi
  203. %clean
  204. rm -rf $RPM_BUILD_ROOT
  205. rm -f %{name}-%{version}
  206. %pre
  207. if ! grep -q ^qubes: /etc/group ; then
  208. groupadd qubes
  209. fi
  210. %triggerin -- xen-runtime
  211. sed -i 's/\/block /\/block.qubes /' /etc/udev/rules.d/xen-backend.rules
  212. /usr/lib/qubes/fix-dir-perms.sh
  213. %preun
  214. if [ "$1" = 0 ] ; then
  215. # no more packages left
  216. service qubes_netvm stop
  217. service qubes_core stop
  218. fi
  219. %postun
  220. if [ "$1" = 0 ] ; then
  221. # no more packages left
  222. chgrp root /etc/xen
  223. chmod 700 /etc/xen
  224. groupdel qubes
  225. sed -i 's/\/block.qubes /\/block /' /etc/udev/rules.d/xen-backend.rules
  226. fi
  227. %files
  228. %defattr(-,root,root,-)
  229. %config(noreplace) %attr(0664,root,qubes) %{_sysconfdir}/qubes/qmemman.conf
  230. /usr/bin/qvm-*
  231. /usr/bin/qubes-*
  232. %dir %{python_sitearch}/qubes
  233. %{python_sitearch}/qubes/qubes.py
  234. %{python_sitearch}/qubes/qubes.pyc
  235. %{python_sitearch}/qubes/qubes.pyo
  236. %{python_sitearch}/qubes/qubesutils.py
  237. %{python_sitearch}/qubes/qubesutils.pyc
  238. %{python_sitearch}/qubes/qubesutils.pyo
  239. %{python_sitearch}/qubes/guihelpers.py
  240. %{python_sitearch}/qubes/guihelpers.pyc
  241. %{python_sitearch}/qubes/guihelpers.pyo
  242. %{python_sitearch}/qubes/notify.py
  243. %{python_sitearch}/qubes/notify.pyc
  244. %{python_sitearch}/qubes/notify.pyo
  245. %{python_sitearch}/qubes/backup.py
  246. %{python_sitearch}/qubes/backup.pyc
  247. %{python_sitearch}/qubes/backup.pyo
  248. %{python_sitearch}/qubes/qmemman*.py*
  249. %{python_sitearch}/qubes/modules/0*.py*
  250. %{python_sitearch}/qubes/modules/__init__.py*
  251. %{python_sitearch}/qubes/tests
  252. /usr/lib/qubes/unbind-pci-device.sh
  253. /usr/lib/qubes/cleanup-dispvms
  254. /usr/lib/qubes/qmemman_daemon.py*
  255. /usr/lib/qubes/qfile-daemon-dvm*
  256. /usr/lib/qubes/qubes-notify-tools
  257. /usr/lib/qubes/qubes-notify-updates
  258. /usr/lib/qubes/block-cleaner-daemon.py*
  259. /usr/lib/qubes/vusb-ctl.py*
  260. /usr/lib/qubes/xl-qvm-usb-attach.py*
  261. /usr/lib/qubes/xl-qvm-usb-detach.py*
  262. /usr/lib/qubes/fix-dir-perms.sh
  263. /usr/lib/qubes/startup-dvm.sh
  264. /usr/lib/qubes/startup-misc.sh
  265. /usr/lib/qubes/prepare-volatile-img.sh
  266. %{_unitdir}/qubes-block-cleaner.service
  267. %{_unitdir}/qubes-core.service
  268. %{_unitdir}/qubes-setupdvm.service
  269. %{_unitdir}/qubes-netvm.service
  270. %{_unitdir}/qubes-qmemman.service
  271. %{_unitdir}/qubes-vm@.service
  272. %{_unitdir}/qubes-reload-firewall@.service
  273. %{_unitdir}/qubes-reload-firewall@.timer
  274. %attr(0770,root,qubes) %dir /var/lib/qubes
  275. %attr(0770,root,qubes) %dir /var/lib/qubes/vm-templates
  276. %attr(0770,root,qubes) %dir /var/lib/qubes/appvms
  277. %attr(0770,root,qubes) %dir /var/lib/qubes/servicevms
  278. %attr(0770,root,qubes) %dir /var/lib/qubes/backup
  279. %attr(0770,root,qubes) %dir /var/lib/qubes/dvmdata
  280. %attr(0770,root,qubes) %dir /var/lib/qubes/vm-kernels
  281. /usr/share/qubes/xen-vm-template.xml
  282. /usr/share/qubes/vm-template-hvm.xml
  283. /usr/bin/xenstore-watch-qubes
  284. /usr/lib/qubes/qubes-prepare-saved-domain.sh
  285. /usr/lib/qubes/qubes-update-dispvm-savefile-with-progress.sh
  286. /etc/xen/scripts/block.qubes
  287. /etc/xen/scripts/block-snapshot
  288. /etc/xen/scripts/block-origin
  289. /etc/xen/scripts/vif-route-qubes
  290. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.Filecopy
  291. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.GetImageRGBA
  292. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.OpenInVM
  293. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.NotifyTools
  294. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.NotifyUpdates
  295. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.VMShell
  296. /etc/qubes-rpc/qubes.NotifyTools
  297. /etc/qubes-rpc/qubes.NotifyUpdates
  298. %attr(2770,root,qubes) %dir /var/log/qubes
  299. %attr(0770,root,qubes) %dir /var/run/qubes
  300. /etc/xdg/autostart/qubes-guid.desktop