core-dom0.spec 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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.12
  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
  71. python -O -m compileall core dom/core-modules qmemman
  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/backup.py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  101. cp core/backup.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  102. cp qmemman/qmemman*py $RPM_BUILD_ROOT%{python_sitearch}/qubes
  103. cp qmemman/qmemman*py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes
  104. mkdir -p $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  105. cp core-modules/0*.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  106. cp core-modules/0*.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  107. cp core-modules/__init__.py $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  108. cp core-modules/__init__.py[co] $RPM_BUILD_ROOT%{python_sitearch}/qubes/modules
  109. mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/qubes
  110. cp qmemman/qmemman.conf $RPM_BUILD_ROOT%{_sysconfdir}/qubes/
  111. mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
  112. cp linux/aux-tools/unbind-pci-device.sh $RPM_BUILD_ROOT/usr/lib/qubes
  113. cp linux/aux-tools/cleanup-dispvms $RPM_BUILD_ROOT/usr/lib/qubes
  114. cp linux/aux-tools/startup-dvm.sh $RPM_BUILD_ROOT/usr/lib/qubes
  115. cp linux/aux-tools/startup-misc.sh $RPM_BUILD_ROOT/usr/lib/qubes
  116. cp linux/aux-tools/prepare-volatile-img.sh $RPM_BUILD_ROOT/usr/lib/qubes
  117. cp qmemman/server.py $RPM_BUILD_ROOT/usr/lib/qubes/qmemman_daemon.py
  118. cp qubes-rpc/qubes-notify-tools $RPM_BUILD_ROOT/usr/lib/qubes/
  119. cp qubes-rpc/qubes-notify-updates $RPM_BUILD_ROOT/usr/lib/qubes/
  120. cp linux/aux-tools/vusb-ctl.py $RPM_BUILD_ROOT/usr/lib/qubes/
  121. cp linux/aux-tools/xl-qvm-usb-attach.py $RPM_BUILD_ROOT/usr/lib/qubes/
  122. cp linux/aux-tools/xl-qvm-usb-detach.py $RPM_BUILD_ROOT/usr/lib/qubes/
  123. cp linux/aux-tools/block-cleaner-daemon.py $RPM_BUILD_ROOT/usr/lib/qubes/
  124. cp linux/aux-tools/fix-dir-perms.sh $RPM_BUILD_ROOT/usr/lib/qubes/
  125. mkdir -p $RPM_BUILD_ROOT/etc/qubes-rpc/policy
  126. cp qubes-rpc-policy/qubes.Filecopy.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.Filecopy
  127. cp qubes-rpc-policy/qubes.OpenInVM.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.OpenInVM
  128. cp qubes-rpc-policy/qubes.VMShell.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.VMShell
  129. cp qubes-rpc-policy/qubes.NotifyTools.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.NotifyTools
  130. cp qubes-rpc/qubes.NotifyTools $RPM_BUILD_ROOT/etc/qubes-rpc/
  131. cp qubes-rpc-policy/qubes.NotifyUpdates.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.NotifyUpdates
  132. cp qubes-rpc/qubes.NotifyUpdates $RPM_BUILD_ROOT/etc/qubes-rpc/
  133. cp dispvm/xenstore-watch $RPM_BUILD_ROOT/usr/bin/xenstore-watch-qubes
  134. cp dispvm/qubes-restore $RPM_BUILD_ROOT/usr/lib/qubes
  135. cp dispvm/qubes-prepare-saved-domain.sh $RPM_BUILD_ROOT/usr/lib/qubes
  136. cp dispvm/qubes-update-dispvm-savefile-with-progress.sh $RPM_BUILD_ROOT/usr/lib/qubes
  137. cp dispvm/qfile-daemon-dvm $RPM_BUILD_ROOT/usr/lib/qubes
  138. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes
  139. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/vm-templates
  140. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/appvms
  141. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/servicevms
  142. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/vm-kernels
  143. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/backup
  144. mkdir -p $RPM_BUILD_ROOT/var/lib/qubes/dvmdata
  145. mkdir -p $RPM_BUILD_ROOT/usr/share/qubes
  146. cp xen-vm-config/vm-template.conf $RPM_BUILD_ROOT/usr/share/qubes/
  147. cp xen-vm-config/vm-template-hvm.conf $RPM_BUILD_ROOT/usr/share/qubes/
  148. mkdir -p $RPM_BUILD_ROOT/usr/bin
  149. mkdir -p $RPM_BUILD_ROOT/var/log/qubes
  150. mkdir -p $RPM_BUILD_ROOT/var/run/qubes
  151. install -d $RPM_BUILD_ROOT/etc/xdg/autostart
  152. install -m 0644 linux/system-config/qubes-guid.desktop $RPM_BUILD_ROOT/etc/xdg/autostart/
  153. %post
  154. # Create NetworkManager configuration if we do not have it
  155. if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
  156. echo '[main]' > /etc/NetworkManager/NetworkManager.conf
  157. echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
  158. echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
  159. fi
  160. sed '/^autoballoon=/d;/^lockfile=/d' -i /etc/xen/xl.conf
  161. echo 'autoballoon=0' >> /etc/xen/xl.conf
  162. echo 'lockfile="/var/run/qubes/xl-lock"' >> /etc/xen/xl.conf
  163. sed 's/^PRELINKING\s*=.*/PRELINKING=no/' -i /etc/sysconfig/prelink
  164. sed '/^\s*XENCONSOLED_LOG_\(HYPERVISOR\|GUESTS\)\s*=.*/d' -i /etc/sysconfig/xenconsoled
  165. echo XENCONSOLED_LOG_HYPERVISOR=yes >> /etc/sysconfig/xenconsoled
  166. echo XENCONSOLED_LOG_GUESTS=yes >> /etc/sysconfig/xenconsoled
  167. systemctl --no-reload enable qubes-core.service >/dev/null 2>&1
  168. systemctl --no-reload enable qubes-netvm.service >/dev/null 2>&1
  169. systemctl --no-reload enable qubes-setupdvm.service >/dev/null 2>&1
  170. # Conflicts with libxl stack, so disable it
  171. systemctl --no-reload disable xend.service >/dev/null 2>&1
  172. systemctl --no-reload disable xendomains.service >/dev/null 2>&1
  173. systemctl demon-reload >/dev/null 2>&1 || :
  174. HAD_SYSCONFIG_NETWORK=yes
  175. if ! [ -e /etc/sysconfig/network ]; then
  176. HAD_SYSCONFIG_NETWORK=no
  177. # supplant empty one so NetworkManager init script does not complain
  178. touch /etc/sysconfig/network
  179. fi
  180. # Load evtchn module - xenstored needs it
  181. modprobe evtchn 2> /dev/null || modprobe xen-evtchn
  182. service xenstored start
  183. if ! [ -e /var/lib/qubes/qubes.xml ]; then
  184. # echo "Initializing Qubes DB..."
  185. umask 007; sg qubes -c qvm-init-storage
  186. qubes-prefs -s default-kernel `ls /var/lib/qubes/vm-kernels|head -n 1` 2> /dev/null
  187. fi
  188. # Because we now have an installer
  189. # this script is always executed during upgrade
  190. # and we decided not to restart core during upgrade
  191. #service qubes_core start
  192. if [ "x"$HAD_SYSCONFIG_NETWORK = "xno" ]; then
  193. rm -f /etc/sysconfig/network
  194. fi
  195. %clean
  196. rm -rf $RPM_BUILD_ROOT
  197. rm -f %{name}-%{version}
  198. %pre
  199. if ! grep -q ^qubes: /etc/group ; then
  200. groupadd qubes
  201. fi
  202. %triggerin -- xen-runtime
  203. sed -i 's/\/block /\/block.qubes /' /etc/udev/rules.d/xen-backend.rules
  204. /usr/lib/qubes/fix-dir-perms.sh
  205. %preun
  206. if [ "$1" = 0 ] ; then
  207. # no more packages left
  208. service qubes_netvm stop
  209. service qubes_core stop
  210. fi
  211. %postun
  212. if [ "$1" = 0 ] ; then
  213. # no more packages left
  214. chgrp root /etc/xen
  215. chmod 700 /etc/xen
  216. groupdel qubes
  217. sed -i 's/\/block.qubes /\/block /' /etc/udev/rules.d/xen-backend.rules
  218. fi
  219. %files
  220. %defattr(-,root,root,-)
  221. %config(noreplace) %attr(0664,root,qubes) %{_sysconfdir}/qubes/qmemman.conf
  222. /usr/bin/qvm-*
  223. /usr/bin/qubes-*
  224. %dir %{python_sitearch}/qubes
  225. %{python_sitearch}/qubes/qubes.py
  226. %{python_sitearch}/qubes/qubes.pyc
  227. %{python_sitearch}/qubes/qubes.pyo
  228. %{python_sitearch}/qubes/qubesutils.py
  229. %{python_sitearch}/qubes/qubesutils.pyc
  230. %{python_sitearch}/qubes/qubesutils.pyo
  231. %{python_sitearch}/qubes/guihelpers.py
  232. %{python_sitearch}/qubes/guihelpers.pyc
  233. %{python_sitearch}/qubes/guihelpers.pyo
  234. %{python_sitearch}/qubes/backup.py
  235. %{python_sitearch}/qubes/backup.pyc
  236. %{python_sitearch}/qubes/backup.pyo
  237. %{python_sitearch}/qubes/qmemman*.py*
  238. %{python_sitearch}/qubes/modules/0*.py*
  239. %{python_sitearch}/qubes/modules/__init__.py*
  240. /usr/lib/qubes/unbind-pci-device.sh
  241. /usr/lib/qubes/cleanup-dispvms
  242. /usr/lib/qubes/qmemman_daemon.py*
  243. /usr/lib/qubes/qfile-daemon-dvm*
  244. /usr/lib/qubes/qubes-notify-tools
  245. /usr/lib/qubes/qubes-notify-updates
  246. /usr/lib/qubes/block-cleaner-daemon.py*
  247. /usr/lib/qubes/vusb-ctl.py*
  248. /usr/lib/qubes/xl-qvm-usb-attach.py*
  249. /usr/lib/qubes/xl-qvm-usb-detach.py*
  250. /usr/lib/qubes/fix-dir-perms.sh
  251. /usr/lib/qubes/startup-dvm.sh
  252. /usr/lib/qubes/startup-misc.sh
  253. /usr/lib/qubes/prepare-volatile-img.sh
  254. %{_unitdir}/qubes-block-cleaner.service
  255. %{_unitdir}/qubes-core.service
  256. %{_unitdir}/qubes-setupdvm.service
  257. %{_unitdir}/qubes-netvm.service
  258. %{_unitdir}/qubes-qmemman.service
  259. %{_unitdir}/qubes-vm@.service
  260. %{_unitdir}/qubes-reload-firewall@.service
  261. %{_unitdir}/qubes-reload-firewall@.timer
  262. %attr(0770,root,qubes) %dir /var/lib/qubes
  263. %attr(0770,root,qubes) %dir /var/lib/qubes/vm-templates
  264. %attr(0770,root,qubes) %dir /var/lib/qubes/appvms
  265. %attr(0770,root,qubes) %dir /var/lib/qubes/servicevms
  266. %attr(0770,root,qubes) %dir /var/lib/qubes/backup
  267. %attr(0770,root,qubes) %dir /var/lib/qubes/dvmdata
  268. %attr(0770,root,qubes) %dir /var/lib/qubes/vm-kernels
  269. /usr/share/qubes/vm-template.conf
  270. /usr/share/qubes/vm-template-hvm.conf
  271. /usr/bin/xenstore-watch-qubes
  272. /usr/lib/qubes/qubes-restore
  273. /usr/lib/qubes/qubes-prepare-saved-domain.sh
  274. /usr/lib/qubes/qubes-update-dispvm-savefile-with-progress.sh
  275. /etc/xen/scripts/block.qubes
  276. /etc/xen/scripts/block-snapshot
  277. /etc/xen/scripts/block-origin
  278. /etc/xen/scripts/vif-route-qubes
  279. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.Filecopy
  280. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.OpenInVM
  281. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.NotifyTools
  282. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.NotifyUpdates
  283. %attr(0664,root,qubes) %config(noreplace) /etc/qubes-rpc/policy/qubes.VMShell
  284. /etc/qubes-rpc/qubes.NotifyTools
  285. /etc/qubes-rpc/qubes.NotifyUpdates
  286. %attr(2770,root,qubes) %dir /var/log/qubes
  287. %attr(0770,root,qubes) %dir /var/run/qubes
  288. /etc/xdg/autostart/qubes-guid.desktop