PKGBUILD.install 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. remove_ShowIn () {
  2. if [ -e /etc/xdg/autostart/$1.desktop ]; then
  3. sed -i '/^\(Not\|Only\)ShowIn/d' /etc/xdg/autostart/$1.desktop
  4. fi
  5. }
  6. update_xdgstart () {
  7. # don't want it at all
  8. 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
  9. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  10. remove_ShowIn $F
  11. echo 'NotShowIn=QUBES;' >> /etc/xdg/autostart/$F.desktop
  12. fi
  13. done
  14. # don't want it in DisposableVM
  15. for F in gcm-apply ; do
  16. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  17. remove_ShowIn $F
  18. echo 'NotShowIn=DisposableVM;' >> /etc/xdg/autostart/$F.desktop
  19. fi
  20. done
  21. # want it in AppVM only
  22. 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
  23. if [ -e /etc/xdg/autostart/$F.desktop ]; then
  24. remove_ShowIn $F
  25. echo 'OnlyShowIn=GNOME;AppVM;' >> /etc/xdg/autostart/$F.desktop
  26. fi
  27. done
  28. # remove existing rule to add own later
  29. for F in gpk-update-icon nm-applet ; do
  30. remove_ShowIn $F
  31. done
  32. echo 'OnlyShowIn=GNOME;UpdateableVM;' >> /etc/xdg/autostart/gpk-update-icon.desktop || :
  33. echo 'OnlyShowIn=GNOME;NetVM;' >> /etc/xdg/autostart/nm-applet.desktop || :
  34. }
  35. update_qubesconfig () {
  36. # Create NetworkManager configuration if we do not have it
  37. if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
  38. echo '[main]' > /etc/NetworkManager/NetworkManager.conf
  39. echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
  40. echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
  41. fi
  42. /usr/lib/qubes/qubes-fix-nm-conf.sh
  43. # Remove ip_forward setting from sysctl, so NM will not reset it
  44. sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
  45. # Install firmware link only on system which haven't it yet
  46. if ! [ -e /lib/firmware/updates ]; then
  47. ln -s /lib/modules/firmware /lib/firmware/updates
  48. fi
  49. # qubes-core-vm has been broken for some time - it overrides /etc/hosts; restore original content
  50. if ! grep -q localhost /etc/hosts; then
  51. cat <<EOF > /etc/hosts
  52. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 `hostname`
  53. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  54. EOF
  55. fi
  56. # Remove most of the udev scripts to speed up the VM boot time
  57. # Just leave the xen* scripts, that are needed if this VM was
  58. # ever used as a net backend (e.g. as a VPN domain in the future)
  59. #echo "--> Removing unnecessary udev scripts..."
  60. mkdir -p /var/lib/qubes/removed-udev-scripts
  61. for f in /etc/udev/rules.d/*
  62. do
  63. if [ $(basename $f) == "xen-backend.rules" ] ; then
  64. continue
  65. fi
  66. if [ $(basename $f) == "50-qubes-misc.rules" ] ; then
  67. continue
  68. fi
  69. if echo $f | grep -q qubes; then
  70. continue
  71. fi
  72. mv $f /var/lib/qubes/removed-udev-scripts/
  73. done
  74. }
  75. update_systemd() {
  76. for srv in qubes-dvm qubes-meminfo-writer qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network qubes-firewall qubes-yum-proxy qubes-qrexec-agent; do
  77. systemctl enable $srv.service 2> /dev/null
  78. done
  79. systemctl enable qubes-update-check.timer 2> /dev/null
  80. # Install overriden services only when original exists
  81. for srv in cups NetworkManager NetworkManager-wait-online ntpd; do
  82. if [ -f /lib/systemd/system/$srv.service ]; then
  83. cp /usr/lib/qubes/init/$srv.service /etc/systemd/system/$srv.service
  84. fi
  85. done
  86. # Set default "runlevel"
  87. rm -f /etc/systemd/system/default.target
  88. ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
  89. DISABLE_SERVICES="alsa-store alsa-restore auditd avahi avahi-daemon backuppc cpuspeed crond"
  90. DISABLE_SERVICES="$DISABLE_SERVICES fedora-autorelabel fedora-autorelabel-mark ipmi hwclock-load hwclock-save"
  91. DISABLE_SERVICES="$DISABLE_SERVICES mdmonitor multipathd openct rpcbind mcelog fedora-storage-init fedora-storage-init-late"
  92. DISABLE_SERVICES="$DISABLE_SERVICES plymouth-start plymouth-read-write plymouth-quit plymouth-quit-wait"
  93. DISABLE_SERVICES="$DISABLE_SERVICES sshd tcsd sm-client sendmail mdmonitor-takeover"
  94. for srv in $DISABLE_SERVICES; do
  95. if [ -f /lib/systemd/system/$srv.service ]; then
  96. if fgrep -q '[Install]' /lib/systemd/system/$srv.service; then
  97. systemctl disable $srv.service 2> /dev/null
  98. else
  99. # forcibly disable
  100. ln -sf /dev/null /etc/systemd/system/$srv.service
  101. fi
  102. fi
  103. done
  104. rm -f /etc/systemd/system/getty.target.wants/getty@tty*.service
  105. # Enable some services
  106. systemctl enable iptables.service 2> /dev/null
  107. systemctl enable ip6tables.service 2> /dev/null
  108. systemctl enable rsyslog.service 2> /dev/null
  109. systemctl enable ntpd.service 2> /dev/null
  110. # Disable original service to enable overriden one
  111. systemctl disable NetworkManager.service 2> /dev/null
  112. # Disable D-BUS activation of NetworkManager - in AppVm it causes problems (eg PackageKit timeouts)
  113. systemctl mask dbus-org.freedesktop.NetworkManager.service 2> /dev/null
  114. systemctl enable NetworkManager.service 2> /dev/null
  115. # Enable cups only when it is real SystemD service
  116. [ -e /lib/systemd/system/cups.service ] && systemctl enable cups.service 2> /dev/null
  117. }
  118. ## arg 1: the new package version
  119. pre_install() {
  120. echo "Pre install..."
  121. }
  122. ## arg 1: the new package version
  123. post_install() {
  124. update_xdgstart
  125. update_qubesconfig
  126. update_systemd
  127. # do the rest of %post thing only when updating for the first time...
  128. if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
  129. cp /etc/init/serial.conf /var/lib/qubes/serial.orig
  130. fi
  131. # SELinux is not enabled on archlinux
  132. # echo "--> Disabling SELinux..."
  133. # sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  134. # mv /etc/selinux/config.processed /etc/selinux/config
  135. # setenforce 0 2>/dev/null
  136. mkdir -p /rw
  137. }
  138. ## arg 1: the new package version
  139. ## arg 2: the old package version
  140. post_upgrade() {
  141. update_xdgstart
  142. update_qubesconfig
  143. update_systemd
  144. }
  145. ## arg 1: the new package version
  146. ## arg 2: the old package version
  147. pre_upgrade() {
  148. # do something here
  149. echo "Pre upgrade..."
  150. }
  151. ## arg 1: the old package version
  152. pre_remove() {
  153. systemctl disable qubes-qrexec-agent.service
  154. }
  155. ## arg 1: the old package version
  156. #post_remove() {
  157. # do something here
  158. #}