core-dom0.spec 13 KB

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