core-vm.spec 21 KB

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