core-vm.spec 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  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_vm)}
  23. Name: qubes-core-vm
  24. Version: %{version}
  25. Release: 1%{dist}
  26. Summary: The Qubes core files for VM
  27. Group: Qubes
  28. Vendor: Invisible Things Lab
  29. License: GPL
  30. URL: http://www.qubes-os.org
  31. Requires: /usr/bin/xenstore-read
  32. Requires: fedora-release
  33. Requires: yum-plugin-post-transaction-actions
  34. Requires: NetworkManager >= 0.8.1-1
  35. Requires: /usr/bin/mimeopen
  36. Requires: /sbin/ethtool
  37. Provides: qubes-core-vm
  38. Obsoletes: qubes-core-commonvm
  39. Obsoletes: qubes-core-appvm
  40. Obsoletes: qubes-core-netvm
  41. Obsoletes: qubes-core-proxyvm
  42. BuildRequires: xen-devel
  43. %define _builddir %(pwd)
  44. %define kde_service_dir /usr/share/kde4/services/ServiceMenus
  45. %description
  46. The Qubes core files for installation inside a Qubes VM.
  47. %build
  48. make -C u2mfn
  49. make -C vchan
  50. make -C misc
  51. make -C qubes_rpc
  52. make -C qrexec
  53. %pre
  54. if [ "$1" != 1 ] ; then
  55. # do this whole %pre thing only when updating for the first time...
  56. exit 0
  57. fi
  58. mkdir -p /var/lib/qubes
  59. if [ -e /etc/fstab ] ; then
  60. mv /etc/fstab /var/lib/qubes/fstab.orig
  61. fi
  62. adduser --create-home user
  63. su user -c 'mkdir -p /home/user/.local/share'
  64. su user -c 'mkdir -p /home/user/.gnome2/nautilus-scripts'
  65. su user -c 'ln -s /usr/lib/qubes/qvm-copy-to-vm.gnome /home/user/.gnome2/nautilus-scripts/"Copy to other AppVM"'
  66. su user -c 'ln -s /usr/bin/qvm-open-in-dvm /home/user/.gnome2/nautilus-scripts/"Open in DisposableVM"'
  67. su user -c 'touch /home/user/.gnome2/nautilus-scripts/.scripts_created'
  68. su user -c 'touch /home/user/.gnome2/nautilus-scripts/.scripts_created2'
  69. %install
  70. install -D misc/fstab $RPM_BUILD_ROOT/etc/fstab
  71. install -d $RPM_BUILD_ROOT/etc/init.d
  72. install vm-init.d/* $RPM_BUILD_ROOT/etc/init.d/
  73. install -d $RPM_BUILD_ROOT/lib/systemd/system $RPM_BUILD_ROOT/usr/lib/qubes/init
  74. install -m 0755 vm-systemd/*.sh $RPM_BUILD_ROOT/usr/lib/qubes/init/
  75. install -m 0644 vm-systemd/qubes-*.service $RPM_BUILD_ROOT/lib/systemd/system/
  76. install -m 0644 vm-systemd/NetworkManager.service $RPM_BUILD_ROOT/usr/lib/qubes/init/
  77. install -m 0644 vm-systemd/cups.service $RPM_BUILD_ROOT/usr/lib/qubes/init/
  78. install -m 0644 vm-systemd/ntpd.service $RPM_BUILD_ROOT/usr/lib/qubes/init/
  79. install -D -m 0440 misc/qubes.sudoers $RPM_BUILD_ROOT/etc/sudoers.d/qubes
  80. install -D -m 0644 misc/qubes.repo $RPM_BUILD_ROOT/etc/yum.repos.d/qubes.repo
  81. install -D -m 0644 misc/serial.conf $RPM_BUILD_ROOT/usr/lib/qubes/serial.conf
  82. install -D misc/qubes_serial_login $RPM_BUILD_ROOT/sbin/qubes_serial_login
  83. install -d $RPM_BUILD_ROOT/usr/share/glib-2.0/schemas/
  84. install -m 0644 misc/org.gnome.settings-daemon.plugins.updates.gschema.override $RPM_BUILD_ROOT/usr/share/glib-2.0/schemas/
  85. install -d $RPM_BUILD_ROOT/var/lib/qubes
  86. install -d -m 755 $RPM_BUILD_ROOT/etc/pki/rpm-gpg
  87. install -m 644 misc/RPM-GPG-KEY-qubes* $RPM_BUILD_ROOT/etc/pki/rpm-gpg/
  88. install -D misc/xenstore-watch $RPM_BUILD_ROOT/usr/bin/xenstore-watch-qubes
  89. install -d $RPM_BUILD_ROOT/etc/udev/rules.d
  90. install -m 0644 misc/qubes_memory.rules $RPM_BUILD_ROOT/etc/udev/rules.d/50-qubes_memory.rules
  91. install -m 0644 misc/qubes_block.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_block.rules
  92. install -d $RPM_BUILD_ROOT/usr/lib/qubes/
  93. install misc/qubes_download_dom0_updates.sh $RPM_BUILD_ROOT/usr/lib/qubes/
  94. install misc/{block_add_change,block_remove,block_cleanup} $RPM_BUILD_ROOT/usr/lib/qubes/
  95. install misc/qubes_trigger_sync_appmenus.sh $RPM_BUILD_ROOT/usr/lib/qubes/
  96. install -D -m 0644 misc/qubes_trigger_sync_appmenus.action $RPM_BUILD_ROOT/etc/yum/post-actions/qubes_trigger_sync_appmenus.action
  97. mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes
  98. install -D misc/qubes_core.modules $RPM_BUILD_ROOT/etc/sysconfig/modules/qubes_core.modules
  99. install network/qubes_network.rules $RPM_BUILD_ROOT/etc/udev/rules.d/99-qubes_network.rules
  100. install network/qubes_setup_dnat_to_ns $RPM_BUILD_ROOT/usr/lib/qubes
  101. install network/qubes_fix_nm_conf.sh $RPM_BUILD_ROOT/usr/lib/qubes
  102. install network/setup_ip $RPM_BUILD_ROOT/usr/lib/qubes/
  103. install network/network-manager-prepare-conf-dir $RPM_BUILD_ROOT/usr/lib/qubes/
  104. install -d $RPM_BUILD_ROOT/etc/dhclient.d
  105. ln -s /usr/lib/qubes/qubes_setup_dnat_to_ns $RPM_BUILD_ROOT/etc/dhclient.d/qubes_setup_dnat_to_ns.sh
  106. install -d $RPM_BUILD_ROOT/etc/NetworkManager/dispatcher.d/
  107. install network/{qubes_nmhook,30-qubes_external_ip} $RPM_BUILD_ROOT/etc/NetworkManager/dispatcher.d/
  108. install -D network/vif-route-qubes $RPM_BUILD_ROOT/etc/xen/scripts/vif-route-qubes
  109. install -D network/iptables $RPM_BUILD_ROOT/etc/sysconfig/iptables
  110. install -d $RPM_BUILD_ROOT/usr/sbin
  111. install network/qubes_firewall $RPM_BUILD_ROOT/usr/sbin/
  112. install network/qubes_netwatcher $RPM_BUILD_ROOT/usr/sbin/
  113. install -d $RPM_BUILD_ROOT/lib/firmware
  114. ln -s /lib/modules/firmware $RPM_BUILD_ROOT/lib/firmware/updates
  115. install -d $RPM_BUILD_ROOT/usr/bin
  116. install qubes_rpc/{qvm-open-in-dvm,qvm-open-in-vm,qvm-copy-to-vm,qvm-run} $RPM_BUILD_ROOT/usr/bin
  117. install qubes_rpc/wrap_in_html_if_url.sh $RPM_BUILD_ROOT/usr/lib/qubes
  118. install qubes_rpc/qvm-copy-to-vm.kde $RPM_BUILD_ROOT/usr/lib/qubes
  119. install qubes_rpc/qvm-copy-to-vm.gnome $RPM_BUILD_ROOT/usr/lib/qubes
  120. install qubes_rpc/{vm-file-editor,qfile-agent,qopen-in-vm,qfile-unpacker} $RPM_BUILD_ROOT/usr/lib/qubes
  121. install qubes_rpc/{vm-shell,qrun-in-vm} $RPM_BUILD_ROOT/usr/lib/qubes
  122. install -d $RPM_BUILD_ROOT/%{kde_service_dir}
  123. install -m 0644 qubes_rpc/{qvm-copy.desktop,qvm-dvm.desktop} $RPM_BUILD_ROOT/%{kde_service_dir}
  124. install -d $RPM_BUILD_ROOT/etc/qubes_rpc
  125. install -m 0644 qubes_rpc/{qubes.Filecopy,qubes.OpenInVM,qubes.VMShell} $RPM_BUILD_ROOT/etc/qubes_rpc
  126. install qrexec/qrexec_agent $RPM_BUILD_ROOT/usr/lib/qubes
  127. install qrexec/qrexec_client_vm $RPM_BUILD_ROOT/usr/lib/qubes
  128. install qrexec/qubes_rpc_multiplexer $RPM_BUILD_ROOT/usr/lib/qubes
  129. install misc/meminfo-writer $RPM_BUILD_ROOT/usr/lib/qubes
  130. install -d $RPM_BUILD_ROOT/mnt/removable
  131. install -d $RPM_BUILD_ROOT/var/lib/qubes/dom0-updates
  132. install -D -m 0644 misc/xorg-preload-apps.conf $RPM_BUILD_ROOT/etc/X11/xorg-preload-apps.conf
  133. install -d $RPM_BUILD_ROOT/var/run/qubes
  134. install -d $RPM_BUILD_ROOT/home_volatile/user
  135. install -D -m 0644 vchan/libvchan.h $RPM_BUILD_ROOT/usr/include/libvchan.h
  136. install -D -m 0644 u2mfn/u2mfnlib.h $RPM_BUILD_ROOT/usr/include/u2mfnlib.h
  137. install -D -m 0644 u2mfn/u2mfn-kernel.h $RPM_BUILD_ROOT/usr/include/u2mfn-kernel.h
  138. install -D vchan/libvchan.so $RPM_BUILD_ROOT/%{_libdir}/libvchan.so
  139. install -D u2mfn/libu2mfn.so $RPM_BUILD_ROOT/%{_libdir}/libu2mfn.so
  140. %triggerin -- initscripts
  141. cp /usr/lib/qubes/serial.conf /etc/init/serial.conf
  142. %post
  143. # disable some Upstart services
  144. for F in plymouth-shutdown prefdm splash-manager start-ttys tty ; do
  145. if [ -e /etc/init/$F.conf ]; then
  146. mv -f /etc/init/$F.conf /etc/init/$F.conf.disabled
  147. fi
  148. done
  149. remove_ShowIn () {
  150. if [ -e /etc/xdg/autostart/$1.desktop ]; then
  151. sed -i '/^\(Not\|Only\)ShowIn/d' /etc/xdg/autostart/$1.desktop
  152. fi
  153. }
  154. # don't want it at all
  155. for F in abrt-applet deja-dup-monitor imsettings-start krb5-auth-dialog pulseaudio restorecond sealertauto gnome-power-manager gnome-sound-applet gnome-screensaver orca-autostart; do
  156. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  157. remove_ShowIn $F
  158. echo 'NotShowIn=QUBES' >> /etc/xdg/autostart/$F.desktop
  159. fi
  160. done
  161. # don't want it in DisposableVM
  162. for F in gcm-apply ; do
  163. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  164. remove_ShowIn $F
  165. echo 'NotShowIn=DisposableVM' >> /etc/xdg/autostart/$F.desktop
  166. fi
  167. done
  168. # want it in AppVM only
  169. 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
  170. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  171. remove_ShowIn $F
  172. echo 'OnlyShowIn=GNOME;AppVM;' >> /etc/xdg/autostart/$F.desktop
  173. fi
  174. done
  175. # remove existing rule to add own later
  176. for F in gpk-update-icon nm-applet ; do
  177. remove_ShowIn $F
  178. done
  179. echo 'OnlyShowIn=GNOME;UpdateableVM;' >> /etc/xdg/autostart/gpk-update-icon.desktop || :
  180. echo 'OnlyShowIn=GNOME;NetVM;' >> /etc/xdg/autostart/nm-applet.desktop || :
  181. usermod -p '' root
  182. usermod -L user
  183. # Create NetworkManager configuration if we do not have it
  184. if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
  185. echo '[main]' > /etc/NetworkManager/NetworkManager.conf
  186. echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
  187. echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
  188. fi
  189. /usr/lib/qubes/qubes_fix_nm_conf.sh
  190. # Remove ip_forward setting from sysctl, so NM will not reset it
  191. sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
  192. # Prevent unnecessary updates in VMs:
  193. sed -i -e '/^exclude = kernel/d' /etc/yum.conf
  194. echo 'exclude = kernel, xorg-x11-drv-*, xorg-x11-drivers, xorg-x11-server-*' >> /etc/yum.conf
  195. if [ "$1" != 1 ] ; then
  196. # do the rest of %post thing only when updating for the first time...
  197. exit 0
  198. fi
  199. if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
  200. cp /etc/init/serial.conf /var/lib/qubes/serial.orig
  201. fi
  202. #echo "--> Disabling SELinux..."
  203. sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  204. mv /etc/selinux/config.processed /etc/selinux/config
  205. setenforce 0 2>/dev/null
  206. # Remove most of the udev scripts to speed up the VM boot time
  207. # Just leave the xen* scripts, that are needed if this VM was
  208. # ever used as a net backend (e.g. as a VPN domain in the future)
  209. #echo "--> Removing unnecessary udev scripts..."
  210. mkdir -p /var/lib/qubes/removed-udev-scripts
  211. for f in /etc/udev/rules.d/*
  212. do
  213. if [ $(basename $f) == "xen-backend.rules" ] ; then
  214. continue
  215. fi
  216. if [ $(basename $f) == "xend.rules" ] ; then
  217. continue
  218. fi
  219. if [ $(basename $f) == "99-qubes_network.rules" ] ; then
  220. continue
  221. fi
  222. if [ $(basename $f) == "99-qubes_block.rules" ] ; then
  223. continue
  224. fi
  225. if [ $(basename $f) == "90-hal.rules" ] ; then
  226. continue
  227. fi
  228. mv $f /var/lib/qubes/removed-udev-scripts/
  229. done
  230. mkdir -p /rw
  231. #rm -f /etc/mtab
  232. #echo "--> Removing HWADDR setting from /etc/sysconfig/network-scripts/ifcfg-eth0"
  233. #mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.orig
  234. #grep -v HWADDR /etc/sysconfig/network-scripts/ifcfg-eth0.orig > /etc/sysconfig/network-scripts/ifcfg-eth0
  235. %preun
  236. if [ "$1" = 0 ] ; then
  237. # no more packages left
  238. mv /var/lib/qubes/fstab.orig /etc/fstab
  239. mv /var/lib/qubes/removed-udev-scripts/* /etc/udev/rules.d/
  240. mv /var/lib/qubes/serial.orig /etc/init/serial.conf
  241. fi
  242. %postun
  243. if [ $1 -eq 0 ] ; then
  244. /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
  245. fi
  246. %posttrans
  247. /usr/bin/glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
  248. %clean
  249. rm -rf $RPM_BUILD_ROOT
  250. %files
  251. %defattr(-,root,root,-)
  252. %dir /var/lib/qubes
  253. %dir /var/run/qubes
  254. %dir %attr(0775,user,user) /var/lib/qubes/dom0-updates
  255. %{kde_service_dir}/qvm-copy.desktop
  256. %{kde_service_dir}/qvm-dvm.desktop
  257. /etc/NetworkManager/dispatcher.d/30-qubes_external_ip
  258. /etc/NetworkManager/dispatcher.d/qubes_nmhook
  259. /etc/X11/xorg-preload-apps.conf
  260. /etc/dhclient.d/qubes_setup_dnat_to_ns.sh
  261. /etc/fstab
  262. /etc/pki/rpm-gpg/RPM-GPG-KEY-qubes*
  263. %dir /etc/qubes_rpc
  264. /etc/qubes_rpc/qubes.Filecopy
  265. /etc/qubes_rpc/qubes.OpenInVM
  266. /etc/qubes_rpc/qubes.VMShell
  267. /etc/sudoers.d/qubes
  268. /etc/sysconfig/iptables
  269. /etc/sysconfig/modules/qubes_core.modules
  270. /etc/udev/rules.d/50-qubes_memory.rules
  271. /etc/udev/rules.d/99-qubes_block.rules
  272. /etc/udev/rules.d/99-qubes_network.rules
  273. /etc/xen/scripts/vif-route-qubes
  274. /etc/yum.repos.d/qubes.repo
  275. /etc/yum/post-actions/qubes_trigger_sync_appmenus.action
  276. /lib/firmware/updates
  277. /sbin/qubes_serial_login
  278. /usr/bin/qvm-copy-to-vm
  279. /usr/bin/qvm-open-in-dvm
  280. /usr/bin/qvm-open-in-vm
  281. /usr/bin/qvm-run
  282. /usr/bin/xenstore-watch-qubes
  283. %dir /usr/lib/qubes
  284. /usr/lib/qubes/block_add_change
  285. /usr/lib/qubes/block_cleanup
  286. /usr/lib/qubes/block_remove
  287. /usr/lib/qubes/meminfo-writer
  288. /usr/lib/qubes/network-manager-prepare-conf-dir
  289. /usr/lib/qubes/qfile-agent
  290. /usr/lib/qubes/qfile-unpacker
  291. /usr/lib/qubes/qopen-in-vm
  292. /usr/lib/qubes/qrexec_agent
  293. /usr/lib/qubes/qrexec_client_vm
  294. /usr/lib/qubes/qrun-in-vm
  295. /usr/lib/qubes/qubes_download_dom0_updates.sh
  296. /usr/lib/qubes/qubes_fix_nm_conf.sh
  297. /usr/lib/qubes/qubes_rpc_multiplexer
  298. /usr/lib/qubes/qubes_setup_dnat_to_ns
  299. /usr/lib/qubes/qubes_trigger_sync_appmenus.sh
  300. /usr/lib/qubes/qvm-copy-to-vm.gnome
  301. /usr/lib/qubes/qvm-copy-to-vm.kde
  302. /usr/lib/qubes/serial.conf
  303. /usr/lib/qubes/setup_ip
  304. /usr/lib/qubes/vm-file-editor
  305. /usr/lib/qubes/vm-shell
  306. /usr/lib/qubes/wrap_in_html_if_url.sh
  307. /usr/sbin/qubes_firewall
  308. /usr/sbin/qubes_netwatcher
  309. /usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.updates.gschema.override
  310. %dir /home_volatile
  311. %attr(700,user,user) /home_volatile/user
  312. %dir /mnt/removable
  313. %package devel
  314. Summary: Include files for qubes core libraries
  315. License: GPL v2 only
  316. Group: Development/Sources
  317. Obsoletes: qubes-core-appvm-devel
  318. %description devel
  319. %files devel
  320. /usr/include/libvchan.h
  321. /usr/include/u2mfnlib.h
  322. /usr/include/u2mfn-kernel.h
  323. %package libs
  324. Summary: Qubes core libraries
  325. License: GPL v2 only
  326. Group: Development/Sources
  327. Obsoletes: qubes-core-appvm-libs
  328. %description libs
  329. %files libs
  330. %{_libdir}/libvchan.so
  331. %{_libdir}/libu2mfn.so
  332. %package sysvinit
  333. Summary: Qubes unit files for SysV init style or upstart
  334. License: GPL v2 only
  335. Group: Qubes
  336. Requires: upstart
  337. Requires: qubes-core-vm
  338. Provides: qubes-core-vm-init-scripts
  339. Conflicts: qubes-core-vm-systemd
  340. %description sysvinit
  341. The Qubes core startup configuration for SysV init (or upstart).
  342. %files sysvinit
  343. /etc/init.d/qubes_core
  344. /etc/init.d/qubes_core_appvm
  345. /etc/init.d/qubes_core_netvm
  346. /etc/init.d/qubes_firewall
  347. /etc/init.d/qubes_netwatcher
  348. %post sysvinit
  349. #echo "--> Turning off unnecessary services..."
  350. # FIXME: perhaps there is more elegant way to do this?
  351. for f in /etc/init.d/*
  352. do
  353. srv=`basename $f`
  354. [ $srv = 'functions' ] && continue
  355. [ $srv = 'killall' ] && continue
  356. [ $srv = 'halt' ] && continue
  357. [ $srv = 'single' ] && continue
  358. [ $srv = 'reboot' ] && continue
  359. [ $srv = 'qubes_gui' ] && continue
  360. chkconfig $srv off
  361. done
  362. #echo "--> Enabling essential services..."
  363. chkconfig rsyslog on
  364. chkconfig haldaemon on
  365. chkconfig messagebus on
  366. chkconfig iptables on
  367. chkconfig --add qubes_core || echo "WARNING: Cannot add service qubes_core!"
  368. chkconfig qubes_core on || echo "WARNING: Cannot enable service qubes_core!"
  369. chkconfig --add qubes_core_netvm || echo "WARNING: Cannot add service qubes_core!"
  370. chkconfig qubes_core_netvm on || echo "WARNING: Cannot enable service qubes_core!"
  371. chkconfig --add qubes_core_appvm || echo "WARNING: Cannot add service qubes_core!"
  372. chkconfig qubes_core_appvm on || echo "WARNING: Cannot enable service qubes_core!"
  373. chkconfig --add qubes_firewall || echo "WARNING: Cannot add service qubes_core!"
  374. chkconfig qubes_firewall on || echo "WARNING: Cannot enable service qubes_core!"
  375. chkconfig --add qubes_netwatcher || echo "WARNING: Cannot add service qubes_core!"
  376. chkconfig qubes_netwatcher on || echo "WARNING: Cannot enable service qubes_core!"
  377. # TODO: make this not display the silly message about security context...
  378. sed -i s/^id:.:initdefault:/id:3:initdefault:/ /etc/inittab
  379. %preun sysvinit
  380. if [ "$1" = 0 ] ; then
  381. # no more packages left
  382. chkconfig qubes_core off
  383. chkconfig qubes_core_netvm off
  384. chkconfig qubes_core_appvm off
  385. chkconfig qubes_firewall off
  386. chkconfig qubes_netwatcher off
  387. fi
  388. %package systemd
  389. Summary: Qubes unit files for SystemD init style
  390. License: GPL v2 only
  391. Group: Qubes
  392. Requires: systemd
  393. Requires(post): systemd-units
  394. Requires(preun): systemd-units
  395. Requires(postun): systemd-units
  396. Requires: qubes-core-vm
  397. Provides: qubes-core-vm-init-scripts
  398. Conflicts: qubes-core-vm-sysvinit
  399. %description systemd
  400. The Qubes core startup configuration for SystemD init.
  401. %files systemd
  402. %defattr(-,root,root,-)
  403. /lib/systemd/system/qubes-dvm.service
  404. /lib/systemd/system/qubes-meminfo-writer.service
  405. /lib/systemd/system/qubes-qrexec-agent.service
  406. /lib/systemd/system/qubes-misc-post.service
  407. /lib/systemd/system/qubes-firewall.service
  408. /lib/systemd/system/qubes-netwatcher.service
  409. /lib/systemd/system/qubes-network.service
  410. /lib/systemd/system/qubes-sysinit.service
  411. %dir /usr/lib/qubes/init
  412. /usr/lib/qubes/init/prepare-dvm.sh
  413. /usr/lib/qubes/init/network-proxy-setup.sh
  414. /usr/lib/qubes/init/misc-post.sh
  415. /usr/lib/qubes/init/misc-post-stop.sh
  416. /usr/lib/qubes/init/qubes-sysinit.sh
  417. /usr/lib/qubes/init/NetworkManager.service
  418. /usr/lib/qubes/init/cups.service
  419. /usr/lib/qubes/init/ntpd.service
  420. %ghost %attr(0644,root,root) /etc/systemd/system/NetworkManager.service
  421. %ghost %attr(0644,root,root) /etc/systemd/system/cups.service
  422. %post systemd
  423. for srv in qubes-dvm qubes-meminfo-writer qubes-qrexec-agent qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network qubes-firewall; do
  424. /bin/systemctl enable $srv.service 2> /dev/null
  425. done
  426. # Install overriden services only when original exists
  427. for srv in cups NetworkManager ntpd; do
  428. if [ -f /lib/systemd/system/$srv.service ]; then
  429. cp /usr/lib/qubes/init/$srv.service /etc/systemd/system/$srv.service
  430. fi
  431. done
  432. # Set default "runlevel"
  433. rm -f /etc/systemd/system/default.target
  434. ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
  435. # Services to disable
  436. #echo "--> Turning off unnecessary services..."
  437. # FIXME: perhaps there is more elegant way to do this?
  438. for f in /etc/init.d/*
  439. do
  440. srv=`basename $f`
  441. [ $srv = 'functions' ] && continue
  442. [ $srv = 'killall' ] && continue
  443. [ $srv = 'halt' ] && continue
  444. [ $srv = 'single' ] && continue
  445. [ $srv = 'reboot' ] && continue
  446. [ $srv = 'qubes_gui' ] && continue
  447. chkconfig $srv off 2> /dev/null
  448. done
  449. DISABLE_SERVICES="alsa-store alsa-restore auditd backuppc cpuspeed crond dbus-org.freedesktop.Avahi"
  450. DISABLE_SERVICES="$DISABLE_SERVICES fedora-autorelabel fedora-autorelabel-mark ipmi hwclock-load hwclock-save"
  451. DISABLE_SERVICES="$DISABLE_SERVICES mdmonitor multipathd openct rpcbind mcelog fedora-storage-init fedora-storage-init-late"
  452. DISABLE_SERVICES="$DISABLE_SERVICES plymouth-start plymouth-read-write plymouth-quit plymouth-quit-wait"
  453. for srv in $DISABLE_SERVICES; do
  454. if [ -f /lib/systemd/system/$srv.service ]; then
  455. if fgrep -q '[Install]' /lib/systemd/system/$srv.service; then
  456. /bin/systemctl disable $srv.service 2> /dev/null
  457. else
  458. # forcibly disable
  459. ln -sf /dev/null /etc/systemd/system/$srv.service
  460. fi
  461. fi
  462. done
  463. rm -f /etc/systemd/system/getty.target.wants/getty@tty*.service
  464. # Enable some services
  465. /bin/systemctl enable iptables.service 2> /dev/null
  466. /bin/systemctl enable rsyslog.service 2> /dev/null
  467. /bin/systemctl enable ntpd.service 2> /dev/null
  468. /bin/systemctl enable NetworkManager.service
  469. # Enable cups only when it is real SystemD service
  470. [ -e /lib/systemd/system/cups.service ] && /bin/systemctl enable cups.service 2> /dev/null
  471. exit 0
  472. %postun systemd
  473. #Do not run this part on upgrades
  474. if [ "$1" != 0 ] ; then
  475. exit 0
  476. fi
  477. for srv in qubes-dvm qubes-meminfo-writer qubes-qrexec-agent qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network; do
  478. /bin/systemctl disable $srv.service
  479. do