core-vm.spec 22 KB

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