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,
|
||||
# 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'.
|
||||
|
||||
#!/bin/bash
|
||||
# Maintainer: Olivier Medoc <o_medoc@yahoo.fr>
|
||||
# shellcheck disable=SC2034
|
||||
pkgname=qubes-vm-core
|
||||
pkgver=`cat version`
|
||||
pkgver=$(cat version)
|
||||
pkgrel=11
|
||||
epoch=
|
||||
pkgdesc="The Qubes core files for installation inside a Qubes VM."
|
||||
@ -25,7 +22,8 @@ options=()
|
||||
install=PKGBUILD.install
|
||||
changelog=
|
||||
|
||||
source=( PKGBUILD.qubes-ensure-lib-modules.service PKGBUILD.qubes-update-desktop-icons.hook
|
||||
source=(
|
||||
PKGBUILD.qubes-ensure-lib-modules.service PKGBUILD.qubes-update-desktop-icons.hook
|
||||
PKGBUILD-qubes-noupgrade.conf
|
||||
PKGBUILD-qubes-repo-3.1.conf
|
||||
PKGBUILD-qubes-repo-3.2.conf
|
||||
@ -35,9 +33,9 @@ noextract=()
|
||||
md5sums=(SKIP)
|
||||
|
||||
build() {
|
||||
|
||||
for source in autostart-dropins qubes-rpc qrexec misc Makefile vm-init.d vm-systemd network init version; do
|
||||
(ln -s $srcdir/../$source $srcdir/$source)
|
||||
# shellcheck disable=SC2154
|
||||
(ln -s "$srcdir/../$source" "$srcdir/$source")
|
||||
done
|
||||
|
||||
# Fix for network tools paths
|
||||
@ -53,57 +51,54 @@ sed 's:#!/usr/bin/env python:#!/usr/bin/env python2:' -i misc/*
|
||||
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)
|
||||
(cd $dir || exit 1; make)
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
# 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
|
||||
rm -r "$pkgdir/etc/yum"*
|
||||
rm -r "$pkgdir/etc/init.d"
|
||||
# Remove fedora specific scripts
|
||||
rm $pkgdir/etc/fstab
|
||||
rm "$pkgdir/etc/fstab"
|
||||
|
||||
# Install systemd script allowing to automount /lib/modules
|
||||
install -m 644 $srcdir/PKGBUILD.qubes-ensure-lib-modules.service ${pkgdir}/usr/lib/systemd/system/qubes-ensure-lib-modules.service
|
||||
install -m 644 "$srcdir/PKGBUILD.qubes-ensure-lib-modules.service" "${pkgdir}/usr/lib/systemd/system/qubes-ensure-lib-modules.service"
|
||||
|
||||
# Install pacman hook to update desktop icons
|
||||
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
|
||||
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.d drop-ins (at least 1 drop-in must be installed or pacman will fail)
|
||||
mkdir -p ${pkgdir}/etc/pacman.d
|
||||
install -m 644 $srcdir/PKGBUILD-qubes-noupgrade.conf ${pkgdir}/etc/pacman.d/10-qubes-noupgrade.conf
|
||||
mkdir -p "${pkgdir}/etc/pacman.d"
|
||||
install -m 644 "$srcdir/PKGBUILD-qubes-noupgrade.conf" "${pkgdir}/etc/pacman.d/10-qubes-noupgrade.conf"
|
||||
|
||||
# Install pacman repository
|
||||
release=`echo $pkgver | cut -d '.' -f 1,2`
|
||||
release=$(echo "$pkgver" | cut -d '.' -f 1,2)
|
||||
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 -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
|
||||
mkdir -p "$pkgdir/etc/systemd/system/getty@tty1.service.d/"
|
||||
cat <<EOF > "$pkgdir/etc/systemd/system/getty@tty1.service.d/autologin.conf"
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/usr/bin/agetty --autologin user --noclear %I 38400 linux
|
||||
EOF
|
||||
|
||||
# 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:
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/bin/bash
|
||||
qubes_preset_file="75-qubes-vm.preset"
|
||||
|
||||
###########################
|
||||
@ -5,7 +6,6 @@ qubes_preset_file="75-qubes-vm.preset"
|
||||
###########################
|
||||
|
||||
update_default_user() {
|
||||
|
||||
# Make sure there is a qubes group
|
||||
groupadd --force --system --gid 98 qubes
|
||||
|
||||
@ -15,7 +15,6 @@ update_default_user() {
|
||||
useradd --user-group --create-home --shell /bin/zsh user
|
||||
}
|
||||
usermod -a --groups qubes user
|
||||
|
||||
}
|
||||
|
||||
## arg 1: the new package version
|
||||
@ -48,7 +47,6 @@ pre_upgrade() {
|
||||
echo "Pre upgrade..."
|
||||
|
||||
update_default_user
|
||||
|
||||
}
|
||||
|
||||
###################
|
||||
@ -64,13 +62,11 @@ configure_notification-daemon() {
|
||||
}
|
||||
|
||||
configure_selinux() {
|
||||
|
||||
# SELinux is not enabled on archlinux
|
||||
#echo "--> Disabling SELinux..."
|
||||
echo "SELINUX not enabled on archlinux. skipped."
|
||||
# sed -e s/^SELINUX=.*$/SELINUX=disabled/ -i /etc/selinux/config
|
||||
# setenforce 0 2>/dev/null
|
||||
|
||||
}
|
||||
|
||||
############################
|
||||
@ -78,7 +74,6 @@ configure_selinux() {
|
||||
############################
|
||||
|
||||
update_qubesconfig() {
|
||||
|
||||
# Create NetworkManager configuration if we do not have it
|
||||
if ! [ -e /etc/NetworkManager/NetworkManager.conf ]; then
|
||||
echo '[main]' > /etc/NetworkManager/NetworkManager.conf
|
||||
@ -107,15 +102,18 @@ update_qubesconfig() {
|
||||
|
||||
# Location of files which contains list of protected files
|
||||
mkdir -p /etc/qubes/protected-files.d
|
||||
# shellcheck source=../init/functions
|
||||
. /usr/lib/qubes/init/functions
|
||||
|
||||
# qubes-core-vm has been broken for some time - it overrides /etc/hosts; restore original content
|
||||
if ! is_protected_file /etc/hosts ; then
|
||||
if ! grep -q localhost /etc/hosts; then
|
||||
|
||||
cat <<EOF > /etc/hosts
|
||||
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 `hostname`
|
||||
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 $(hostname)
|
||||
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
|
||||
EOF
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -124,10 +122,10 @@ EOF
|
||||
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
|
||||
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
|
||||
echo "${ip} $(hostname)" >> /etc/hosts
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@ -139,14 +137,13 @@ EOF
|
||||
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 '"'`
|
||||
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 .`
|
||||
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
|
||||
localedef -i "$base" "$charmap" "$current_locale"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
############################
|
||||
@ -161,7 +158,7 @@ is_masked() {
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
target=`readlink /etc/systemd/system/"$1" 2>/dev/null` || :
|
||||
target=$(readlink /etc/systemd/system/"$1" 2>/dev/null) || :
|
||||
if [ "$target" = "/dev/null" ]
|
||||
then
|
||||
return 0
|
||||
@ -183,16 +180,16 @@ unmask() {
|
||||
|
||||
preset_units() {
|
||||
local represet=
|
||||
cat "$1" | while read action unit_name
|
||||
while read -r action unit_name < "$1"
|
||||
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
|
||||
represet=1
|
||||
continue
|
||||
fi
|
||||
echo "$action $unit_name" | grep -q '^[[:space:]]*[^#;]' || continue
|
||||
[ -n "$action" -a -n "$unit_name" ] || continue
|
||||
if [ "$2" = "initial" -o "$represet" = "1" ]
|
||||
[[ -n "$action" && -n "$unit_name" ]] || continue
|
||||
if [ "$2" = "initial" ] || [ "$represet" = "1" ]
|
||||
then
|
||||
if [ "$action" = "disable" ] && is_static "$unit_name"
|
||||
then
|
||||
@ -217,7 +214,7 @@ preset_units() {
|
||||
}
|
||||
|
||||
restore_units() {
|
||||
grep '^[[:space:]]*[^#;]' "$1" | while read action unit_name
|
||||
while read -r action unit_name < grep '^[[:space:]]*[^#;]' "$1"
|
||||
do
|
||||
if is_static "$unit_name" && is_masked "$unit_name"
|
||||
then
|
||||
@ -230,8 +227,7 @@ restore_units() {
|
||||
}
|
||||
|
||||
configure_systemd() {
|
||||
|
||||
if [ $1 -eq 1 ]
|
||||
if [ "$1" -eq 1 ]
|
||||
then
|
||||
preset_units /usr/lib/systemd/system-preset/$qubes_preset_file initial
|
||||
changed=true
|
||||
@ -249,7 +245,7 @@ else
|
||||
done
|
||||
fi
|
||||
|
||||
if [ $1 -eq 1 ]
|
||||
if [ "$1" -eq 1 ]
|
||||
then
|
||||
# First install.
|
||||
# Set default "runlevel".
|
||||
@ -277,7 +273,6 @@ if [ "x$changed" != "x" ]
|
||||
then
|
||||
systemctl daemon-reload
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
######################
|
||||
@ -318,7 +313,6 @@ fi
|
||||
}
|
||||
|
||||
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
|
||||
@ -340,7 +334,7 @@ update_finalize() {
|
||||
# as system-login (which include system-auth) already gives pam_unix.so
|
||||
# with more appropriate parameters (fix the missing nullok parameter)
|
||||
|
||||
if [ -n "`cat /etc/pam.d/su | grep pam_unix.so`" ] ; then
|
||||
if grep -q pam_unix.so /etc/pam.d/su; then
|
||||
echo "Fixing pam.d"
|
||||
cat <<EOF > /etc/pam.d/su
|
||||
#%PAM-1.0
|
||||
@ -365,7 +359,6 @@ EOF
|
||||
|
||||
## arg 1: the new package version
|
||||
post_install() {
|
||||
|
||||
update_qubesconfig
|
||||
|
||||
# do the rest of %post thing only when updating for the first time...
|
||||
@ -380,19 +373,19 @@ post_install() {
|
||||
mkdir -p /var/lib/qubes/removed-udev-scripts
|
||||
for f in /etc/udev/rules.d/*
|
||||
do
|
||||
if [ $(basename $f) == "xen-backend.rules" ] ; then
|
||||
if [ "$(basename "$f")" == "xen-backend.rules" ] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ $(basename $f) == "50-qubes-misc.rules" ] ; then
|
||||
if [ "$(basename "$f")" == "50-qubes-misc.rules" ] ; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if echo $f | grep -q qubes; then
|
||||
if echo "$f" | grep -q qubes; then
|
||||
continue
|
||||
fi
|
||||
|
||||
mv $f /var/lib/qubes/removed-udev-scripts/
|
||||
mv "$f" /var/lib/qubes/removed-udev-scripts/
|
||||
done
|
||||
|
||||
mkdir -p /rw
|
||||
@ -403,13 +396,11 @@ post_install() {
|
||||
configure_systemd 0
|
||||
|
||||
update_finalize
|
||||
|
||||
}
|
||||
|
||||
## arg 1: the new package version
|
||||
## arg 2: the old package version
|
||||
post_upgrade() {
|
||||
|
||||
update_qubesconfig
|
||||
|
||||
configure_notification-daemon
|
||||
@ -419,7 +410,6 @@ post_upgrade() {
|
||||
|
||||
|
||||
update_finalize
|
||||
|
||||
}
|
||||
|
||||
######################
|
||||
@ -428,7 +418,6 @@ post_upgrade() {
|
||||
|
||||
## arg 1: the old package version
|
||||
pre_remove() {
|
||||
|
||||
# no more packages left
|
||||
if [ -e /var/lib/qubes/fstab.orig ] ; then
|
||||
mv /var/lib/qubes/fstab.orig /etc/fstab
|
||||
@ -438,7 +427,7 @@ pre_remove() {
|
||||
mv /var/lib/qubes/serial.orig /etc/init/serial.conf
|
||||
fi
|
||||
|
||||
if [ $1 -eq 0 ] ; then
|
||||
if [ "$1" -eq 0 ] ; then
|
||||
# Run this only during uninstall.
|
||||
# Save the preset file to later use it to re-preset services there
|
||||
# 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/
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
## arg 1: the old package version
|
||||
post_remove() {
|
||||
|
||||
changed=
|
||||
|
||||
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
|
||||
systemctl disable $srv.service
|
||||
done
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user