PKGBUILD.install 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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-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. UNITDIR=/lib/systemd/system
  84. OVERRIDEDIR=/usr/lib/qubes/init
  85. # Install overriden services only when original exists
  86. for srv in cups NetworkManager NetworkManager-wait-online ntpd chronyd; do
  87. if [ -f $UNITDIR/$srv.service ]; then
  88. cp $OVERRIDEDIR/$srv.service /etc/systemd/system/
  89. fi
  90. if [ -f $UNITDIR/$srv.socket -a -f $OVERRIDEDIR/$srv.socket ]; then
  91. cp $OVERRIDEDIR/$srv.socket /etc/systemd/system/
  92. fi
  93. if [ -f $UNITDIR/$srv.path -a -f $OVERRIDEDIR/$srv.path ]; then
  94. cp $OVERRIDEDIR/$srv.service /etc/systemd/system/
  95. fi
  96. done
  97. # Set default "runlevel"
  98. rm -f /etc/systemd/system/default.target
  99. ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
  100. DISABLE_SERVICES="alsa-store alsa-restore auditd avahi avahi-daemon backuppc cpuspeed crond"
  101. DISABLE_SERVICES="$DISABLE_SERVICES fedora-autorelabel fedora-autorelabel-mark ipmi hwclock-load hwclock-save"
  102. DISABLE_SERVICES="$DISABLE_SERVICES mdmonitor multipathd openct rpcbind mcelog fedora-storage-init fedora-storage-init-late"
  103. DISABLE_SERVICES="$DISABLE_SERVICES plymouth-start plymouth-read-write plymouth-quit plymouth-quit-wait"
  104. DISABLE_SERVICES="$DISABLE_SERVICES sshd tcsd sm-client sendmail mdmonitor-takeover"
  105. DISABLE_SERVICES="$DISABLE_SERVICES rngd smartd upower irqbalance colord"
  106. for srv in $DISABLE_SERVICES; do
  107. if [ -f /lib/systemd/system/$srv.service ]; then
  108. if fgrep -q '[Install]' /lib/systemd/system/$srv.service; then
  109. systemctl disable $srv.service 2> /dev/null
  110. else
  111. # forcibly disable
  112. ln -sf /dev/null /etc/systemd/system/$srv.service
  113. fi
  114. fi
  115. done
  116. rm -f /etc/systemd/system/getty.target.wants/getty@tty*.service
  117. # Enable some services
  118. systemctl enable iptables.service 2> /dev/null
  119. systemctl enable ip6tables.service 2> /dev/null
  120. systemctl enable rsyslog.service 2> /dev/null
  121. systemctl enable ntpd.service 2> /dev/null
  122. # Disable original service to enable overriden one
  123. systemctl disable NetworkManager.service 2> /dev/null
  124. # Disable D-BUS activation of NetworkManager - in AppVm it causes problems (eg PackageKit timeouts)
  125. systemctl mask dbus-org.freedesktop.NetworkManager.service 2> /dev/null
  126. systemctl enable NetworkManager.service 2> /dev/null
  127. # Fix for https://bugzilla.redhat.com/show_bug.cgi?id=974811
  128. systemctl enable NetworkManager-dispatcher.service 2> /dev/null
  129. # Enable cups only when it is real SystemD service
  130. [ -e /lib/systemd/system/cups.service ] && systemctl enable cups.service 2> /dev/null
  131. }
  132. ## arg 1: the new package version
  133. pre_install() {
  134. echo "Pre install..."
  135. # do this whole %pre thing only when updating for the first time...
  136. mkdir -p /var/lib/qubes
  137. # Add qubes core related fstab entries
  138. echo "xen /proc/xen xenfs defaults 0 0" >> /etc/fstab
  139. echo "/dev/xvdi /mnt/removable auto noauto,user,rw 0 0" >> /etc/fstab
  140. #if [ -e /etc/fstab ] ; then
  141. # mv /etc/fstab /var/lib/qubes/fstab.orig
  142. #fi
  143. # 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.
  144. # See https://bugs.archlinux.org/task/31831
  145. useradd --shell /bin/zsh --create-home user
  146. }
  147. ## arg 1: the new package version
  148. post_install() {
  149. update_xdgstart
  150. update_qubesconfig
  151. update_systemd
  152. # do the rest of %post thing only when updating for the first time...
  153. if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
  154. cp /etc/init/serial.conf /var/lib/qubes/serial.orig
  155. fi
  156. # SELinux is not enabled on archlinux
  157. # echo "--> Disabling SELinux..."
  158. # sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  159. # mv /etc/selinux/config.processed /etc/selinux/config
  160. # setenforce 0 2>/dev/null
  161. mkdir -p /rw
  162. }
  163. ## arg 1: the new package version
  164. ## arg 2: the old package version
  165. post_upgrade() {
  166. update_xdgstart
  167. update_qubesconfig
  168. update_systemd
  169. }
  170. ## arg 1: the new package version
  171. ## arg 2: the old package version
  172. pre_upgrade() {
  173. # do something here
  174. echo "Pre upgrade..."
  175. }
  176. ## arg 1: the old package version
  177. #pre_remove() {
  178. #
  179. #}
  180. ## arg 1: the old package version
  181. post_remove() {
  182. for srv in qubes-dvm qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network qubes-qrexec-agent; do
  183. systemctl disable $srv.service
  184. done
  185. }