core-vm.spec 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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-actions
  46. Requires: qubes-core-vm-kernel-placeholder
  47. Requires: qubes-utils
  48. Requires: initscripts
  49. %if %{fedora} >= 20
  50. # gpk-update-viewer required by qubes-manager
  51. Requires: gnome-packagekit-updater
  52. %endif
  53. Requires: ImageMagick
  54. Requires: fakeroot
  55. Requires: desktop-notification-daemon
  56. Requires: qubes-libvchan
  57. Requires: qubes-db-vm
  58. Provides: qubes-core-vm
  59. Obsoletes: qubes-core-commonvm
  60. Obsoletes: qubes-core-appvm
  61. Obsoletes: qubes-core-netvm
  62. Obsoletes: qubes-core-proxyvm
  63. Obsoletes: qubes-upgrade-vm < 2.0
  64. BuildRequires: xen-devel
  65. BuildRequires: qubes-utils-devel >= 2.0.5
  66. BuildRequires: qubes-libvchan-%{backend_vmm}-devel
  67. %define _builddir %(pwd)
  68. %define kde_service_dir /usr/share/kde4/services
  69. %description
  70. The Qubes core files for installation inside a Qubes VM.
  71. %prep
  72. # we operate on the current directory, so no need to unpack anything
  73. # symlink is to generate useful debuginfo packages
  74. rm -f %{name}-%{version}
  75. ln -sf . %{name}-%{version}
  76. %setup -T -D
  77. %build
  78. for dir in qubes-rpc qrexec misc; do
  79. (cd $dir; make)
  80. done
  81. %pre
  82. if [ "$1" != 1 ] ; then
  83. # do this whole %pre thing only when updating for the first time...
  84. exit 0
  85. fi
  86. mkdir -p /var/lib/qubes
  87. if [ -e /etc/fstab ] ; then
  88. mv /etc/fstab /var/lib/qubes/fstab.orig
  89. fi
  90. adduser --create-home user
  91. usermod -p '' root
  92. usermod -L user
  93. %install
  94. (cd qrexec; make install DESTDIR=$RPM_BUILD_ROOT)
  95. make install-vm DESTDIR=$RPM_BUILD_ROOT
  96. # Create ghost files to silent rpmbuild warnings, those files will NOT be
  97. # included in package
  98. mkdir -p $RPM_BUILD_ROOT/etc/systemd/system
  99. for f in ModemManager.service NetworkManager.service \
  100. NetworkManager-wait-online.service cups.service cups.socket cups.path; do
  101. cp $RPM_BUILD_ROOT/usr/lib/qubes/init/$f $RPM_BUILD_ROOT/etc/systemd/system/
  102. done
  103. %triggerin -- initscripts
  104. if [ -e /etc/init/serial.conf ]; then
  105. cp /usr/share/qubes/serial.conf /etc/init/serial.conf
  106. fi
  107. %triggerin -- pulseaudio-module-x11
  108. sed -i '/^\(Not\|Only\)ShowIn/d' /etc/xdg/autostart/pulseaudio.desktop
  109. echo 'NotShowIn=QUBES;' >> /etc/xdg/autostart/pulseaudio.desktop
  110. %post
  111. # disable some Upstart services
  112. for F in plymouth-shutdown prefdm splash-manager start-ttys tty ; do
  113. if [ -e /etc/init/$F.conf ]; then
  114. mv -f /etc/init/$F.conf /etc/init/$F.conf.disabled
  115. fi
  116. done
  117. remove_ShowIn () {
  118. if [ -e /etc/xdg/autostart/$1.desktop ]; then
  119. sed -i '/^\(Not\|Only\)ShowIn/d' /etc/xdg/autostart/$1.desktop
  120. fi
  121. }
  122. # reenable if disabled by some earlier version of package
  123. remove_ShowIn abrt-applet.desktop imsettings-start.desktop
  124. # don't want it at all
  125. for F in deja-dup-monitor krb5-auth-dialog pulseaudio restorecond sealertauto gnome-power-manager gnome-sound-applet gnome-screensaver orca-autostart; do
  126. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  127. remove_ShowIn $F
  128. echo 'NotShowIn=QUBES;' >> /etc/xdg/autostart/$F.desktop
  129. fi
  130. done
  131. # don't want it in DisposableVM
  132. for F in gcm-apply ; do
  133. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  134. remove_ShowIn $F
  135. echo 'NotShowIn=DisposableVM;' >> /etc/xdg/autostart/$F.desktop
  136. fi
  137. done
  138. # want it in AppVM only
  139. for F in gnome-keyring-gpg gnome-keyring-pkcs11 gnome-keyring-secrets gnome-keyring-ssh gnome-settings-daemon user-dirs-update-gtk gsettings-data-convert ; do
  140. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  141. remove_ShowIn $F
  142. echo 'OnlyShowIn=GNOME;AppVM;' >> /etc/xdg/autostart/$F.desktop
  143. fi
  144. done
  145. # remove existing rule to add own later
  146. for F in gpk-update-icon nm-applet ; do
  147. remove_ShowIn $F
  148. done
  149. echo 'OnlyShowIn=GNOME;UpdateableVM;' >> /etc/xdg/autostart/gpk-update-icon.desktop || :
  150. %if %{fedora} >= 20
  151. echo 'OnlyShowIn=GNOME;QUBES;' >> /etc/xdg/autostart/nm-applet.desktop || :
  152. %else
  153. echo 'OnlyShowIn=GNOME;NetVM;' >> /etc/xdg/autostart/nm-applet.desktop || :
  154. %endif
  155. # Create NetworkManager configuration if we do not have it
  156. if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
  157. echo '[main]' > /etc/NetworkManager/NetworkManager.conf
  158. echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
  159. echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
  160. fi
  161. /usr/lib/qubes/qubes-fix-nm-conf.sh
  162. # Remove ip_forward setting from sysctl, so NM will not reset it
  163. sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
  164. # Remove old firmware updates link
  165. if [ -L /lib/firmware/updates ]; then
  166. rm -f /lib/firmware/updates
  167. fi
  168. if ! grep -q '/etc/yum\.conf\.d/qubes-proxy\.conf' /etc/yum.conf; then
  169. echo >> /etc/yum.conf
  170. echo '# Yum does not support inclusion of config dir...' >> /etc/yum.conf
  171. echo 'include=file:///etc/yum.conf.d/qubes-proxy.conf' >> /etc/yum.conf
  172. fi
  173. # Revert 'Prevent unnecessary updates in VMs':
  174. sed -i -e '/^exclude = kernel/d' /etc/yum.conf
  175. # qubes-core-vm has been broken for some time - it overrides /etc/hosts; restore original content
  176. if ! grep -q localhost /etc/hosts; then
  177. cat <<EOF > /etc/hosts
  178. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 `hostname`
  179. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  180. EOF
  181. fi
  182. # ensure that hostname resolves to 127.0.0.1 resp. ::1 and that /etc/hosts is
  183. # in the form expected by qubes-sysinit.sh
  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. if [ "$1" != 1 ] ; then
  193. # do the rest of %post thing only when updating for the first time...
  194. exit 0
  195. fi
  196. if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
  197. cp /etc/init/serial.conf /var/lib/qubes/serial.orig
  198. fi
  199. # Remove most of the udev scripts to speed up the VM boot time
  200. # Just leave the xen* scripts, that are needed if this VM was
  201. # ever used as a net backend (e.g. as a VPN domain in the future)
  202. #echo "--> Removing unnecessary udev scripts..."
  203. mkdir -p /var/lib/qubes/removed-udev-scripts
  204. for f in /etc/udev/rules.d/*
  205. do
  206. if [ $(basename $f) == "xen-backend.rules" ] ; then
  207. continue
  208. fi
  209. if [ $(basename $f) == "50-qubes-misc.rules" ] ; then
  210. continue
  211. fi
  212. if echo $f | grep -q qubes; then
  213. continue
  214. fi
  215. mv $f /var/lib/qubes/removed-udev-scripts/
  216. done
  217. mkdir -p /rw
  218. #rm -f /etc/mtab
  219. #echo "--> Removing HWADDR setting from /etc/sysconfig/network-scripts/ifcfg-eth0"
  220. #mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.orig
  221. #grep -v HWADDR /etc/sysconfig/network-scripts/ifcfg-eth0.orig > /etc/sysconfig/network-scripts/ifcfg-eth0
  222. %triggerin -- notification-daemon
  223. # Enable autostart of notification-daemon when installed
  224. if [ ! -e /etc/xdg/autostart/notification-daemon.desktop ]; then
  225. ln -s /usr/share/applications/notification-daemon.desktop /etc/xdg/autostart/
  226. fi
  227. exit 0
  228. %triggerin -- selinux-policy
  229. #echo "--> Disabling SELinux..."
  230. sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  231. mv /etc/selinux/config.processed /etc/selinux/config
  232. setenforce 0 2>/dev/null
  233. exit 0
  234. %preun
  235. if [ "$1" = 0 ] ; then
  236. # no more packages left
  237. if [ -e /var/lib/qubes/fstab.orig ] ; then
  238. mv /var/lib/qubes/fstab.orig /etc/fstab
  239. fi
  240. mv /var/lib/qubes/removed-udev-scripts/* /etc/udev/rules.d/
  241. if [ -e /var/lib/qubes/serial.orig ] ; then
  242. mv /var/lib/qubes/serial.orig /etc/init/serial.conf
  243. fi
  244. fi
  245. %postun
  246. if [ $1 -eq 0 ] ; then
  247. /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
  248. if [ -L /lib/firmware/updates ]; then
  249. rm /lib/firmware/updates
  250. fi
  251. fi
  252. %posttrans
  253. /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
  254. %clean
  255. rm -rf $RPM_BUILD_ROOT
  256. rm -f %{name}-%{version}
  257. %files
  258. %defattr(-,root,root,-)
  259. %dir /var/lib/qubes
  260. %dir /var/run/qubes
  261. %dir %attr(0775,user,user) /var/lib/qubes/dom0-updates
  262. %{kde_service_dir}/qvm-copy.desktop
  263. %{kde_service_dir}/qvm-move.desktop
  264. %{kde_service_dir}/qvm-dvm.desktop
  265. /etc/NetworkManager/dispatcher.d/30-qubes-external-ip
  266. /etc/NetworkManager/dispatcher.d/qubes-nmhook
  267. %config(noreplace) /etc/X11/xorg-preload-apps.conf
  268. /etc/dispvm-dotfiles.tbz
  269. /etc/dhclient.d/qubes-setup-dnat-to-ns.sh
  270. /etc/fstab
  271. /etc/pki/rpm-gpg/RPM-GPG-KEY-qubes*
  272. %config(noreplace) /etc/polkit-1/localauthority/50-local.d/qubes-allow-all.pkla
  273. %config(noreplace) /etc/polkit-1/rules.d/00-qubes-allow-all.rules
  274. %dir /etc/qubes-rpc
  275. /etc/qubes-rpc/qubes.Filecopy
  276. /etc/qubes-rpc/qubes.OpenInVM
  277. /etc/qubes-rpc/qubes.GetAppmenus
  278. /etc/qubes-rpc/qubes.VMShell
  279. /etc/qubes-rpc/qubes.SyncNtpClock
  280. /etc/qubes-rpc/qubes.SuspendPre
  281. /etc/qubes-rpc/qubes.SuspendPost
  282. /etc/qubes-rpc/qubes.WaitForSession
  283. /etc/qubes-rpc/qubes.DetachPciDevice
  284. /etc/qubes-rpc/qubes.Backup
  285. /etc/qubes-rpc/qubes.Restore
  286. /etc/qubes-rpc/qubes.SelectFile
  287. /etc/qubes-rpc/qubes.SelectDirectory
  288. /etc/qubes-rpc/qubes.GetImageRGBA
  289. /etc/qubes-rpc/qubes.SetDateTime
  290. %config(noreplace) /etc/sudoers.d/qubes
  291. %config(noreplace) /etc/sysconfig/iptables
  292. %config(noreplace) /etc/sysconfig/ip6tables
  293. %config(noreplace) /etc/tinyproxy/filter-updates
  294. %config(noreplace) /etc/tinyproxy/tinyproxy-updates.conf
  295. %config(noreplace) /etc/udev/rules.d/50-qubes-misc.rules
  296. %config(noreplace) /etc/udev/rules.d/99-qubes-network.rules
  297. /etc/xdg/autostart/00-qubes-show-hide-nm-applet.desktop
  298. /etc/xdg/nautilus-actions/nautilus-actions.conf
  299. /etc/xen/scripts/vif-route-qubes
  300. %config(noreplace) /etc/yum.conf.d/qubes-proxy.conf
  301. %config(noreplace) /etc/yum.repos.d/qubes-r3.repo
  302. /etc/yum/pluginconf.d/yum-qubes-hooks.conf
  303. /etc/yum/post-actions/qubes-trigger-sync-appmenus.action
  304. /usr/lib/systemd/system/user@.service.d/90-session-stop-timeout.conf
  305. /usr/sbin/qubes-serial-login
  306. /usr/bin/qvm-copy-to-vm
  307. /usr/bin/qvm-move-to-vm
  308. /usr/bin/qvm-open-in-dvm
  309. /usr/bin/qvm-open-in-vm
  310. /usr/bin/qvm-run
  311. /usr/bin/qvm-mru-entry
  312. /usr/bin/xenstore-watch-qubes
  313. /usr/bin/qubes-desktop-run
  314. %dir /usr/lib/qubes
  315. /usr/lib/qubes/vusb-ctl.py*
  316. /usr/lib/qubes/dispvm-prerun.sh
  317. /usr/lib/qubes/sync-ntp-clock
  318. /usr/lib/qubes/prepare-suspend
  319. /usr/lib/qubes/network-manager-prepare-conf-dir
  320. /usr/lib/qubes/show-hide-nm-applet.sh
  321. /usr/lib/qubes/qrexec-agent
  322. /usr/lib/qubes/qrexec-client-vm
  323. /usr/lib/qubes/qrexec_client_vm
  324. /usr/lib/qubes/qubes-rpc-multiplexer
  325. /usr/lib/qubes/qfile-agent
  326. %attr(4755,root,root) /usr/lib/qubes/qfile-unpacker
  327. /usr/lib/qubes/qopen-in-vm
  328. /usr/lib/qubes/qrun-in-vm
  329. /usr/lib/qubes/qubes-download-dom0-updates.sh
  330. /usr/lib/qubes/qubes-fix-nm-conf.sh
  331. /usr/lib/qubes/qubes-setup-dnat-to-ns
  332. /usr/lib/qubes/qubes-trigger-sync-appmenus.sh
  333. /usr/lib/qubes/qvm-copy-to-vm.gnome
  334. /usr/lib/qubes/qvm-copy-to-vm.kde
  335. /usr/lib/qubes/qvm-move-to-vm.gnome
  336. /usr/lib/qubes/qvm-move-to-vm.kde
  337. /usr/lib/qubes/setup-ip
  338. /usr/lib/qubes/tar2qfile
  339. /usr/lib/qubes/vm-file-editor
  340. /usr/lib/qubes/wrap-in-html-if-url.sh
  341. /usr/lib/qubes/iptables-updates-proxy
  342. /usr/lib/qubes/close-window
  343. /usr/lib/yum-plugins/yum-qubes-hooks.py*
  344. /usr/sbin/qubes-firewall
  345. /usr/sbin/qubes-netwatcher
  346. /usr/share/qubes/serial.conf
  347. /usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.updates.gschema.override
  348. /usr/share/glib-2.0/schemas/org.gnome.nautilus.gschema.override
  349. /usr/share/file-manager/actions/qvm-copy-gnome.desktop
  350. /usr/share/file-manager/actions/qvm-move-gnome.desktop
  351. /usr/share/file-manager/actions/qvm-dvm-gnome.desktop
  352. %dir /usr/share/qubes
  353. /usr/share/qubes/mime-override/globs
  354. %dir /home_volatile
  355. %attr(700,user,user) /home_volatile/user
  356. %dir /mnt/removable
  357. %dir /rw
  358. %package sysvinit
  359. Summary: Qubes unit files for SysV init style or upstart
  360. License: GPL v2 only
  361. Group: Qubes
  362. Requires: upstart
  363. Requires: qubes-core-vm
  364. Provides: qubes-core-vm-init-scripts
  365. Conflicts: qubes-core-vm-systemd
  366. %description sysvinit
  367. The Qubes core startup configuration for SysV init (or upstart).
  368. %files sysvinit
  369. /etc/init.d/qubes-core
  370. /etc/init.d/qubes-core-appvm
  371. /etc/init.d/qubes-core-netvm
  372. /etc/init.d/qubes-firewall
  373. /etc/init.d/qubes-netwatcher
  374. /etc/init.d/qubes-updates-proxy
  375. /etc/init.d/qubes-qrexec-agent
  376. /etc/sysconfig/modules/qubes-core.modules
  377. /etc/sysconfig/modules/qubes-misc.modules
  378. %post sysvinit
  379. #echo "--> Turning off unnecessary services..."
  380. # FIXME: perhaps there is more elegant way to do this?
  381. for f in /etc/init.d/*
  382. do
  383. srv=`basename $f`
  384. [ $srv = 'functions' ] && continue
  385. [ $srv = 'killall' ] && continue
  386. [ $srv = 'halt' ] && continue
  387. [ $srv = 'single' ] && continue
  388. [ $srv = 'reboot' ] && continue
  389. [ $srv = 'qubes-gui' ] && continue
  390. chkconfig $srv off
  391. done
  392. #echo "--> Enabling essential services..."
  393. chkconfig rsyslog on
  394. chkconfig haldaemon on
  395. chkconfig messagebus on
  396. chkconfig iptables on
  397. chkconfig ip6tables on
  398. chkconfig --add qubes-core || echo "WARNING: Cannot add service qubes-core!"
  399. chkconfig qubes-core on || echo "WARNING: Cannot enable service qubes-core!"
  400. chkconfig --add qubes-core-netvm || echo "WARNING: Cannot add service qubes-core-netvm!"
  401. chkconfig qubes-core-netvm on || echo "WARNING: Cannot enable service qubes-core-netvm!"
  402. chkconfig --add qubes-core-appvm || echo "WARNING: Cannot add service qubes-core-appvm!"
  403. chkconfig qubes-core-appvm on || echo "WARNING: Cannot enable service qubes-core-appvm!"
  404. chkconfig --add qubes-firewall || echo "WARNING: Cannot add service qubes-firewall!"
  405. chkconfig qubes-firewall on || echo "WARNING: Cannot enable service qubes-firewall!"
  406. chkconfig --add qubes-netwatcher || echo "WARNING: Cannot add service qubes-netwatcher!"
  407. chkconfig qubes-netwatcher on || echo "WARNING: Cannot enable service qubes-netwatcher!"
  408. chkconfig --add qubes-updates-proxy || echo "WARNING: Cannot add service qubes-updates-proxy!"
  409. chkconfig qubes-updates-proxy on || echo "WARNING: Cannot enable service qubes-updates-proxy!"
  410. chkconfig --add qubes-qrexec-agent || echo "WARNING: Cannot add service qubes-qrexec-agent!"
  411. chkconfig qubes-qrexec-agent on || echo "WARNING: Cannot enable service qubes-qrexec-agent!"
  412. # TODO: make this not display the silly message about security context...
  413. sed -i s/^id:.:initdefault:/id:3:initdefault:/ /etc/inittab
  414. %preun sysvinit
  415. if [ "$1" = 0 ] ; then
  416. # no more packages left
  417. chkconfig qubes-core off
  418. chkconfig qubes-core-netvm off
  419. chkconfig qubes-core-appvm off
  420. chkconfig qubes-firewall off
  421. chkconfig qubes-netwatcher off
  422. chkconfig qubes-updates-proxy off
  423. chkconfig qubes-qrexec-agent off
  424. fi
  425. %package systemd
  426. Summary: Qubes unit files for SystemD init style
  427. License: GPL v2 only
  428. Group: Qubes
  429. Requires: systemd
  430. Requires(post): systemd-units
  431. Requires(preun): systemd-units
  432. Requires(postun): systemd-units
  433. Requires: qubes-core-vm
  434. Provides: qubes-core-vm-init-scripts
  435. Conflicts: qubes-core-vm-sysvinit
  436. %description systemd
  437. The Qubes core startup configuration for SystemD init.
  438. %files systemd
  439. %defattr(-,root,root,-)
  440. /lib/systemd/system/qubes-dvm.service
  441. /lib/systemd/system/qubes-misc-post.service
  442. /lib/systemd/system/qubes-firewall.service
  443. /lib/systemd/system/qubes-netwatcher.service
  444. /lib/systemd/system/qubes-network.service
  445. /lib/systemd/system/qubes-sysinit.service
  446. /lib/systemd/system/qubes-update-check.service
  447. /lib/systemd/system/qubes-update-check.timer
  448. /lib/systemd/system/qubes-updates-proxy.service
  449. /lib/systemd/system/qubes-qrexec-agent.service
  450. /lib/modules-load.d/qubes-core.conf
  451. /lib/modules-load.d/qubes-misc.conf
  452. %dir /usr/lib/qubes/init
  453. /usr/lib/qubes/init/prepare-dvm.sh
  454. /usr/lib/qubes/init/network-proxy-setup.sh
  455. /usr/lib/qubes/init/misc-post.sh
  456. /usr/lib/qubes/init/misc-post-stop.sh
  457. /usr/lib/qubes/init/qubes-sysinit.sh
  458. /usr/lib/qubes/init/ModemManager.service
  459. /usr/lib/qubes/init/NetworkManager.service
  460. /usr/lib/qubes/init/NetworkManager-wait-online.service
  461. /usr/lib/qubes/init/cups.service
  462. /usr/lib/qubes/init/cups.socket
  463. /usr/lib/qubes/init/cups.path
  464. /usr/lib/qubes/init/ntpd.service
  465. /usr/lib/qubes/init/chronyd.service
  466. %ghost %attr(0644,root,root) /etc/systemd/system/ModemManager.service
  467. %ghost %attr(0644,root,root) /etc/systemd/system/NetworkManager.service
  468. %ghost %attr(0644,root,root) /etc/systemd/system/NetworkManager-wait-online.service
  469. %ghost %attr(0644,root,root) /etc/systemd/system/cups.service
  470. %ghost %attr(0644,root,root) /etc/systemd/system/cups.socket
  471. %ghost %attr(0644,root,root) /etc/systemd/system/cups.path
  472. %post systemd
  473. for srv in qubes-dvm qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network qubes-firewall qubes-updates-proxy qubes-qrexec-agent; do
  474. /bin/systemctl enable $srv.service 2> /dev/null
  475. done
  476. /bin/systemctl enable qubes-update-check.timer 2> /dev/null
  477. UNITDIR=/lib/systemd/system
  478. OVERRIDEDIR=/usr/lib/qubes/init
  479. # Install overriden services only when original exists
  480. for srv in cups ModemManager NetworkManager NetworkManager-wait-online ntpd chronyd; do
  481. if [ -f $UNITDIR/$srv.service ]; then
  482. cp $OVERRIDEDIR/$srv.service /etc/systemd/system/
  483. fi
  484. if [ -f $UNITDIR/$srv.socket -a -f $OVERRIDEDIR/$srv.socket ]; then
  485. cp $OVERRIDEDIR/$srv.socket /etc/systemd/system/
  486. fi
  487. if [ -f $UNITDIR/$srv.path -a -f $OVERRIDEDIR/$srv.path ]; then
  488. cp $OVERRIDEDIR/$srv.path /etc/systemd/system/
  489. fi
  490. done
  491. # Set default "runlevel"
  492. rm -f /etc/systemd/system/default.target
  493. ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
  494. DISABLE_SERVICES="alsa-store alsa-restore auditd avahi avahi-daemon backuppc cpuspeed crond"
  495. DISABLE_SERVICES="$DISABLE_SERVICES fedora-autorelabel fedora-autorelabel-mark ipmi hwclock-load hwclock-save"
  496. DISABLE_SERVICES="$DISABLE_SERVICES mdmonitor multipathd openct rpcbind mcelog fedora-storage-init fedora-storage-init-late"
  497. DISABLE_SERVICES="$DISABLE_SERVICES plymouth-start plymouth-read-write plymouth-quit plymouth-quit-wait"
  498. DISABLE_SERVICES="$DISABLE_SERVICES sshd tcsd sm-client sendmail mdmonitor-takeover"
  499. DISABLE_SERVICES="$DISABLE_SERVICES rngd smartd upower irqbalance colord"
  500. for srv in $DISABLE_SERVICES; do
  501. if [ -f /lib/systemd/system/$srv.service ]; then
  502. if fgrep -q '[Install]' /lib/systemd/system/$srv.service; then
  503. /bin/systemctl disable $srv.service 2> /dev/null
  504. else
  505. # forcibly disable
  506. ln -sf /dev/null /etc/systemd/system/$srv.service
  507. fi
  508. fi
  509. done
  510. rm -f /etc/systemd/system/getty.target.wants/getty@tty*.service
  511. # Enable some services
  512. /bin/systemctl enable iptables.service 2> /dev/null
  513. /bin/systemctl enable ip6tables.service 2> /dev/null
  514. /bin/systemctl enable rsyslog.service 2> /dev/null
  515. /bin/systemctl enable ntpd.service 2> /dev/null
  516. # Enable cups only when it is real SystemD service
  517. [ -e /lib/systemd/system/cups.service ] && /bin/systemctl enable cups.service 2> /dev/null
  518. exit 0
  519. %triggerin systemd -- NetworkManager
  520. UNITDIR=/lib/systemd/system
  521. OVERRIDEDIR=/usr/lib/qubes/init
  522. # Install overriden services only when original exists
  523. for srv in ModemManager NetworkManager NetworkManager-wait-online; do
  524. if [ -f $UNITDIR/$srv.service ]; then
  525. cp $OVERRIDEDIR/$srv.service /etc/systemd/system/
  526. fi
  527. if [ -f $UNITDIR/$srv.socket -a -f $OVERRIDEDIR/$srv.socket ]; then
  528. cp $OVERRIDEDIR/$srv.socket /etc/systemd/system/
  529. fi
  530. if [ -f $UNITDIR/$srv.path -a -f $OVERRIDEDIR/$srv.path ]; then
  531. cp $OVERRIDEDIR/$srv.path /etc/systemd/system/
  532. fi
  533. done
  534. # Disable original service to enable overriden one
  535. /bin/systemctl disable ModemManager.service 2> /dev/null
  536. /bin/systemctl disable NetworkManager.service 2> /dev/null
  537. # Disable D-BUS activation of NetworkManager - in AppVm it causes problems (eg PackageKit timeouts)
  538. /bin/systemctl mask dbus-org.freedesktop.NetworkManager.service 2> /dev/null
  539. /bin/systemctl enable ModemManager.service 2> /dev/null
  540. /bin/systemctl enable NetworkManager.service 2> /dev/null
  541. # Fix for https://bugzilla.redhat.com/show_bug.cgi?id=974811
  542. /bin/systemctl enable NetworkManager-dispatcher.service 2> /dev/null
  543. exit 0
  544. %triggerin systemd -- cups
  545. UNITDIR=/lib/systemd/system
  546. OVERRIDEDIR=/usr/lib/qubes/init
  547. # Install overriden services only when original exists
  548. for srv in cups; do
  549. if [ -f $UNITDIR/$srv.service ]; then
  550. cp $OVERRIDEDIR/$srv.service /etc/systemd/system/
  551. fi
  552. if [ -f $UNITDIR/$srv.socket -a -f $OVERRIDEDIR/$srv.socket ]; then
  553. cp $OVERRIDEDIR/$srv.socket /etc/systemd/system/
  554. fi
  555. if [ -f $UNITDIR/$srv.path -a -f $OVERRIDEDIR/$srv.path ]; then
  556. cp $OVERRIDEDIR/$srv.path /etc/systemd/system/
  557. fi
  558. done
  559. # Enable cups only when it is real SystemD service
  560. [ -e /lib/systemd/system/cups.service ] && /bin/systemctl enable cups.service 2> /dev/null
  561. exit 0
  562. %triggerin systemd -- haveged
  563. /bin/systemctl enable haveged.service 2> /dev/null
  564. exit 0
  565. %postun systemd
  566. #Do not run this part on upgrades
  567. if [ "$1" != 0 ] ; then
  568. exit 0
  569. fi
  570. for srv in qubes-dvm qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network qubes-qrexec-agent; do
  571. /bin/systemctl disable $srv.service
  572. do