PKGBUILD.install 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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. echo "Updating systemd configuration for Qubes..."
  80. echo "Enabling tty1"
  81. # Archlinux specific: ensure tty1 is enabled
  82. rm -f /etc/systemd/system/getty.target.wants/getty\@tty*.service
  83. systemctl enable getty\@tty1.service
  84. # Archlinux specific: Update pam.d configuration for su to enable systemd-login wrapper
  85. if [ -z "`cat /etc/pam.d/su | grep system-login`" ] ; then
  86. echo "Fixing pam.d"
  87. sed '/auth\t\trequired\tpam_unix.so/aauth\t\tinclude\t\tsystem-login' -i /etc/pam.d/su
  88. sed '/account\t\trequired\tpam_unix.so/aaccount\t\tinclude\t\tsystem-login' -i /etc/pam.d/su
  89. sed '/session\t\trequired\tpam_unix.so/asession\t\tinclude\t\tsystem-login' -i /etc/pam.d/su
  90. cp /etc/pam.d/su /etc/pam.d/su-l
  91. fi
  92. echo "Enabling qubes specific services"
  93. for srv in qubes-dvm qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network qubes-firewall qubes-yum-proxy qubes-qrexec-agent qubes-ensure-lib-modules; do
  94. systemctl enable $srv.service 2> /dev/null
  95. done
  96. systemctl enable qubes-update-check.timer 2> /dev/null
  97. UNITDIR=/lib/systemd/system
  98. OVERRIDEDIR=/usr/lib/qubes/init
  99. # Install overriden services only when original exists
  100. for srv in cups NetworkManager NetworkManager-wait-online ntpd chronyd; do
  101. if [ -f $UNITDIR/$srv.service ]; then
  102. cp $OVERRIDEDIR/$srv.service /etc/systemd/system/
  103. fi
  104. if [ -f $UNITDIR/$srv.socket -a -f $OVERRIDEDIR/$srv.socket ]; then
  105. cp $OVERRIDEDIR/$srv.socket /etc/systemd/system/
  106. fi
  107. if [ -f $UNITDIR/$srv.path -a -f $OVERRIDEDIR/$srv.path ]; then
  108. cp $OVERRIDEDIR/$srv.service /etc/systemd/system/
  109. fi
  110. done
  111. # Set default "runlevel"
  112. rm -f /etc/systemd/system/default.target
  113. ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
  114. DISABLE_SERVICES="alsa-store alsa-restore auditd avahi avahi-daemon backuppc cpuspeed crond"
  115. DISABLE_SERVICES="$DISABLE_SERVICES fedora-autorelabel fedora-autorelabel-mark ipmi hwclock-load hwclock-save"
  116. DISABLE_SERVICES="$DISABLE_SERVICES mdmonitor multipathd openct rpcbind mcelog fedora-storage-init fedora-storage-init-late"
  117. DISABLE_SERVICES="$DISABLE_SERVICES plymouth-start plymouth-read-write plymouth-quit plymouth-quit-wait"
  118. DISABLE_SERVICES="$DISABLE_SERVICES sshd tcsd sm-client sendmail mdmonitor-takeover"
  119. DISABLE_SERVICES="$DISABLE_SERVICES rngd smartd upower irqbalance colord"
  120. for srv in $DISABLE_SERVICES; do
  121. if [ -f /lib/systemd/system/$srv.service ]; then
  122. if fgrep -q '[Install]' /lib/systemd/system/$srv.service; then
  123. systemctl disable $srv.service 2> /dev/null
  124. else
  125. # forcibly disable
  126. ln -sf /dev/null /etc/systemd/system/$srv.service
  127. fi
  128. fi
  129. done
  130. # Enable some services
  131. systemctl enable iptables.service 2> /dev/null
  132. systemctl enable ip6tables.service 2> /dev/null
  133. systemctl enable rsyslog.service 2> /dev/null
  134. systemctl enable ntpd.service 2> /dev/null
  135. # Disable original service to enable overriden one
  136. systemctl disable NetworkManager.service 2> /dev/null
  137. # Disable D-BUS activation of NetworkManager - in AppVm it causes problems (eg PackageKit timeouts)
  138. systemctl mask dbus-org.freedesktop.NetworkManager.service 2> /dev/null
  139. systemctl enable NetworkManager.service 2> /dev/null
  140. # Fix for https://bugzilla.redhat.com/show_bug.cgi?id=974811
  141. systemctl enable NetworkManager-dispatcher.service 2> /dev/null
  142. # Enable cups only when it is real SystemD service
  143. [ -e /lib/systemd/system/cups.service ] && systemctl enable cups.service 2> /dev/null
  144. }
  145. ## arg 1: the new package version
  146. pre_install() {
  147. echo "Pre install..."
  148. # do this whole %pre thing only when updating for the first time...
  149. mkdir -p /var/lib/qubes
  150. # Backup fstab / But use archlinux defaults (cp instead of mv)
  151. if [ -e /etc/fstab ] ; then
  152. cp /etc/fstab /var/lib/qubes/fstab.orig
  153. fi
  154. # Add qubes core related fstab entries
  155. echo "xen /proc/xen xenfs defaults 0 0" >> /etc/fstab
  156. # 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.
  157. # See https://bugs.archlinux.org/task/31831
  158. useradd --shell /bin/zsh --create-home user
  159. }
  160. ## arg 1: the new package version
  161. post_install() {
  162. update_xdgstart
  163. update_qubesconfig
  164. update_systemd
  165. # do the rest of %post thing only when updating for the first time...
  166. # Note: serial console wont work this way on archlinux. Maybe better using systemd ?
  167. #if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
  168. # cp /etc/init/serial.conf /var/lib/qubes/serial.orig
  169. #fi
  170. # SELinux is not enabled on archlinux
  171. # echo "--> Disabling SELinux..."
  172. # sed -e s/^SELINUX=.*$/SELINUX=disabled/ </etc/selinux/config >/etc/selinux/config.processed
  173. # mv /etc/selinux/config.processed /etc/selinux/config
  174. # setenforce 0 2>/dev/null
  175. mkdir -p /rw
  176. }
  177. ## arg 1: the new package version
  178. ## arg 2: the old package version
  179. post_upgrade() {
  180. update_xdgstart
  181. update_systemd
  182. }
  183. ## arg 1: the new package version
  184. ## arg 2: the old package version
  185. pre_upgrade() {
  186. # do something here
  187. echo "Pre upgrade..."
  188. }
  189. ## arg 1: the old package version
  190. pre_remove() {
  191. # no more packages left
  192. if [ -e /var/lib/qubes/fstab.orig ] ; then
  193. mv /var/lib/qubes/fstab.orig /etc/fstab
  194. fi
  195. mv /var/lib/qubes/removed-udev-scripts/* /etc/udev/rules.d/
  196. if [ -e /var/lib/qubes/serial.orig ] ; then
  197. mv /var/lib/qubes/serial.orig /etc/init/serial.conf
  198. fi
  199. }
  200. ## arg 1: the old package version
  201. post_remove() {
  202. /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas &> /dev/null || :
  203. if [ -L /lib/firmware/updates ] ; then
  204. rm /lib/firmware/updates
  205. fi
  206. for srv in qubes-dvm qubes-sysinit qubes-misc-post qubes-netwatcher qubes-network qubes-firewall qubes-qrexec-agent qubes-yum-proxy qubes-ensure-lib-modules; do
  207. systemctl disable $srv.service
  208. done
  209. systemctl disable qubes-update-check.timer
  210. }