Fix indentation and shellcheck issues for archlinux
(cherry picked from commit 60ee036f04d5f22d1a3a694586f219f5b6ce30a1)
This commit is contained in:
parent
ace824d505
commit
74ce135461
@ -1,11 +1,8 @@
|
|||||||
# This is an example PKGBUILD file. Use this as a start to creating your own,
|
#!/bin/bash
|
||||||
# and remove these comments. For more information, see 'man PKGBUILD'.
|
|
||||||
# NOTE: Please fill out the license field for your package! If it is unknown,
|
|
||||||
# then please put 'unknown'.
|
|
||||||
|
|
||||||
# Maintainer: Olivier Medoc <o_medoc@yahoo.fr>
|
# Maintainer: Olivier Medoc <o_medoc@yahoo.fr>
|
||||||
|
# shellcheck disable=SC2034
|
||||||
pkgname=qubes-vm-core
|
pkgname=qubes-vm-core
|
||||||
pkgver=`cat version`
|
pkgver=$(cat version)
|
||||||
pkgrel=11
|
pkgrel=11
|
||||||
epoch=
|
epoch=
|
||||||
pkgdesc="The Qubes core files for installation inside a Qubes VM."
|
pkgdesc="The Qubes core files for installation inside a Qubes VM."
|
||||||
@ -25,85 +22,83 @@ options=()
|
|||||||
install=PKGBUILD.install
|
install=PKGBUILD.install
|
||||||
changelog=
|
changelog=
|
||||||
|
|
||||||
source=( PKGBUILD.qubes-ensure-lib-modules.service PKGBUILD.qubes-update-desktop-icons.hook
|
source=(
|
||||||
PKGBUILD-qubes-noupgrade.conf
|
PKGBUILD.qubes-ensure-lib-modules.service PKGBUILD.qubes-update-desktop-icons.hook
|
||||||
PKGBUILD-qubes-repo-3.1.conf
|
PKGBUILD-qubes-noupgrade.conf
|
||||||
PKGBUILD-qubes-repo-3.2.conf
|
PKGBUILD-qubes-repo-3.1.conf
|
||||||
)
|
PKGBUILD-qubes-repo-3.2.conf
|
||||||
|
)
|
||||||
|
|
||||||
noextract=()
|
noextract=()
|
||||||
md5sums=(SKIP)
|
md5sums=(SKIP)
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
|
for source in autostart-dropins qubes-rpc qrexec misc Makefile vm-init.d vm-systemd network init version; do
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
(ln -s "$srcdir/../$source" "$srcdir/$source")
|
||||||
|
done
|
||||||
|
|
||||||
for source in autostart-dropins qubes-rpc qrexec misc Makefile vm-init.d vm-systemd network init version; do
|
# Fix for network tools paths
|
||||||
(ln -s $srcdir/../$source $srcdir/$source)
|
sed 's:/sbin/ifconfig:ifconfig:g' -i network/*
|
||||||
done
|
sed 's:/sbin/route:route:g' -i network/*
|
||||||
|
sed 's:/sbin/ethtool:ethtool:g' -i network/*
|
||||||
|
sed 's:/sbin/ip:ip:g' -i network/*
|
||||||
|
sed 's:/bin/grep:grep:g' -i network/*
|
||||||
|
|
||||||
# Fix for network tools paths
|
# Force running all scripts with python2
|
||||||
sed 's:/sbin/ifconfig:ifconfig:g' -i network/*
|
sed 's:#!/usr/bin/python:#!/usr/bin/python2:' -i misc/*
|
||||||
sed 's:/sbin/route:route:g' -i network/*
|
sed 's:#!/usr/bin/env python:#!/usr/bin/env python2:' -i misc/*
|
||||||
sed 's:/sbin/ethtool:ethtool:g' -i network/*
|
sed 's:#!/usr/bin/python:#!/usr/bin/python2:' -i qubes-rpc/*
|
||||||
sed 's:/sbin/ip:ip:g' -i network/*
|
sed 's:#!/usr/bin/env python:#!/usr/bin/env python2:' -i qubes-rpc/*
|
||||||
sed 's:/bin/grep:grep:g' -i network/*
|
|
||||||
|
|
||||||
# Force running all scripts with python2
|
# Fix for archlinux sbindir
|
||||||
sed 's:#!/usr/bin/python:#!/usr/bin/python2:' -i misc/*
|
sed 's:/usr/sbin/ntpdate:/usr/bin/ntpdate:g' -i qubes-rpc/sync-ntp-clock
|
||||||
sed 's:#!/usr/bin/env python:#!/usr/bin/env python2:' -i misc/*
|
sed 's:/usr/sbin/qubes-firewall:/usr/bin/qubes-firewall:g' -i vm-systemd/qubes-firewall.service
|
||||||
sed 's:#!/usr/bin/python:#!/usr/bin/python2:' -i qubes-rpc/*
|
|
||||||
sed 's:#!/usr/bin/env python:#!/usr/bin/env python2:' -i qubes-rpc/*
|
|
||||||
|
|
||||||
|
|
||||||
# Fix for archlinux sbindir
|
|
||||||
sed 's:/usr/sbin/ntpdate:/usr/bin/ntpdate:g' -i qubes-rpc/sync-ntp-clock
|
|
||||||
sed 's:/usr/sbin/qubes-firewall:/usr/bin/qubes-firewall:g' -i vm-systemd/qubes-firewall.service
|
|
||||||
|
|
||||||
for dir in qubes-rpc qrexec misc; do
|
|
||||||
(cd $dir; make)
|
|
||||||
done
|
|
||||||
|
|
||||||
|
for dir in qubes-rpc qrexec misc; do
|
||||||
|
(cd $dir || exit 1; make)
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
# Note: Archlinux removed use of directory such as /sbin /bin /usr/sbin (https://mailman.archlinux.org/pipermail/arch-dev-public/2012-March/022625.html)
|
# Note: Archlinux removed use of directory such as /sbin /bin /usr/sbin (https://mailman.archlinux.org/pipermail/arch-dev-public/2012-March/022625.html)
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
(cd qrexec || exit 1; make install DESTDIR="$pkgdir" SBINDIR=/usr/bin LIBDIR=/usr/lib SYSLIBDIR=/usr/lib)
|
||||||
|
|
||||||
(cd qrexec; make install DESTDIR=$pkgdir SBINDIR=/usr/bin LIBDIR=/usr/lib SYSLIBDIR=/usr/lib)
|
make install-vm DESTDIR="$pkgdir" SBINDIR=/usr/bin LIBDIR=/usr/lib SYSLIBDIR=/usr/lib SYSTEM_DROPIN_DIR=/usr/lib/systemd/system USER_DROPIN_DIR=/usr/lib/systemd/user DIST=archlinux
|
||||||
|
|
||||||
make install-vm DESTDIR=$pkgdir SBINDIR=/usr/bin LIBDIR=/usr/lib SYSLIBDIR=/usr/lib SYSTEM_DROPIN_DIR=/usr/lib/systemd/system USER_DROPIN_DIR=/usr/lib/systemd/user DIST=archlinux
|
# Remove things non wanted in archlinux
|
||||||
|
rm -r "$pkgdir/etc/yum"*
|
||||||
|
rm -r "$pkgdir/etc/init.d"
|
||||||
|
# Remove fedora specific scripts
|
||||||
|
rm "$pkgdir/etc/fstab"
|
||||||
|
|
||||||
# Remove things non wanted in archlinux
|
# Install systemd script allowing to automount /lib/modules
|
||||||
rm -r $pkgdir/etc/yum*
|
install -m 644 "$srcdir/PKGBUILD.qubes-ensure-lib-modules.service" "${pkgdir}/usr/lib/systemd/system/qubes-ensure-lib-modules.service"
|
||||||
rm -r $pkgdir/etc/init.d
|
|
||||||
# Remove fedora specific scripts
|
|
||||||
rm $pkgdir/etc/fstab
|
|
||||||
|
|
||||||
# Install systemd script allowing to automount /lib/modules
|
# Install pacman hook to update desktop icons
|
||||||
install -m 644 $srcdir/PKGBUILD.qubes-ensure-lib-modules.service ${pkgdir}/usr/lib/systemd/system/qubes-ensure-lib-modules.service
|
mkdir -p "${pkgdir}/usr/share/libalpm/hooks/"
|
||||||
|
install -m 644 "$srcdir/PKGBUILD.qubes-update-desktop-icons.hook" "${pkgdir}/usr/share/libalpm/hooks/qubes-update-desktop-icons.hook"
|
||||||
|
|
||||||
# Install pacman hook to update desktop icons
|
# Install pacman.d drop-ins (at least 1 drop-in must be installed or pacman will fail)
|
||||||
mkdir -p ${pkgdir}/usr/share/libalpm/hooks/
|
mkdir -p "${pkgdir}/etc/pacman.d"
|
||||||
install -m 644 $srcdir/PKGBUILD.qubes-update-desktop-icons.hook ${pkgdir}/usr/share/libalpm/hooks/qubes-update-desktop-icons.hook
|
install -m 644 "$srcdir/PKGBUILD-qubes-noupgrade.conf" "${pkgdir}/etc/pacman.d/10-qubes-noupgrade.conf"
|
||||||
|
|
||||||
# Install pacman.d drop-ins (at least 1 drop-in must be installed or pacman will fail)
|
# Install pacman repository
|
||||||
mkdir -p ${pkgdir}/etc/pacman.d
|
release=$(echo "$pkgver" | cut -d '.' -f 1,2)
|
||||||
install -m 644 $srcdir/PKGBUILD-qubes-noupgrade.conf ${pkgdir}/etc/pacman.d/10-qubes-noupgrade.conf
|
echo "Installing repository for release ${release}"
|
||||||
|
install -m 644 "$srcdir/PKGBUILD-qubes-repo-${release}.conf" "${pkgdir}/etc/pacman.d/99-qubes-repository-${release}.conf.disabled"
|
||||||
|
|
||||||
# Install pacman repository
|
# Archlinux specific: enable autologin on tty1
|
||||||
release=`echo $pkgver | cut -d '.' -f 1,2`
|
mkdir -p "$pkgdir/etc/systemd/system/getty@tty1.service.d/"
|
||||||
echo "Installing repository for release ${release}"
|
cat <<EOF > "$pkgdir/etc/systemd/system/getty@tty1.service.d/autologin.conf"
|
||||||
install -m 644 $srcdir/PKGBUILD-qubes-repo-${release}.conf ${pkgdir}/etc/pacman.d/99-qubes-repository-${release}.conf.disabled
|
|
||||||
|
|
||||||
# Archlinux specific: enable autologin on tty1
|
|
||||||
mkdir -p $pkgdir/etc/systemd/system/getty@tty1.service.d/
|
|
||||||
cat <<EOF > $pkgdir/etc/systemd/system/getty@tty1.service.d/autologin.conf
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=
|
ExecStart=
|
||||||
ExecStart=-/usr/bin/agetty --autologin user --noclear %I 38400 linux
|
ExecStart=-/usr/bin/agetty --autologin user --noclear %I 38400 linux
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Archlinux packaging guidelines: /var/run is a symlink to a tmpfs. Don't create it
|
# Archlinux packaging guidelines: /var/run is a symlink to a tmpfs. Don't create it
|
||||||
rm -r $pkgdir/var/run
|
rm -r "$pkgdir/var/run"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim:set ts=2 sw=2 et:
|
# vim:set ts=2 sw=2 et:
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
qubes_preset_file="75-qubes-vm.preset"
|
qubes_preset_file="75-qubes-vm.preset"
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
@ -5,50 +6,47 @@ qubes_preset_file="75-qubes-vm.preset"
|
|||||||
###########################
|
###########################
|
||||||
|
|
||||||
update_default_user() {
|
update_default_user() {
|
||||||
|
# Make sure there is a qubes group
|
||||||
|
groupadd --force --system --gid 98 qubes
|
||||||
|
|
||||||
# Make sure there is a qubes group
|
# 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.
|
||||||
groupadd --force --system --gid 98 qubes
|
# See https://bugs.archlinux.org/task/31831
|
||||||
|
id -u 'user' >/dev/null 2>&1 || {
|
||||||
# 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.
|
useradd --user-group --create-home --shell /bin/zsh user
|
||||||
# See https://bugs.archlinux.org/task/31831
|
}
|
||||||
id -u 'user' >/dev/null 2>&1 || {
|
usermod -a --groups qubes user
|
||||||
useradd --user-group --create-home --shell /bin/zsh user
|
|
||||||
}
|
|
||||||
usermod -a --groups qubes user
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## arg 1: the new package version
|
## arg 1: the new package version
|
||||||
pre_install() {
|
pre_install() {
|
||||||
echo "Pre install..."
|
echo "Pre install..."
|
||||||
|
|
||||||
update_default_user
|
update_default_user
|
||||||
|
|
||||||
# do this whole %pre thing only when updating for the first time...
|
# do this whole %pre thing only when updating for the first time...
|
||||||
|
|
||||||
mkdir -p /var/lib/qubes
|
mkdir -p /var/lib/qubes
|
||||||
|
|
||||||
# Backup fstab / But use archlinux defaults (cp instead of mv)
|
# Backup fstab / But use archlinux defaults (cp instead of mv)
|
||||||
if [ -e /etc/fstab ] ; then
|
if [ -e /etc/fstab ] ; then
|
||||||
cp /etc/fstab /var/lib/qubes/fstab.orig
|
cp /etc/fstab /var/lib/qubes/fstab.orig
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add qubes core related fstab entries
|
# Add qubes core related fstab entries
|
||||||
echo "xen /proc/xen xenfs defaults 0 0" >> /etc/fstab
|
echo "xen /proc/xen xenfs defaults 0 0" >> /etc/fstab
|
||||||
|
|
||||||
usermod -p '' root
|
usermod -p '' root
|
||||||
usermod -L user
|
usermod -L user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## arg 1: the new package version
|
## arg 1: the new package version
|
||||||
## arg 2: the old package version
|
## arg 2: the old package version
|
||||||
pre_upgrade() {
|
pre_upgrade() {
|
||||||
# do something here
|
# do something here
|
||||||
echo "Pre upgrade..."
|
echo "Pre upgrade..."
|
||||||
|
|
||||||
update_default_user
|
|
||||||
|
|
||||||
|
update_default_user
|
||||||
}
|
}
|
||||||
|
|
||||||
###################
|
###################
|
||||||
@ -64,13 +62,11 @@ configure_notification-daemon() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configure_selinux() {
|
configure_selinux() {
|
||||||
|
# SELinux is not enabled on archlinux
|
||||||
# SELinux is not enabled on archlinux
|
#echo "--> Disabling SELinux..."
|
||||||
#echo "--> Disabling SELinux..."
|
echo "SELINUX not enabled on archlinux. skipped."
|
||||||
echo "SELINUX not enabled on archlinux. skipped."
|
# sed -e s/^SELINUX=.*$/SELINUX=disabled/ -i /etc/selinux/config
|
||||||
# sed -e s/^SELINUX=.*$/SELINUX=disabled/ -i /etc/selinux/config
|
# setenforce 0 2>/dev/null
|
||||||
# setenforce 0 2>/dev/null
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
############################
|
############################
|
||||||
@ -78,75 +74,76 @@ configure_selinux() {
|
|||||||
############################
|
############################
|
||||||
|
|
||||||
update_qubesconfig() {
|
update_qubesconfig() {
|
||||||
|
# Create NetworkManager configuration if we do not have it
|
||||||
|
if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
|
||||||
|
echo '[main]' > /etc/NetworkManager/NetworkManager.conf
|
||||||
|
echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
|
||||||
|
echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
|
||||||
|
fi
|
||||||
|
/usr/lib/qubes/qubes-fix-nm-conf.sh
|
||||||
|
|
||||||
# Create NetworkManager configuration if we do not have it
|
# Remove ip_forward setting from sysctl, so NM will not reset it
|
||||||
if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
|
# Archlinux now use sysctl.d/ instead of sysctl.conf
|
||||||
echo '[main]' > /etc/NetworkManager/NetworkManager.conf
|
#sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
|
||||||
echo 'plugins = keyfile' >> /etc/NetworkManager/NetworkManager.conf
|
|
||||||
echo '[keyfile]' >> /etc/NetworkManager/NetworkManager.conf
|
|
||||||
fi
|
|
||||||
/usr/lib/qubes/qubes-fix-nm-conf.sh
|
|
||||||
|
|
||||||
# Remove ip_forward setting from sysctl, so NM will not reset it
|
# Remove old firmware updates link
|
||||||
# Archlinux now use sysctl.d/ instead of sysctl.conf
|
if [ -L /lib/firmware/updates ]; then
|
||||||
#sed 's/^net.ipv4.ip_forward.*/#\0/' -i /etc/sysctl.conf
|
rm -f /lib/firmware/updates
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove old firmware updates link
|
# Yum proxy configuration is fedora specific
|
||||||
if [ -L /lib/firmware/updates ]; then
|
#if ! grep -q '/etc/yum\.conf\.d/qubes-proxy\.conf' /etc/yum.conf; then
|
||||||
rm -f /lib/firmware/updates
|
# echo >> /etc/yum.conf
|
||||||
fi
|
# echo '# Yum does not support inclusion of config dir...' >> /etc/yum.conf
|
||||||
|
# echo 'include=file:///etc/yum.conf.d/qubes-proxy.conf' >> /etc/yum.conf
|
||||||
|
#fi
|
||||||
|
#/usr/lib/qubes/update-proxy-configs
|
||||||
|
# Archlinux pacman configuration is handled in update_finalize
|
||||||
|
|
||||||
# Yum proxy configuration is fedora specific
|
# Location of files which contains list of protected files
|
||||||
#if ! grep -q '/etc/yum\.conf\.d/qubes-proxy\.conf' /etc/yum.conf; then
|
mkdir -p /etc/qubes/protected-files.d
|
||||||
# echo >> /etc/yum.conf
|
# shellcheck source=../init/functions
|
||||||
# echo '# Yum does not support inclusion of config dir...' >> /etc/yum.conf
|
. /usr/lib/qubes/init/functions
|
||||||
# echo 'include=file:///etc/yum.conf.d/qubes-proxy.conf' >> /etc/yum.conf
|
|
||||||
#fi
|
|
||||||
#/usr/lib/qubes/update-proxy-configs
|
|
||||||
# Archlinux pacman configuration is handled in update_finalize
|
|
||||||
|
|
||||||
# Location of files which contains list of protected files
|
# qubes-core-vm has been broken for some time - it overrides /etc/hosts; restore original content
|
||||||
mkdir -p /etc/qubes/protected-files.d
|
if ! is_protected_file /etc/hosts ; then
|
||||||
. /usr/lib/qubes/init/functions
|
if ! grep -q localhost /etc/hosts; then
|
||||||
|
|
||||||
# qubes-core-vm has been broken for some time - it overrides /etc/hosts; restore original content
|
cat <<EOF > /etc/hosts
|
||||||
if ! is_protected_file /etc/hosts ; then
|
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 $(hostname)
|
||||||
if ! grep -q localhost /etc/hosts; then
|
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
|
||||||
cat <<EOF > /etc/hosts
|
|
||||||
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 `hostname`
|
|
||||||
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ensure that hostname resolves to 127.0.0.1 resp. ::1 and that /etc/hosts is
|
fi
|
||||||
# in the form expected by qubes-sysinit.sh
|
fi
|
||||||
if ! is_protected_file /etc/hostname ; then
|
|
||||||
for ip in '127\.0\.0\.1' '::1'; do
|
|
||||||
if grep -q "^${ip}\(\s\|$\)" /etc/hosts; then
|
|
||||||
sed -i "/^${ip}\s/,+0s/\(\s`hostname`\)\+\(\s\|$\)/\2/g" /etc/hosts
|
|
||||||
sed -i "s/^${ip}\(\s\|$\).*$/\0 `hostname`/" /etc/hosts
|
|
||||||
else
|
|
||||||
echo "${ip} `hostname`" >> /etc/hosts
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure there is a default locale set so gnome-terminal will start
|
# ensure that hostname resolves to 127.0.0.1 resp. ::1 and that /etc/hosts is
|
||||||
if [ ! -e /etc/locale.conf ] || ! grep -q LANG /etc/locale.conf; then
|
# in the form expected by qubes-sysinit.sh
|
||||||
touch /etc/locale.conf
|
if ! is_protected_file /etc/hostname ; then
|
||||||
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
|
for ip in '127\.0\.0\.1' '::1'; do
|
||||||
fi
|
if grep -q "^${ip}\(\s\|$\)" /etc/hosts; then
|
||||||
# ... and make sure it is really generated
|
sed -i "/^${ip}\s/,+0s/\(\s$(hostname)\)\+\(\s\|$\)/\2/g" /etc/hosts
|
||||||
# This line is buggy as LANG can be set to LANG="en_US.UTF-8". The Quotes must be stripped
|
sed -i "s/^${ip}\(\s\|$\).*$/\0 $(hostname)/" /etc/hosts
|
||||||
current_locale=`grep LANG /etc/locale.conf|cut -f 2 -d = | tr -d '"'`
|
else
|
||||||
if [ -n "$current_locale" ] && ! locale -a | grep -q "$current_locale"; then
|
echo "${ip} $(hostname)" >> /etc/hosts
|
||||||
base=`echo "$current_locale" | cut -f 1 -d .`
|
fi
|
||||||
charmap=`echo "$current_locale.UTF-8" | cut -f 2 -d .`
|
done
|
||||||
[ -n "$charmap" ] && charmap="-f $charmap"
|
fi
|
||||||
localedef -i $base $charmap $current_locale
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Make sure there is a default locale set so gnome-terminal will start
|
||||||
|
if [ ! -e /etc/locale.conf ] || ! grep -q LANG /etc/locale.conf; then
|
||||||
|
touch /etc/locale.conf
|
||||||
|
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
|
||||||
|
fi
|
||||||
|
# ... and make sure it is really generated
|
||||||
|
# This line is buggy as LANG can be set to LANG="en_US.UTF-8". The Quotes must be stripped
|
||||||
|
current_locale=$(grep LANG /etc/locale.conf|cut -f 2 -d = | tr -d '"')
|
||||||
|
if [ -n "$current_locale" ] && ! locale -a | grep -q "$current_locale"; then
|
||||||
|
base=$(echo "$current_locale" | cut -f 1 -d .)
|
||||||
|
charmap=$(echo "$current_locale.UTF-8" | cut -f 2 -d .)
|
||||||
|
[ -n "$charmap" ] && charmap="-f $charmap"
|
||||||
|
localedef -i "$base" "$charmap" "$current_locale"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
############################
|
############################
|
||||||
@ -159,12 +156,12 @@ is_static() {
|
|||||||
is_masked() {
|
is_masked() {
|
||||||
if [ ! -L /etc/systemd/system/"$1" ]
|
if [ ! -L /etc/systemd/system/"$1" ]
|
||||||
then
|
then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
target=`readlink /etc/systemd/system/"$1" 2>/dev/null` || :
|
target=$(readlink /etc/systemd/system/"$1" 2>/dev/null) || :
|
||||||
if [ "$target" = "/dev/null" ]
|
if [ "$target" = "/dev/null" ]
|
||||||
then
|
then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@ -183,16 +180,16 @@ unmask() {
|
|||||||
|
|
||||||
preset_units() {
|
preset_units() {
|
||||||
local represet=
|
local represet=
|
||||||
cat "$1" | while read action unit_name
|
while read -r action unit_name < "$1"
|
||||||
do
|
do
|
||||||
if [ "$action" = "#" -a "$unit_name" = "Units below this line will be re-preset on package upgrade" ]
|
if [ "$action" = "#" ] && [ "$unit_name" = "Units below this line will be re-preset on package upgrade" ]
|
||||||
then
|
then
|
||||||
represet=1
|
represet=1
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "$action $unit_name" | grep -q '^[[:space:]]*[^#;]' || continue
|
echo "$action $unit_name" | grep -q '^[[:space:]]*[^#;]' || continue
|
||||||
[ -n "$action" -a -n "$unit_name" ] || continue
|
[[ -n "$action" && -n "$unit_name" ]] || continue
|
||||||
if [ "$2" = "initial" -o "$represet" = "1" ]
|
if [ "$2" = "initial" ] || [ "$represet" = "1" ]
|
||||||
then
|
then
|
||||||
if [ "$action" = "disable" ] && is_static "$unit_name"
|
if [ "$action" = "disable" ] && is_static "$unit_name"
|
||||||
then
|
then
|
||||||
@ -208,7 +205,7 @@ preset_units() {
|
|||||||
# We masked this static unit before, now we unmask it.
|
# We masked this static unit before, now we unmask it.
|
||||||
unmask "$unit_name"
|
unmask "$unit_name"
|
||||||
fi
|
fi
|
||||||
systemctl --no-reload preset "$unit_name" >/dev/null 2>&1 || :
|
systemctl --no-reload preset "$unit_name" >/dev/null 2>&1 || :
|
||||||
else
|
else
|
||||||
systemctl --no-reload preset "$unit_name" >/dev/null 2>&1 || :
|
systemctl --no-reload preset "$unit_name" >/dev/null 2>&1 || :
|
||||||
fi
|
fi
|
||||||
@ -217,7 +214,7 @@ preset_units() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
restore_units() {
|
restore_units() {
|
||||||
grep '^[[:space:]]*[^#;]' "$1" | while read action unit_name
|
while read -r action unit_name < grep '^[[:space:]]*[^#;]' "$1"
|
||||||
do
|
do
|
||||||
if is_static "$unit_name" && is_masked "$unit_name"
|
if is_static "$unit_name" && is_masked "$unit_name"
|
||||||
then
|
then
|
||||||
@ -230,119 +227,116 @@ restore_units() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configure_systemd() {
|
configure_systemd() {
|
||||||
|
if [ "$1" -eq 1 ]
|
||||||
|
then
|
||||||
|
preset_units /usr/lib/systemd/system-preset/$qubes_preset_file initial
|
||||||
|
changed=true
|
||||||
|
else
|
||||||
|
preset_units /usr/lib/systemd/system-preset/$qubes_preset_file upgrade
|
||||||
|
changed=true
|
||||||
|
# Upgrade path - now qubes-iptables is used instead
|
||||||
|
for svc in iptables ip6tables
|
||||||
|
do
|
||||||
|
if [ -f "$svc".service ]
|
||||||
|
then
|
||||||
|
systemctl --no-reload preset "$svc".service
|
||||||
|
changed=true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $1 -eq 1 ]
|
if [ "$1" -eq 1 ]
|
||||||
then
|
then
|
||||||
preset_units /usr/lib/systemd/system-preset/$qubes_preset_file initial
|
# First install.
|
||||||
changed=true
|
# Set default "runlevel".
|
||||||
else
|
# FIXME: this ought to be done via kernel command line.
|
||||||
preset_units /usr/lib/systemd/system-preset/$qubes_preset_file upgrade
|
# The fewer deviations of the template from the seed
|
||||||
changed=true
|
# image, the better.
|
||||||
# Upgrade path - now qubes-iptables is used instead
|
rm -f /etc/systemd/system/default.target
|
||||||
for svc in iptables ip6tables
|
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
|
||||||
do
|
changed=true
|
||||||
if [ -f "$svc".service ]
|
fi
|
||||||
then
|
|
||||||
systemctl --no-reload preset "$svc".service
|
|
||||||
changed=true
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $1 -eq 1 ]
|
# remove old symlinks
|
||||||
then
|
if [ -L /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service ]
|
||||||
# First install.
|
then
|
||||||
# Set default "runlevel".
|
rm -f /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service
|
||||||
# FIXME: this ought to be done via kernel command line.
|
changed=true
|
||||||
# The fewer deviations of the template from the seed
|
fi
|
||||||
# image, the better.
|
if [ -L /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service ]
|
||||||
rm -f /etc/systemd/system/default.target
|
then
|
||||||
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
|
rm -f /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service
|
||||||
changed=true
|
changed=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove old symlinks
|
|
||||||
if [ -L /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service ]
|
|
||||||
then
|
|
||||||
rm -f /etc/systemd/system/sysinit.target.wants/qubes-random-seed.service
|
|
||||||
changed=true
|
|
||||||
fi
|
|
||||||
if [ -L /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service ]
|
|
||||||
then
|
|
||||||
rm -f /etc/systemd/system/multi-user.target.wants/qubes-mount-home.service
|
|
||||||
changed=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "x$changed" != "x" ]
|
|
||||||
then
|
|
||||||
systemctl daemon-reload
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [ "x$changed" != "x" ]
|
||||||
|
then
|
||||||
|
systemctl daemon-reload
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
######################
|
######################
|
||||||
## Archlinux Specific Functions ##
|
## Archlinux Specific Functions ##
|
||||||
######################
|
######################
|
||||||
config_prependtomark() {
|
config_prependtomark() {
|
||||||
FILE=$1
|
FILE=$1
|
||||||
APPENDBEFORELINE=$2
|
APPENDBEFORELINE=$2
|
||||||
APPENDLINE=$3
|
APPENDLINE=$3
|
||||||
grep -F -q "$APPENDLINE" "$FILE" || sed "/$APPENDBEFORELINE/i$APPENDLINE" -i "$FILE"
|
grep -F -q "$APPENDLINE" "$FILE" || sed "/$APPENDBEFORELINE/i$APPENDLINE" -i "$FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
config_appendtomark() {
|
config_appendtomark() {
|
||||||
FILE=$1
|
FILE=$1
|
||||||
APPENDAFTERLINE=$2
|
APPENDAFTERLINE=$2
|
||||||
APPENDLINE=$3
|
APPENDLINE=$3
|
||||||
grep -F -q "$APPENDLINE" "$FILE" || sed "/$APPENDAFTERLINE/a$APPENDLINE" -i "$FILE"
|
grep -F -q "$APPENDLINE" "$FILE" || sed "/$APPENDAFTERLINE/a$APPENDLINE" -i "$FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
config_cleanupmark() {
|
config_cleanupmark() {
|
||||||
FILE="$1"
|
FILE="$1"
|
||||||
BEGINMARK="$2"
|
BEGINMARK="$2"
|
||||||
ENDMARK="$3"
|
ENDMARK="$3"
|
||||||
if grep -F -q "$BEGINMARK" "$FILE"; then
|
if grep -F -q "$BEGINMARK" "$FILE"; then
|
||||||
if grep -F -q "$ENDMARK" "$FILE"; then
|
if grep -F -q "$ENDMARK" "$FILE"; then
|
||||||
cp "$FILE" "$FILE.qubes-update-orig"
|
cp "$FILE" "$FILE.qubes-update-orig"
|
||||||
sed -i -e "/^$BEGINMARK$/,/^$ENDMARK$/{
|
sed -i -e "/^$BEGINMARK$/,/^$ENDMARK$/{
|
||||||
/^$ENDMARK$/b
|
/^$ENDMARK$/b
|
||||||
/^$BEGINMARK$/!d
|
/^$BEGINMARK$/!d
|
||||||
}" "$FILE"
|
}" "$FILE"
|
||||||
rm -f "$FILE.qubes-update-orig"
|
rm -f "$FILE.qubes-update-orig"
|
||||||
else
|
else
|
||||||
echo "ERROR: found $BEGINMARK marker but not $ENDMARK in $FILE. Please cleanup this file manually."
|
echo "ERROR: found $BEGINMARK marker but not $ENDMARK in $FILE. Please cleanup this file manually."
|
||||||
fi
|
fi
|
||||||
elif grep -F -q "$ENDMARK" "$FILE"; then
|
elif grep -F -q "$ENDMARK" "$FILE"; then
|
||||||
echo "ERROR: found $ENDMARK marker but not $BEGINMARK in $FILE. Please cleanup this file manually."
|
echo "ERROR: found $ENDMARK marker but not $BEGINMARK in $FILE. Please cleanup this file manually."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
update_finalize() {
|
update_finalize() {
|
||||||
|
# Archlinux specific: If marker exists, cleanup text between begin and end marker
|
||||||
|
QUBES_MARKER="### QUBES CONFIG MARKER ###"
|
||||||
|
if grep -F -q "$QUBES_MARKER" /etc/pacman.conf; then
|
||||||
|
config_prependtomark "/etc/pacman.conf" "# REPOSITORIES" "### QUBES CONFIG END MARKER ###"
|
||||||
|
config_cleanupmark "/etc/pacman.conf" "$QUBES_MARKER" "### QUBES CONFIG END MARKER ###"
|
||||||
|
# Else, add qubes config block marker
|
||||||
|
else
|
||||||
|
config_prependtomark "/etc/pacman.conf" "# REPOSITORIES" "$QUBES_MARKER"
|
||||||
|
config_prependtomark "/etc/pacman.conf" "# REPOSITORIES" "### QUBES CONFIG END MARKER ###"
|
||||||
|
fi
|
||||||
|
|
||||||
# Archlinux specific: If marker exists, cleanup text between begin and end marker
|
# Include /etc/pacman.d drop-in directory
|
||||||
QUBES_MARKER="### QUBES CONFIG MARKER ###"
|
config_appendtomark "/etc/pacman.conf" "$QUBES_MARKER" "Include = /etc/pacman.d/*.conf"
|
||||||
if grep -F -q "$QUBES_MARKER" /etc/pacman.conf; then
|
|
||||||
config_prependtomark "/etc/pacman.conf" "# REPOSITORIES" "### QUBES CONFIG END MARKER ###"
|
|
||||||
config_cleanupmark "/etc/pacman.conf" "$QUBES_MARKER" "### QUBES CONFIG END MARKER ###"
|
|
||||||
# Else, add qubes config block marker
|
|
||||||
else
|
|
||||||
config_prependtomark "/etc/pacman.conf" "# REPOSITORIES" "$QUBES_MARKER"
|
|
||||||
config_prependtomark "/etc/pacman.conf" "# REPOSITORIES" "### QUBES CONFIG END MARKER ###"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Include /etc/pacman.d drop-in directory
|
/usr/lib/qubes/update-proxy-configs
|
||||||
config_appendtomark "/etc/pacman.conf" "$QUBES_MARKER" "Include = /etc/pacman.d/*.conf"
|
|
||||||
|
|
||||||
/usr/lib/qubes/update-proxy-configs
|
# Archlinux specific: Update pam.d configuration for su to enable systemd-login wrapper
|
||||||
|
# Also remove pam_unix.so from su configuration
|
||||||
|
# as system-login (which include system-auth) already gives pam_unix.so
|
||||||
|
# with more appropriate parameters (fix the missing nullok parameter)
|
||||||
|
|
||||||
# Archlinux specific: Update pam.d configuration for su to enable systemd-login wrapper
|
if grep -q pam_unix.so /etc/pam.d/su; then
|
||||||
# Also remove pam_unix.so from su configuration
|
echo "Fixing pam.d"
|
||||||
# as system-login (which include system-auth) already gives pam_unix.so
|
cat <<EOF > /etc/pam.d/su
|
||||||
# with more appropriate parameters (fix the missing nullok parameter)
|
|
||||||
|
|
||||||
if [ -n "`cat /etc/pam.d/su | grep pam_unix.so`" ] ; then
|
|
||||||
echo "Fixing pam.d"
|
|
||||||
cat <<EOF > /etc/pam.d/su
|
|
||||||
#%PAM-1.0
|
#%PAM-1.0
|
||||||
auth sufficient pam_rootok.so
|
auth sufficient pam_rootok.so
|
||||||
# Uncomment the following line to implicitly trust users in the "wheel" group.
|
# Uncomment the following line to implicitly trust users in the "wheel" group.
|
||||||
@ -353,73 +347,69 @@ auth include system-login
|
|||||||
account include system-login
|
account include system-login
|
||||||
session include system-login
|
session include system-login
|
||||||
EOF
|
EOF
|
||||||
cp /etc/pam.d/su /etc/pam.d/su-l
|
cp /etc/pam.d/su /etc/pam.d/su-l
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Archlinux specific: ensure tty1 is enabled
|
# Archlinux specific: ensure tty1 is enabled
|
||||||
rm -f /etc/systemd/system/getty.target.wants/getty@tty*.service
|
rm -f /etc/systemd/system/getty.target.wants/getty@tty*.service
|
||||||
systemctl enable getty\@tty1.service
|
systemctl enable getty\@tty1.service
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
}
|
}
|
||||||
|
|
||||||
## arg 1: the new package version
|
## arg 1: the new package version
|
||||||
post_install() {
|
post_install() {
|
||||||
|
update_qubesconfig
|
||||||
|
|
||||||
update_qubesconfig
|
# do the rest of %post thing only when updating for the first time...
|
||||||
|
if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
|
||||||
|
cp /etc/init/serial.conf /var/lib/qubes/serial.orig
|
||||||
|
fi
|
||||||
|
|
||||||
# do the rest of %post thing only when updating for the first time...
|
# Remove most of the udev scripts to speed up the VM boot time
|
||||||
if [ -e /etc/init/serial.conf ] && ! [ -f /var/lib/qubes/serial.orig ] ; then
|
# Just leave the xen* scripts, that are needed if this VM was
|
||||||
cp /etc/init/serial.conf /var/lib/qubes/serial.orig
|
# ever used as a net backend (e.g. as a VPN domain in the future)
|
||||||
fi
|
#echo "--> Removing unnecessary udev scripts..."
|
||||||
|
mkdir -p /var/lib/qubes/removed-udev-scripts
|
||||||
|
for f in /etc/udev/rules.d/*
|
||||||
|
do
|
||||||
|
if [ "$(basename "$f")" == "xen-backend.rules" ] ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# Remove most of the udev scripts to speed up the VM boot time
|
if [ "$(basename "$f")" == "50-qubes-misc.rules" ] ; then
|
||||||
# Just leave the xen* scripts, that are needed if this VM was
|
continue
|
||||||
# ever used as a net backend (e.g. as a VPN domain in the future)
|
fi
|
||||||
#echo "--> Removing unnecessary udev scripts..."
|
|
||||||
mkdir -p /var/lib/qubes/removed-udev-scripts
|
|
||||||
for f in /etc/udev/rules.d/*
|
|
||||||
do
|
|
||||||
if [ $(basename $f) == "xen-backend.rules" ] ; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $(basename $f) == "50-qubes-misc.rules" ] ; then
|
if echo "$f" | grep -q qubes; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo $f | grep -q qubes; then
|
mv "$f" /var/lib/qubes/removed-udev-scripts/
|
||||||
continue
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
mv $f /var/lib/qubes/removed-udev-scripts/
|
mkdir -p /rw
|
||||||
done
|
|
||||||
|
|
||||||
mkdir -p /rw
|
configure_notification-daemon
|
||||||
|
configure_selinux
|
||||||
|
|
||||||
configure_notification-daemon
|
configure_systemd 0
|
||||||
configure_selinux
|
|
||||||
|
|
||||||
configure_systemd 0
|
update_finalize
|
||||||
|
|
||||||
update_finalize
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## arg 1: the new package version
|
## arg 1: the new package version
|
||||||
## arg 2: the old package version
|
## arg 2: the old package version
|
||||||
post_upgrade() {
|
post_upgrade() {
|
||||||
|
update_qubesconfig
|
||||||
|
|
||||||
update_qubesconfig
|
configure_notification-daemon
|
||||||
|
configure_selinux
|
||||||
|
|
||||||
configure_notification-daemon
|
configure_systemd 1
|
||||||
configure_selinux
|
|
||||||
|
|
||||||
configure_systemd 1
|
|
||||||
|
|
||||||
|
|
||||||
update_finalize
|
update_finalize
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################
|
######################
|
||||||
@ -428,7 +418,6 @@ post_upgrade() {
|
|||||||
|
|
||||||
## arg 1: the old package version
|
## arg 1: the old package version
|
||||||
pre_remove() {
|
pre_remove() {
|
||||||
|
|
||||||
# no more packages left
|
# no more packages left
|
||||||
if [ -e /var/lib/qubes/fstab.orig ] ; then
|
if [ -e /var/lib/qubes/fstab.orig ] ; then
|
||||||
mv /var/lib/qubes/fstab.orig /etc/fstab
|
mv /var/lib/qubes/fstab.orig /etc/fstab
|
||||||
@ -438,7 +427,7 @@ pre_remove() {
|
|||||||
mv /var/lib/qubes/serial.orig /etc/init/serial.conf
|
mv /var/lib/qubes/serial.orig /etc/init/serial.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $1 -eq 0 ] ; then
|
if [ "$1" -eq 0 ] ; then
|
||||||
# Run this only during uninstall.
|
# Run this only during uninstall.
|
||||||
# Save the preset file to later use it to re-preset services there
|
# Save the preset file to later use it to re-preset services there
|
||||||
# once the Qubes OS preset file is removed.
|
# once the Qubes OS preset file is removed.
|
||||||
@ -446,12 +435,10 @@ pre_remove() {
|
|||||||
cp -f /usr/lib/systemd/system-preset/$qubes_preset_file /run/qubes-uninstall/
|
cp -f /usr/lib/systemd/system-preset/$qubes_preset_file /run/qubes-uninstall/
|
||||||
cp -f /usr/lib/systemd/system-preset/$qubes_preset_file /run/qubes-uninstall/
|
cp -f /usr/lib/systemd/system-preset/$qubes_preset_file /run/qubes-uninstall/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## arg 1: the old package version
|
## arg 1: the old package version
|
||||||
post_remove() {
|
post_remove() {
|
||||||
|
|
||||||
changed=
|
changed=
|
||||||
|
|
||||||
if [ -d /run/qubes-uninstall ]
|
if [ -d /run/qubes-uninstall ]
|
||||||
@ -478,5 +465,4 @@ post_remove() {
|
|||||||
for srv in qubes-sysinit qubes-misc-post qubes-mount-dirs qubes-network qubes-qrexec-agent; do
|
for srv in qubes-sysinit qubes-misc-post qubes-mount-dirs qubes-network qubes-qrexec-agent; do
|
||||||
systemctl disable $srv.service
|
systemctl disable $srv.service
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user