core-dom0.spec 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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: xen-devel
  40. BuildRequires: ImageMagick
  41. BuildRequires: systemd-units
  42. Requires(post): systemd-units
  43. Requires(preun): systemd-units
  44. Requires(postun): systemd-units
  45. Requires: python, xen-runtime, pciutils, python-inotify, python-daemon
  46. Requires: qubes-core-dom0-linux >= 2.0.24
  47. Requires: python-lxml
  48. # TODO: R: qubes-gui-dom0 >= 2.1.11
  49. Conflicts: qubes-gui-dom0 < 1.1.13
  50. Requires: xen >= 4.1.0-2
  51. Requires: xen-hvm
  52. Requires: createrepo
  53. Requires: gnome-packagekit
  54. Requires: cronie
  55. # for qubes-hcl-report
  56. Requires: dmidecode
  57. # Prevent preupgrade from installation (it pretend to provide distribution upgrade)
  58. Obsoletes: preupgrade < 2.0
  59. Provides: preupgrade = 2.0
  60. %define _builddir %(pwd)
  61. %description
  62. The Qubes core files for installation on Dom0.
  63. %prep
  64. # we operate on the current directory, so no need to unpack anything
  65. # symlink is to generate useful debuginfo packages
  66. rm -f %{name}-%{version}
  67. ln -sf . %{name}-%{version}
  68. %setup -T -D
  69. %build
  70. python -m compileall core core-modules qmemman tests
  71. python -O -m compileall core dom/core-modules qmemman tests
  72. for dir in dispvm qmemman; do
  73. (cd $dir; make)
  74. done
  75. %install
  76. mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/system
  77. cp linux/systemd/qubes-block-cleaner.service $RPM_BUILD_ROOT%{_unitdir}
  78. cp linux/systemd/qubes-core.service $RPM_BUILD_ROOT%{_unitdir}
  79. cp linux/systemd/qubes-setupdvm.service $RPM_BUILD_ROOT%{_unitdir}
  80. cp linux/systemd/qubes-netvm.service $RPM_BUILD_ROOT%{_unitdir}
  81. cp linux/systemd/qubes-qmemman.service $RPM_BUILD_ROOT%{_unitdir}
  82. cp linux/systemd/qubes-vm@.service $RPM_BUILD_ROOT%{_unitdir}
  83. cp linux/systemd/qubes-reload-firewall@.service $RPM_BUILD_ROOT%{_unitdir}
  84. cp linux/systemd/qubes-reload-firewall@.timer $RPM_BUILD_ROOT%{_unitdir}
  85. mkdir -p $RPM_BUILD_ROOT/usr/bin/
  86. cp qvm-tools/qvm-* $RPM_BUILD_ROOT/usr/bin
  87. cp qvm-tools/qubes-* $RPM_BUILD_ROOT/usr/bin
  88. mkdir -p $RPM_BUILD_ROOT/etc/xen/scripts
  89. cp dispvm/block.qubes $RPM_BUILD_ROOT/etc/xen/scripts
  90. cp linux/system-config/vif-route-qubes $RPM_BUILD_ROOT/etc/xen/scripts
  91. cp linux/system-config/block-snapshot $RPM_BUILD_ROOT/etc/xen/scripts
  92. ln -s block-snapshot $RPM_BUILD_ROOT/etc/xen/scripts/block-origin
  93. mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes
  94. cp core/qubes.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  95. cp core/qubes.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  96. cp core/qubesutils.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  97. cp core/qubesutils.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  98. cp core/guihelpers.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  99. cp core/guihelpers.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  100. cp core/notify.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  101. cp core/notify.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  102. cp core/backup.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  103. cp core/backup.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  104. cp qmemman/qmemman*py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  105. cp qmemman/qmemman*py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  106. mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  107. cp core-modules/0*.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  108. cp core-modules/0*.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  109. cp core-modules/__init__.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  110. cp core-modules/__init__.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  111. mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes/tests
  112. cp tests/*.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/tests/
  113. cp tests/*.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/tests/
  114. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/qubes
  115. cp qmemman/qmemman.conf $RPM_BUILD_ROOT%{_sysconfdir}/qubes/
  116. mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
  117. cp linux/aux-tools/unbind-pci-device.sh $RPM_BUILD_ROOT/usr/lib/qubes
  118. cp linux/aux-tools/cleanup-dispvms $RPM_BUILD_ROOT/usr/lib/qubes
  119. cp linux/aux-tools/startup-dvm.sh $RPM_BUILD_ROOT/usr/lib/qubes
  120. cp linux/aux-tools/startup-misc.sh $RPM_BUILD_ROOT/usr/lib/qubes
  121. cp linux/aux-tools/prepare-volatile-img.sh $RPM_BUILD_ROOT/usr/lib/qubes
  122. cp qmemman/server.py $RPM_BUILD_ROOT/usr/lib/qubes/qmemman_daemon.py
  123. cp qubes-rpc/qubes-notify-tools $RPM_BUILD_ROOT/usr/lib/qubes/
  124. cp qubes-rpc/qubes-notify-updates $RPM_BUILD_ROOT/usr/lib/qubes/
  125. cp linux/aux-tools/vusb-ctl.py $RPM_BUILD_ROOT/usr/lib/qubes/
  126. cp linux/aux-tools/xl-qvm-usb-attach.py $RPM_BUILD_ROOT/usr/lib/qubes/
  127. cp linux/aux-tools/xl-qvm-usb-detach.py $RPM_BUILD_ROOT/usr/lib/qubes/
  128. cp linux/aux-tools/block-cleaner-daemon.py $RPM_BUILD_ROOT/usr/lib/qubes/
  129. cp linux/aux-tools/fix-dir-perms.sh $RPM_BUILD_ROOT/usr/lib/qubes/
  130. mkdir -p $RPM_BUILD_ROOT/etc/qubes-rpc/policy
  131. cp qubes-rpc-policy/qubes.Filecopy.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.Filecopy
  132. cp qubes-rpc-policy/qubes.GetImageRGBA.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.GetImageRGBA
  133. cp qubes-rpc-policy/qubes.OpenInVM.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.OpenInVM
  134. cp qubes-rpc-policy/qubes.VMShell.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.VMShell
  135. cp qubes-rpc-policy/qubes.NotifyTools.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.NotifyTools
  136. cp qubes-rpc/qubes.NotifyTools $RPM_BUILD_ROOT/etc/qubes-rpc/
  137. cp qubes-rpc-policy/qubes.NotifyUpdates.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.NotifyUpdates
  138. cp qubes-rpc/qubes.NotifyUpdates $RPM_BUILD_ROOT/etc/qubes-rpc/
  139. cp dispvm/xenstore-watch $RPM_BUILD_ROOT/usr/bin/xenstore-watch-qubes
  140. cp dispvm/qubes-prepare-saved-domain.sh $RPM_BUILD_ROOT/usr/lib/qubes
  141. cp dispvm/qubes-update-dispvm-savefile-with-progress.sh $RPM_BUILD_ROOT/usr/lib/qubes
  142. cp dispvm/qfile-daemon-dvm $RPM_BUILD_ROOT/usr/lib/qubes
  143. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
  144. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/vm-templates
  145. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/appvms
  146. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/servicevms
  147. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/vm-kernels
  148. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/backup
  149. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/dvmdata
  150. mkdir -p $RPM_BUILD_ROOT/usr/share/qubes
  151. cp xen-vm-config/vm-template.xml $RPM_BUILD_ROOT/usr/share/qubes/xen-vm-template.xml
  152. cp xen-vm-config/vm-template-hvm.xml $RPM_BUILD_ROOT/usr/share/qubes/
  153. mkdir -p $RPM_BUILD_ROOT/usr/bin
  154. mkdir -p $RPM_BUILD_ROOT/var/log/qubes
  155. mkdir -p $RPM_BUILD_ROOT/var/run/qubes
  156. install -d $RPM_BUILD_ROOT/etc/xdg/autostart
  157. install -m 0644 linux/system-config/qubes-guid.desktop $RPM_BUILD_ROOT/etc/xdg/autostart/
  158. %post
  159. # Create NetworkManager configuration if we do not have it
  160. if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
  161. echo '[main]' > /etc/NetworkManager/NetworkManager.conf
  162. echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
  163. echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
  164. fi
  165. sed '/^autoballoon=/d;/^lockfile=/d' -i /etc/xen/xl.conf
  166. echo 'autoballoon=0' >> /etc/xen/xl.conf
  167. echo 'lockfile="/var/run/qubes/xl-lock"' >> /etc/xen/xl.conf
  168. sed 's/^PRELINKING\s*=.*/PRELINKING=no/' -i /etc/sysconfig/prelink
  169. sed '/^\s*XENCONSOLED_LOG_\(HYPERVISOR\|GUESTS\)\s*=.*/d' -i /etc/sysconfig/xenconsoled
  170. echo XENCONSOLED_LOG_HYPERVISOR=yes >> /etc/sysconfig/xenconsoled
  171. echo XENCONSOLED_LOG_GUESTS=yes >> /etc/sysconfig/xenconsoled
  172. systemctl --no-reload enable qubes-core.service >/dev/null 2>&1
  173. systemctl --no-reload enable qubes-netvm.service >/dev/null 2>&1
  174. systemctl --no-reload enable qubes-setupdvm.service >/dev/null 2>&1
  175. # Conflicts with libxl stack, so disable it
  176. systemctl --no-reload disable xend.service >/dev/null 2>&1
  177. systemctl --no-reload disable xendomains.service >/dev/null 2>&1
  178. systemctl daemon-reload >/dev/null 2>&1 || :
  179. HAD_SYSCONFIG_NETWORK=yes
  180. if ! [ -e /etc/sysconfig/network ]; then
  181. HAD_SYSCONFIG_NETWORK=no
  182. # supplant empty one so NetworkManager init script does not complain
  183. touch /etc/sysconfig/network
  184. fi
  185. # Load evtchn module - xenstored needs it
  186. modprobe evtchn 2> /dev/null || modprobe xen-evtchn
  187. service xenstored start
  188. if ! [ -e /var/lib/qubes/qubes.xml ]; then
  189. # echo "Initializing Qubes DB..."
  190. umask 007; sg qubes -c qvm-init-storage
  191. qubes-prefs -s default-kernel `ls /var/lib/qubes/vm-kernels|head -n 1` 2> /dev/null
  192. fi
  193. # Because we now have an installer
  194. # this script is always executed during upgrade
  195. # and we decided not to restart core during upgrade
  196. #service qubes_core start
  197. if [ "x"$HAD_SYSCONFIG_NETWORK = "xno" ]; then
  198. rm -f /etc/sysconfig/network
  199. fi
  200. %clean
  201. rm -rf $RPM_BUILD_ROOT
  202. rm -f %{name}-%{version}
  203. %pre
  204. if ! grep -q ^qubes: /etc/group ; then
  205. groupadd qubes
  206. fi
  207. %triggerin -- xen-runtime
  208. sed -i 's/\/block /\/block.qubes /' /etc/udev/rules.d/xen-backend.rules
  209. /usr/lib/qubes/fix-dir-perms.sh
  210. %preun
  211. if [ "$1" = 0 ] ; then
  212. # no more packages left
  213. service qubes_netvm stop
  214. service qubes_core stop
  215. fi
  216. %postun
  217. if [ "$1" = 0 ] ; then
  218. # no more packages left
  219. chgrp root /etc/xen
  220. chmod 700 /etc/xen
  221. groupdel qubes
  222. sed -i 's/\/block.qubes /\/block /' /etc/udev/rules.d/xen-backend.rules
  223. fi
  224. %files
  225. %defattr(-,root,root,-)
  226. %config(noreplace) %attr(0664,root,qubes) %{_sysconfdir}/qubes/qmemman.conf
  227. /usr/bin/qvm-*
  228. /usr/bin/qubes-*
  229. %dir %{python_sitearch}/qubes
  230. %{python_sitearch}/qubes/qubes.py
  231. %{python_sitearch}/qubes/qubes.pyc
  232. %{python_sitearch}/qubes/qubes.pyo
  233. %{python_sitearch}/qubes/qubesutils.py
  234. %{python_sitearch}/qubes/qubesutils.pyc
  235. %{python_sitearch}/qubes/qubesutils.pyo
  236. %{python_sitearch}/qubes/guihelpers.py
  237. %{python_sitearch}/qubes/guihelpers.pyc
  238. %{python_sitearch}/qubes/guihelpers.pyo
  239. %{python_sitearch}/qubes/notify.py
  240. %{python_sitearch}/qubes/notify.pyc
  241. %{python_sitearch}/qubes/notify.pyo
  242. %{python_sitearch}/qubes/backup.py
  243. %{python_sitearch}/qubes/backup.pyc
  244. %{python_sitearch}/qubes/backup.pyo
  245. %{python_sitearch}/qubes/qmemman*.py*
  246. %{python_sitearch}/qubes/modules/0*.py*
  247. %{python_sitearch}/qubes/modules/__init__.py*
  248. %{python_sitearch}/qubes/tests
  249. /usr/lib/qubes/unbind-pci-device.sh
  250. /usr/lib/qubes/cleanup-dispvms
  251. /usr/lib/qubes/qmemman_daemon.py*
  252. /usr/lib/qubes/qfile-daemon-dvm*
  253. /usr/lib/qubes/qubes-notify-tools
  254. /usr/lib/qubes/qubes-notify-updates
  255. /usr/lib/qubes/block-cleaner-daemon.py*
  256. /usr/lib/qubes/vusb-ctl.py*
  257. /usr/lib/qubes/xl-qvm-usb-attach.py*
  258. /usr/lib/qubes/xl-qvm-usb-detach.py*
  259. /usr/lib/qubes/fix-dir-perms.sh
  260. /usr/lib/qubes/startup-dvm.sh
  261. /usr/lib/qubes/startup-misc.sh
  262. /usr/lib/qubes/prepare-volatile-img.sh
  263. %{_unitdir}/qubes-block-cleaner.service
  264. %{_unitdir}/qubes-core.service
  265. %{_unitdir}/qubes-setupdvm.service
  266. %{_unitdir}/qubes-netvm.service
  267. %{_unitdir}/qubes-qmemman.service
  268. %{_unitdir}/qubes-vm@.service
  269. %{_unitdir}/qubes-reload-firewall@.service
  270. %{_unitdir}/qubes-reload-firewall@.timer
  271. %attr(0770,root,qubes) %dir /var/lib/qubes
  272. %attr(0770,root,qubes) %dir /var/lib/qubes/vm-templates
  273. %attr(0770,root,qubes) %dir /var/lib/qubes/appvms
  274. %attr(0770,root,qubes) %dir /var/lib/qubes/servicevms
  275. %attr(0770,root,qubes) %dir /var/lib/qubes/backup
  276. %attr(0770,root,qubes) %dir /var/lib/qubes/dvmdata
  277. %attr(0770,root,qubes) %dir /var/lib/qubes/vm-kernels
  278. /usr/share/qubes/xen-vm-template.xml
  279. /usr/share/qubes/vm-template-hvm.xml
  280. /usr/bin/xenstore-watch-qubes
  281. /usr/lib/qubes/qubes-prepare-saved-domain.sh
  282. /usr/lib/qubes/qubes-update-dispvm-savefile-with-progress.sh
  283. /etc/xen/scripts/block.qubes
  284. /etc/xen/scripts/block-snapshot
  285. /etc/xen/scripts/block-origin
  286. /etc/xen/scripts/vif-route-qubes
  287. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.Filecopy
  288. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.GetImageRGBA
  289. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.OpenInVM
  290. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.NotifyTools
  291. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.NotifyUpdates
  292. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.VMShell
  293. /etc/qubes-rpc/qubes.NotifyTools
  294. /etc/qubes-rpc/qubes.NotifyUpdates
  295. %attr(2770,root,qubes) %dir /var/log/qubes
  296. %attr(0770,root,qubes) %dir /var/run/qubes
  297. /etc/xdg/autostart/qubes-guid.desktop