PKGBUILD.install 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. # Archlinux now use sysctl.d/ instead of sysctl.conf
  45. # sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
  46. # Install firmware link only on system which haven't it yet
  47. if ! [ -e /lib/firmware/updates ]; then
  48. if ! [ -h /lib/firmware/updates ]; then
  49. ln -s /lib/modules/firmware /lib/firmware/updates
  50. fi
  51. fi
  52. # qubes-core-vm has been broken for some time - it overrides /etc/hosts; restore original content
  53. if ! grep -q localhost /etc/hosts; then
  54. cat <<EOF > /etc/hosts
  55. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 `hostname`
  56. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  57. EOF
  58. fi
  59. # Remove most of the udev scripts to speed up the VM boot time
  60. # Just leave the xen* scripts, that are needed if this VM was
  61. # ever used as a net backend (e.g. as a VPN domain in the future)
  62. #echo "--> Removing unnecessary udev scripts..."
  63. mkdir -p /var/lib/qubes/removed-udev-scripts
  64. for f in /etc/udev/rules.d/*
  65. do
  66. if [ $(basename $f) == "xen-backend.rules" ] ; then
  67. continue
  68. fi
  69. if [ $(basename $f) == "50-qubes-misc.rules" ] ; then
  70. continue
  71. fi
  72. if echo $f | grep -q qubes; then
  73. continue
  74. fi
  75. mv $f /var/lib/qubes/removed-udev-scripts/
  76. done
  77. }
  78. update_systemd() {
  79. 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
  80. systemctl enable $srv.service 2> /dev/null
  81. done
  82. systemctl enable qubes-update-check.timer 2> /dev/null
  83. # Install overriden services only when original exists
  84. for srv in cups NetworkManager NetworkManager-wait-online ntpd; do
  85. if [ -f /lib/systemd/system/$srv.service ]; then
  86. cp /usr/lib/qubes/init/$srv.service /etc/systemd/system/$srv.service
  87. fi
  88. done
  89. # Set default "runlevel"
  90. rm -f /etc/systemd/system/default.target
  91. ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
  92. DISABLE_SERVICES="alsa-store alsa-restore auditd avahi avahi-daemon backuppc cpuspeed crond"
  93. DISABLE_SERVICES="$DISABLE_SERVICES fedora-autorelabel fedora-autorelabel-mark ipmi hwclock-load hwclock-save"
  94. DISABLE_SERVICES="$DISABLE_SERVICES mdmonitor multipathd openct rpcbind mcelog fedora-storage-init fedora-storage-init-late"
  95. DISABLE_SERVICES="$DISABLE_SERVICES plymouth-start plymouth-read-write plymouth-quit plymouth-quit-wait"
  96. DISABLE_SERVICES="$DISABLE_SERVICES sshd tcsd sm-client sendmail mdmonitor-takeover"
  97. for srv in $DISABLE_SERVICES; do
  98. if [ -f /lib/systemd/system/$srv.service ]; then
  99. if fgrep -q '[Install]' /lib/systemd/system/$srv.service; then
  100. systemctl disable $srv.service 2> /dev/null
  101. else
  102. # forcibly disable
  103. ln -sf /dev/null /etc/systemd/system/$srv.service
  104. fi
  105. fi
  106. done
  107. rm -f /etc/systemd/system/getty.target.wants/getty@tty*.service
  108. # Enable some services
  109. systemctl enable iptables.service 2> /dev/null
  110. systemctl enable ip6tables.service 2> /dev/null
  111. systemctl enable rsyslog.service 2> /dev/null
  112. systemctl enable ntpd.service 2> /dev/null
  113. # Disable original service to enable overriden one
  114. systemctl disable NetworkManager.service 2> /dev/null
  115. # Disable D-BUS activation of NetworkManager - in AppVm it causes problems (eg PackageKit timeouts)
  116. systemctl mask dbus-org.freedesktop.NetworkManager.service 2> /dev/null
  117. systemctl enable NetworkManager.service 2> /dev/null
  118. # Enable cups only when it is real SystemD service
  119. [ -e /lib/systemd/system/cups.service ] && systemctl enable cups.service 2> /dev/null
  120. }
  121. ## arg 1: the new package version
  122. pre_install() {
  123. echo "Pre install..."
  124. # do this whole %pre thing only when updating for the first time...
  125. mkdir -p /var/lib/qubes
  126. # Add qubes core related fstab entries
  127. echo "xen /proc/xen xenfs defaults 0 0" >> /etc/fstab
  128. echo "/dev/xvdi /mnt/removable auto noauto,user,rw 0 0" >> /etc/fstab
  129. #if [ -e /etc/fstab ] ; then
  130. # mv /etc/fstab /var/lib/qubes/fstab.orig
  131. #fi
  132. # Archlinux bash version has a 'bug' when running su -c, /etc/profile is not loaded because bash consider there is no interactive pty when running 'su - user -c' or something like this.
  133. # See https://bugs.archlinux.org/task/31831
  134. useradd --shell /bin/zsh --create-home user
  135. }
  136. ## arg 1: the new package version
  137. post_install() {
  138. update_xdgstart
  139. update_qubesconfig
  140. update_systemd
  141. # do the rest of %post thing only when updating for the first time...
  142. if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
  143. cp /etc/init/serial.conf /var/lib/qubes/serial.orig
  144. fi
  145. # SELinux is not enabled on archlinux
  146. # echo "--> Disabling SELinux..."
  147. # sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  148. # mv /etc/selinux/config.processed /etc/selinux/config
  149. # setenforce 0 2>/dev/null
  150. mkdir -p /rw
  151. }
  152. ## arg 1: the new package version
  153. ## arg 2: the old package version
  154. post_upgrade() {
  155. update_xdgstart
  156. update_qubesconfig
  157. update_systemd
  158. }
  159. ## arg 1: the new package version
  160. ## arg 2: the old package version
  161. pre_upgrade() {
  162. # do something here
  163. echo "Pre upgrade..."
  164. }
  165. ## arg 1: the old package version
  166. pre_remove() {
  167. systemctl disable qubes-qrexec-agent.service
  168. }
  169. ## arg 1: the old package version
  170. #post_remove() {
  171. # do something here
  172. #}