core-vm.spec 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. #
  2. # The Qubes OS Project, http://www.qubes-os.org
  3. #
  4. # Copyright (C) 2010 Joanna Rutkowska <joanna@invisiblethingslab.com>
  5. # Copyright (C) 2010 Rafal Wojtczuk <rafal@invisiblethingslab.com>
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # as published by the Free Software Foundation; either version 2
  10. # of the License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. #
  21. #
  22. %{!?version: %define version %(cat version)}
  23. %{!?backend_vmm: %define backend_vmm %(echo $BACKEND_VMM)}
  24. Name: qubes-core-vm
  25. Version: %{version}
  26. Release: 1%{dist}
  27. Summary: The Qubes core files for VM
  28. Group: Qubes
  29. Vendor: Invisible Things Lab
  30. License: GPL
  31. URL: http://www.qubes-os.org
  32. Requires: fedora-release
  33. Requires: yum-plugin-post-transaction-actions
  34. Requires: NetworkManager >= 0.8.1-1
  35. %if %{fedora} >= 18
  36. # Fedora >= 18 defaults to firewalld, which isn't supported nor needed by Qubes
  37. Requires: iptables-services
  38. Conflicts: firewalld
  39. %endif
  40. Requires: /usr/bin/mimeopen
  41. Requires: ethtool
  42. Requires: tinyproxy
  43. Requires: ntpdate
  44. Requires: net-tools
  45. Requires: nautilus-python
  46. Requires: qubes-core-vm-kernel-placeholder
  47. Requires: qubes-utils
  48. Requires: initscripts
  49. # for qubes-desktop-run
  50. Requires: pygobject3-base
  51. # for qubes-desktop-file-install
  52. Requires: pyxdg
  53. %if %{fedora} >= 20
  54. # gpk-update-viewer required by qubes-manager
  55. Requires: gnome-packagekit-updater
  56. %endif
  57. Requires: ImageMagick
  58. Requires: fakeroot
  59. Requires: desktop-notification-daemon
  60. Requires: pygtk2
  61. Requires: zenity
  62. Requires: qubes-libvchan
  63. Requires: qubes-db-vm
  64. Provides: qubes-core-vm
  65. Obsoletes: qubes-core-commonvm
  66. Obsoletes: qubes-core-appvm
  67. Obsoletes: qubes-core-netvm
  68. Obsoletes: qubes-core-proxyvm
  69. Obsoletes: qubes-upgrade-vm < 3.0
  70. BuildRequires: xen-devel
  71. BuildRequires: libX11-devel
  72. BuildRequires: qubes-utils-devel >= 3.0.1
  73. BuildRequires: qubes-libvchan-%{backend_vmm}-devel
  74. %define _builddir %(pwd)
  75. %define kde_service_dir /usr/share/kde4/services
  76. %description
  77. The Qubes core files for installation inside a Qubes VM.
  78. %prep
  79. # we operate on the current directory, so no need to unpack anything
  80. # symlink is to generate useful debuginfo packages
  81. rm -f %{name}-%{version}
  82. ln -sf . %{name}-%{version}
  83. %setup -T -D
  84. %build
  85. for dir in qubes-rpc qrexec misc; do
  86. (cd $dir; make)
  87. done
  88. %pre
  89. # Make sure there is a qubes group
  90. groupadd --force --system --gid 98 qubes
  91. id -u 'user' >/dev/null 2>&1 || {
  92. useradd --user-group --create-home --shell /bin/bash user
  93. }
  94. usermod -a --groups qubes user
  95. if [ "$1" != 1 ] ; then
  96. # do this whole %pre thing only when updating for the first time...
  97. exit 0
  98. fi
  99. mkdir -p /var/lib/qubes
  100. if [ -e /etc/fstab ] ; then
  101. mv /etc/fstab /var/lib/qubes/fstab.orig
  102. fi
  103. usermod -p '' root
  104. usermod -L user
  105. %install
  106. (cd qrexec; make install DESTDIR=$RPM_BUILD_ROOT)
  107. make install-vm DESTDIR=$RPM_BUILD_ROOT
  108. cp -p $RPM_BUILD_ROOT/usr/lib/qubes/init/iptables $RPM_BUILD_ROOT/etc/sysconfig/iptables.qubes
  109. cp -p $RPM_BUILD_ROOT/usr/lib/qubes/init/ip6tables $RPM_BUILD_ROOT/etc/sysconfig/ip6tables.qubes
  110. %triggerin -- initscripts
  111. if [ -e /etc/init/serial.conf ]; then
  112. cp /usr/share/qubes/serial.conf /etc/init/serial.conf
  113. fi
  114. %triggerin -- pulseaudio-module-x11
  115. /usr/bin/qubes-desktop-file-install --force --dir /usr/share/qubes/xdg/autostart --remove-show-in --add-not-show-in X-QUBES /etc/xdg/autostart/pulseaudio.desktop
  116. %triggerin -- iptables
  117. if ! grep -q IPTABLES_DATA /etc/sysconfig/iptables-config; then
  118. cat <<EOF >>/etc/sysconfig/iptables-config
  119. ### Automatically added by Qubes:
  120. # Override default rules location on Qubes
  121. IPTABLES_DATA=/etc/sysconfig/iptables.qubes
  122. EOF
  123. fi
  124. if ! grep -q IP6TABLES_DATA /etc/sysconfig/ip6tables-config; then
  125. cat <<EOF >>/etc/sysconfig/ip6tables-config
  126. ### Automatically added by Qubes:
  127. # Override default rules location on Qubes
  128. IP6TABLES_DATA=/etc/sysconfig/ip6tables.qubes
  129. EOF
  130. fi
  131. %post
  132. # disable some Upstart services
  133. for F in plymouth-shutdown prefdm splash-manager start-ttys tty ; do
  134. if [ -e /etc/init/$F.conf ]; then
  135. mv -f /etc/init/$F.conf /etc/init/$F.conf.disabled
  136. fi
  137. done
  138. # Update all autostart xdg desktop configuration files (modified copies are
  139. # placed in /usr/share/qubes/xdg/autostart)
  140. /usr/lib/qubes/qubes-trigger-desktop-file-install clean
  141. # Create NetworkManager configuration if we do not have it
  142. if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
  143. echo '[main]' > /etc/NetworkManager/NetworkManager.conf
  144. echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
  145. echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
  146. fi
  147. /usr/lib/qubes/qubes-fix-nm-conf.sh
  148. # Remove ip_forward setting from sysctl, so NM will not reset it
  149. sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
  150. # Remove old firmware updates link
  151. if [ -L /lib/firmware/updates ]; then
  152. rm -f /lib/firmware/updates
  153. fi
  154. if ! grep -q '/etc/yum\.conf\.d/qubes-proxy\.conf' /etc/yum.conf; then
  155. echo >> /etc/yum.conf
  156. echo '# Yum does not support inclusion of config dir...' >> /etc/yum.conf
  157. echo 'include=file:///etc/yum.conf.d/qubes-proxy.conf' >> /etc/yum.conf
  158. fi
  159. # Revert 'Prevent unnecessary updates in VMs':
  160. sed -i -e '/^exclude = kernel/d' /etc/yum.conf
  161. # Location of files which contains list of protected files
  162. mkdir -p /etc/qubes/protected-files.d
  163. PROTECTED_FILE_LIST='/etc/qubes/protected-files.d'
  164. # qubes-core-vm has been broken for some time - it overrides /etc/hosts; restore original content
  165. if ! grep -rq "^/etc/hosts$" "${PROTECTED_FILE_LIST}" 2>/dev/null; then
  166. if ! grep -q localhost /etc/hosts; then
  167. cat <<EOF > /etc/hosts
  168. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 `hostname`
  169. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  170. EOF
  171. fi
  172. fi
  173. # Make sure that /etc/sysconfig/ip(|6)tables exists. Otherwise iptales.service
  174. # would not start (even when configured to use another configuration file.
  175. if [ ! -e '/etc/sysconfig/iptables' ]; then
  176. ln -s iptables.qubes /etc/sysconfig/iptables
  177. fi
  178. if [ ! -e '/etc/sysconfig/ip6tables' ]; then
  179. ln -s ip6tables.qubes /etc/sysconfig/ip6tables
  180. fi
  181. # ensure that hostname resolves to 127.0.0.1 resp. ::1 and that /etc/hosts is
  182. # in the form expected by qubes-sysinit.sh
  183. if ! grep -rq "^/etc/hostname$" "${PROTECTED_FILE_LIST}" 2>/dev/null; then
  184. for ip in '127\.0\.0\.1' '::1'; do
  185. if grep -q "^${ip}\(\s\|$\)" /etc/hosts; then
  186. sed -i "/^${ip}\s/,+0s/\(\s`hostname`\)\+\(\s\|$\)/\2/g" /etc/hosts
  187. sed -i "s/^${ip}\(\s\|$\).*$/\0 `hostname`/" /etc/hosts
  188. else
  189. echo "${ip} `hostname`" >> /etc/hosts
  190. fi
  191. done
  192. fi
  193. %if %{fedora} >= 20
  194. # Make sure there is a default locale set so gnome-terminal will start
  195. if [ ! -e /etc/locale.conf ] || ! grep -q LANG /etc/locale.conf; then
  196. touch /etc/locale.conf
  197. echo "LANG=en_US.UTF-8" >> /etc/locale.conf
  198. fi
  199. # ... and make sure it is really generated
  200. current_locale=`grep LANG /etc/locale.conf|cut -f 2 -d = | tr -d '"'`
  201. if [ -n "$current_locale" ] && ! locale -a | grep -q "$current_locale"; then
  202. base=`echo "$current_locale" | cut -f 1 -d .`
  203. charmap=`echo "$current_locale.UTF-8" | cut -f 2 -d .`
  204. [ -n "$charmap" ] && charmap="-f $charmap"
  205. localedef -i $base $charmap $current_locale
  206. fi
  207. %endif
  208. if [ "$1" != 1 ] ; then
  209. # do the rest of %post thing only when updating for the first time...
  210. exit 0
  211. fi
  212. if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
  213. cp /etc/init/serial.conf /var/lib/qubes/serial.orig
  214. fi
  215. # Remove most of the udev scripts to speed up the VM boot time
  216. # Just leave the xen* scripts, that are needed if this VM was
  217. # ever used as a net backend (e.g. as a VPN domain in the future)
  218. #echo "--> Removing unnecessary udev scripts..."
  219. mkdir -p /var/lib/qubes/removed-udev-scripts
  220. for f in /etc/udev/rules.d/*
  221. do
  222. if [ $(basename $f) == "xen-backend.rules" ] ; then
  223. continue
  224. fi
  225. if [ $(basename $f) == "50-qubes-misc.rules" ] ; then
  226. continue
  227. fi
  228. if echo $f | grep -q qubes; then
  229. continue
  230. fi
  231. mv $f /var/lib/qubes/removed-udev-scripts/
  232. done
  233. mkdir -p /rw
  234. #rm -f /etc/mtab
  235. #echo "--> Removing HWADDR setting from /etc/sysconfig/network-scripts/ifcfg-eth0"
  236. #mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.orig
  237. #grep -v HWADDR /etc/sysconfig/network-scripts/ifcfg-eth0.orig > /etc/sysconfig/network-scripts/ifcfg-eth0
  238. %triggerin -- notification-daemon
  239. # Enable autostart of notification-daemon when installed
  240. if [ ! -e /etc/xdg/autostart/notification-daemon.desktop ]; then
  241. ln -s /usr/share/applications/notification-daemon.desktop /etc/xdg/autostart/
  242. fi
  243. exit 0
  244. %triggerin -- selinux-policy
  245. #echo "--> Disabling SELinux..."
  246. sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  247. mv /etc/selinux/config.processed /etc/selinux/config
  248. setenforce 0 2>/dev/null
  249. exit 0
  250. %preun
  251. if [ "$1" = 0 ] ; then
  252. # no more packages left
  253. if [ -e /var/lib/qubes/fstab.orig ] ; then
  254. mv /var/lib/qubes/fstab.orig /etc/fstab
  255. fi
  256. mv /var/lib/qubes/removed-udev-scripts/* /etc/udev/rules.d/
  257. if [ -e /var/lib/qubes/serial.orig ] ; then
  258. mv /var/lib/qubes/serial.orig /etc/init/serial.conf
  259. fi
  260. fi
  261. %postun
  262. if [ $1 -eq 0 ] ; then
  263. /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
  264. if [ -L /lib/firmware/updates ]; then
  265. rm /lib/firmware/updates
  266. fi
  267. rm -rf /usr/share/qubes/xdg
  268. fi
  269. %posttrans
  270. /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
  271. %clean
  272. rm -rf $RPM_BUILD_ROOT
  273. rm -f %{name}-%{version}
  274. %files
  275. %defattr(-,root,root,-)
  276. %dir /var/lib/qubes
  277. %dir /var/run/qubes
  278. %dir %attr(0775,user,user) /var/lib/qubes/dom0-updates
  279. %{kde_service_dir}/qvm-copy.desktop
  280. %{kde_service_dir}/qvm-move.desktop
  281. %{kde_service_dir}/qvm-dvm.desktop
  282. /etc/NetworkManager/dispatcher.d/30-qubes-external-ip
  283. /etc/NetworkManager/dispatcher.d/qubes-nmhook
  284. %config(noreplace) /etc/X11/xorg-preload-apps.conf
  285. /etc/dispvm-dotfiles.tbz
  286. /etc/dhclient.d/qubes-setup-dnat-to-ns.sh
  287. /etc/fstab
  288. /etc/pki/rpm-gpg/RPM-GPG-KEY-qubes*
  289. %config(noreplace) /etc/polkit-1/localauthority/50-local.d/qubes-allow-all.pkla
  290. %config(noreplace) /etc/polkit-1/rules.d/00-qubes-allow-all.rules
  291. %dir /etc/qubes-rpc
  292. %config(noreplace) /etc/qubes-rpc/qubes.Filecopy
  293. %config(noreplace) /etc/qubes-rpc/qubes.OpenInVM
  294. %config(noreplace) /etc/qubes-rpc/qubes.GetAppmenus
  295. %config(noreplace) /etc/qubes-rpc/qubes.VMShell
  296. %config(noreplace) /etc/qubes-rpc/qubes.SyncNtpClock
  297. %config(noreplace) /etc/qubes-rpc/qubes.SuspendPre
  298. %config(noreplace) /etc/qubes-rpc/qubes.SuspendPost
  299. %config(noreplace) /etc/qubes-rpc/qubes.WaitForSession
  300. %config(noreplace) /etc/qubes-rpc/qubes.DetachPciDevice
  301. %config(noreplace) /etc/qubes-rpc/qubes.Backup
  302. %config(noreplace) /etc/qubes-rpc/qubes.Restore
  303. %config(noreplace) /etc/qubes-rpc/qubes.SelectFile
  304. %config(noreplace) /etc/qubes-rpc/qubes.SelectDirectory
  305. %config(noreplace) /etc/qubes-rpc/qubes.GetImageRGBA
  306. %config(noreplace) /etc/qubes-rpc/qubes.SetDateTime
  307. %config(noreplace) /etc/sudoers.d/qubes
  308. %config(noreplace) /etc/sysconfig/iptables.qubes
  309. %config(noreplace) /etc/sysconfig/ip6tables.qubes
  310. /usr/lib/qubes/init/iptables
  311. /usr/lib/qubes/init/ip6tables
  312. %config(noreplace) /etc/tinyproxy/filter-updates
  313. %config(noreplace) /etc/tinyproxy/tinyproxy-updates.conf
  314. %config(noreplace) /etc/udev/rules.d/50-qubes-misc.rules
  315. %config(noreplace) /etc/udev/rules.d/99-qubes-network.rules
  316. /etc/xdg/autostart/00-qubes-show-hide-nm-applet.desktop
  317. /etc/xen/scripts/vif-route-qubes
  318. %config(noreplace) /etc/yum.conf.d/qubes-proxy.conf
  319. %config(noreplace) /etc/yum.repos.d/qubes-r3.repo
  320. /etc/yum/pluginconf.d/yum-qubes-hooks.conf
  321. /etc/yum/post-actions/qubes-trigger-sync-appmenus.action
  322. /etc/yum/post-actions/qubes-trigger-desktop-file-install.action
  323. /usr/lib/systemd/system/user@.service.d/90-session-stop-timeout.conf
  324. /usr/sbin/qubes-serial-login
  325. /usr/bin/qvm-copy-to-vm
  326. /usr/bin/qvm-move-to-vm
  327. /usr/bin/qvm-open-in-dvm
  328. /usr/bin/qvm-open-in-vm
  329. /usr/bin/qvm-run
  330. /usr/bin/qvm-mru-entry
  331. /usr/bin/xenstore-watch-qubes
  332. /usr/bin/qubes-desktop-run
  333. /usr/bin/qrexec-fork-server
  334. /usr/bin/qrexec-client-vm
  335. /usr/bin/qubes-desktop-file-install
  336. %dir /usr/lib/qubes
  337. /usr/lib/qubes/vusb-ctl.py*
  338. /usr/lib/qubes/dispvm-prerun.sh
  339. /usr/lib/qubes/sync-ntp-clock
  340. /usr/lib/qubes/prepare-suspend
  341. /usr/lib/qubes/network-manager-prepare-conf-dir
  342. /usr/lib/qubes/show-hide-nm-applet.sh
  343. /usr/lib/qubes/qrexec-agent
  344. /usr/lib/qubes/qrexec-client-vm
  345. /usr/lib/qubes/qrexec_client_vm
  346. /usr/lib/qubes/qubes-rpc-multiplexer
  347. /usr/lib/qubes/qfile-agent
  348. %attr(4755,root,root) /usr/lib/qubes/qfile-unpacker
  349. /usr/lib/qubes/qopen-in-vm
  350. /usr/lib/qubes/qrun-in-vm
  351. /usr/lib/qubes/qubes-download-dom0-updates.sh
  352. /usr/lib/qubes/qubes-fix-nm-conf.sh
  353. /usr/lib/qubes/qubes-setup-dnat-to-ns
  354. /usr/lib/qubes/qubes-trigger-sync-appmenus.sh
  355. /usr/lib/qubes/qvm-copy-to-vm.gnome
  356. /usr/lib/qubes/qvm-copy-to-vm.kde
  357. /usr/lib/qubes/qvm-move-to-vm.gnome
  358. /usr/lib/qubes/qvm-move-to-vm.kde
  359. /usr/lib/qubes/setup-ip
  360. /usr/lib/qubes/tar2qfile
  361. /usr/lib/qubes/vm-file-editor
  362. /usr/lib/qubes/wrap-in-html-if-url.sh
  363. /usr/lib/qubes/iptables-updates-proxy
  364. /usr/lib/qubes/close-window
  365. /usr/lib/qubes/qubes-trigger-desktop-file-install
  366. /usr/lib/yum-plugins/yum-qubes-hooks.py*
  367. /usr/sbin/qubes-firewall
  368. /usr/sbin/qubes-netwatcher
  369. /usr/share/qubes/serial.conf
  370. /usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.updates.gschema.override
  371. /usr/share/glib-2.0/schemas/org.gnome.nautilus.gschema.override
  372. /usr/share/glib-2.0/schemas/org.mate.NotificationDaemon.gschema.override
  373. /usr/share/nautilus-python/extensions/qvm_copy_nautilus.py*
  374. /usr/share/nautilus-python/extensions/qvm_move_nautilus.py*
  375. /usr/share/nautilus-python/extensions/qvm_dvm_nautilus.py*
  376. %dir /usr/share/qubes
  377. /usr/share/qubes/mime-override/globs
  378. %dir /home_volatile
  379. %attr(700,user,user) /home_volatile/user
  380. %dir /mnt/removable
  381. %dir /rw
  382. %package sysvinit
  383. Summary: Qubes unit files for SysV init style or upstart
  384. License: GPL v2 only
  385. Group: Qubes
  386. Requires: upstart
  387. Requires: qubes-core-vm
  388. Provides: qubes-core-vm-init-scripts
  389. Conflicts: qubes-core-vm-systemd
  390. %description sysvinit
  391. The Qubes core startup configuration for SysV init (or upstart).
  392. %files sysvinit
  393. /etc/init.d/qubes-core
  394. /etc/init.d/qubes-core-appvm
  395. /etc/init.d/qubes-core-netvm
  396. /etc/init.d/qubes-firewall
  397. /etc/init.d/qubes-netwatcher
  398. /etc/init.d/qubes-updates-proxy
  399. /etc/init.d/qubes-qrexec-agent
  400. /etc/sysconfig/modules/qubes-core.modules
  401. /etc/sysconfig/modules/qubes-misc.modules
  402. %post sysvinit
  403. #echo "--> Turning off unnecessary services..."
  404. # FIXME: perhaps there is more elegant way to do this?
  405. for f in /etc/init.d/*
  406. do
  407. srv=`basename $f`
  408. [ $srv = 'functions' ] && continue
  409. [ $srv = 'killall' ] && continue
  410. [ $srv = 'halt' ] && continue
  411. [ $srv = 'single' ] && continue
  412. [ $srv = 'reboot' ] && continue
  413. [ $srv = 'qubes-gui' ] && continue
  414. chkconfig $srv off
  415. done
  416. #echo "--> Enabling essential services..."
  417. chkconfig rsyslog on
  418. chkconfig haldaemon on
  419. chkconfig messagebus on
  420. chkconfig iptables on
  421. chkconfig ip6tables on
  422. chkconfig --add qubes-core || echo "WARNING: Cannot add service qubes-core!"
  423. chkconfig qubes-core on || echo "WARNING: Cannot enable service qubes-core!"
  424. chkconfig --add qubes-core-netvm || echo "WARNING: Cannot add service qubes-core-netvm!"
  425. chkconfig qubes-core-netvm on || echo "WARNING: Cannot enable service qubes-core-netvm!"
  426. chkconfig --add qubes-core-appvm || echo "WARNING: Cannot add service qubes-core-appvm!"
  427. chkconfig qubes-core-appvm on || echo "WARNING: Cannot enable service qubes-core-appvm!"
  428. chkconfig --add qubes-firewall || echo "WARNING: Cannot add service qubes-firewall!"
  429. chkconfig qubes-firewall on || echo "WARNING: Cannot enable service qubes-firewall!"
  430. chkconfig --add qubes-netwatcher || echo "WARNING: Cannot add service qubes-netwatcher!"
  431. chkconfig qubes-netwatcher on || echo "WARNING: Cannot enable service qubes-netwatcher!"
  432. chkconfig --add qubes-updates-proxy || echo "WARNING: Cannot add service qubes-updates-proxy!"
  433. chkconfig qubes-updates-proxy on || echo "WARNING: Cannot enable service qubes-updates-proxy!"
  434. chkconfig --add qubes-qrexec-agent || echo "WARNING: Cannot add service qubes-qrexec-agent!"
  435. chkconfig qubes-qrexec-agent on || echo "WARNING: Cannot enable service qubes-qrexec-agent!"
  436. # TODO: make this not display the silly message about security context...
  437. sed -i s/^id:.:initdefault:/id:3:initdefault:/ /etc/inittab
  438. %preun sysvinit
  439. if [ "$1" = 0 ] ; then
  440. # no more packages left
  441. chkconfig qubes-core off
  442. chkconfig qubes-core-netvm off
  443. chkconfig qubes-core-appvm off
  444. chkconfig qubes-firewall off
  445. chkconfig qubes-netwatcher off
  446. chkconfig qubes-updates-proxy off
  447. chkconfig qubes-qrexec-agent off
  448. fi
  449. %package systemd
  450. Summary: Qubes unit files for SystemD init style
  451. License: GPL v2 only
  452. Group: Qubes
  453. Requires: systemd
  454. Requires(post): systemd-units
  455. Requires(preun): systemd-units
  456. Requires(postun): systemd-units
  457. Requires: qubes-core-vm
  458. Provides: qubes-core-vm-init-scripts
  459. Conflicts: qubes-core-vm-sysvinit
  460. %description systemd
  461. The Qubes core startup configuration for SystemD init.
  462. %files systemd
  463. %defattr(-,root,root,-)
  464. /lib/systemd/system/qubes-dvm.service
  465. /lib/systemd/system/qubes-misc-post.service
  466. /lib/systemd/system/qubes-firewall.service
  467. /lib/systemd/system/qubes-mount-home.service
  468. /lib/systemd/system/qubes-netwatcher.service
  469. /lib/systemd/system/qubes-network.service
  470. /lib/systemd/system/qubes-sysinit.service
  471. /lib/systemd/system/qubes-update-check.service
  472. /lib/systemd/system/qubes-update-check.timer
  473. /lib/systemd/system/qubes-updates-proxy.service
  474. /lib/systemd/system/qubes-qrexec-agent.service
  475. /lib/systemd/system-preset/75-qubes-vm.preset
  476. /lib/modules-load.d/qubes-core.conf
  477. /lib/modules-load.d/qubes-misc.conf
  478. %dir /usr/lib/qubes/init
  479. /usr/lib/qubes/init/prepare-dvm.sh
  480. /usr/lib/qubes/init/network-proxy-setup.sh
  481. /usr/lib/qubes/init/misc-post.sh
  482. /usr/lib/qubes/init/misc-post-stop.sh
  483. /usr/lib/qubes/init/mount-home.sh
  484. /usr/lib/qubes/init/qubes-sysinit.sh
  485. /lib/systemd/system/chronyd.service.d/30_qubes.conf
  486. /lib/systemd/system/crond.service.d/30_qubes.conf
  487. /lib/systemd/system/cups.service.d/30_qubes.conf
  488. /lib/systemd/system/cups.socket.d/30_qubes.conf
  489. /lib/systemd/system/cups.path.d/30_qubes.conf
  490. /lib/systemd/system/getty@tty.service.d/30_qubes.conf
  491. /lib/systemd/system/ModemManager.service.d/30_qubes.conf
  492. /lib/systemd/system/NetworkManager.service.d/30_qubes.conf
  493. /lib/systemd/system/NetworkManager-wait-online.service.d/30_qubes.conf
  494. /lib/systemd/system/ntpd.service.d/30_qubes.conf
  495. %post systemd
  496. PRESET_FAILED=0
  497. if [ $1 -eq 1 ]; then
  498. /bin/systemctl --no-reload preset-all > /dev/null 2>&1 && PRESET_FAILED=0 || PRESET_FAILED=1
  499. else
  500. services="qubes-dvm qubes-misc-post qubes-firewall qubes-mount-home"
  501. services="$services qubes-netwatcher qubes-network qubes-sysinit"
  502. services="$services qubes-updates-proxy qubes-qrexec-agent"
  503. for srv in $services; do
  504. /bin/systemctl --no-reload preset $srv.service
  505. done
  506. /bin/systemctl --no-reload preset qubes-update-check.timer
  507. fi
  508. # Set default "runlevel"
  509. rm -f /etc/systemd/system/default.target
  510. ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
  511. grep '^[[:space:]]*[^#;]' /lib/systemd/system-preset/75-qubes-vm.preset | while read action unit_name; do
  512. case "$action" in
  513. (disable)
  514. if [ -f /lib/systemd/system/$unit_name ]; then
  515. if ! fgrep -q '[Install]' /lib/systemd/system/$unit_name; then
  516. # forcibly disable
  517. ln -sf /dev/null /etc/systemd/system/$unit_name
  518. fi
  519. fi
  520. ;;
  521. *)
  522. # preset-all is not available in fc20; so preset each unit file listed in 75-qubes-vm.preset
  523. if [ $1 -eq 1 -a "${PRESET_FAILED}" -eq 1 ]; then
  524. systemctl --no-reload preset "${unit_name}" > /dev/null 2>&1 || true
  525. fi
  526. ;;
  527. esac
  528. done
  529. /bin/systemctl daemon-reload
  530. exit 0
  531. %postun systemd
  532. #Do not run this part on upgrades
  533. if [ "$1" != 0 ] ; then
  534. exit 0
  535. fi
  536. for srv in qubes-dvm qubes-sysinit qubes-misc-post qubes-mount-home qubes-netwatcher qubes-network qubes-qrexec-agent; do
  537. /bin/systemctl disable $srv.service
  538. do