More improvements

This commit is contained in:
Kron4ek 2021-05-07 20:17:57 +05:00 committed by GitHub
parent 2313664285
commit a3450c7757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,7 +31,7 @@ export working_dir=/tmp/"$(basename "${script}")"_"${USER}"_"${script_md5}"
# a problem with mounting the squashfs image due to an incorrectly calculated offset.
# The size of this script
scriptsize=17635
scriptsize=17981
# The size of the utils.tar archive
# utils.tar contains bwrap and squashfuse binaries
@ -161,32 +161,42 @@ elif [ "$1" = "-u" ] || [ "$1" = "-U" ]; then
head -c $scriptsize "${script}" > conty-start.sh
fi
# Update Arch mirrorlist
clear
echo "Updating Arch mirrorlist"
bash "${script}" reflector --protocol https --score 5 --sort rate --save sqfs/etc/pacman.d/mirrorlist
# Check if there are additional arguments passed
shift
if [ -n "$1" ]; then
export packagelist="$@"
fi
# Generate a script to perform inside Conty
# It updates Arch mirrorlist
# Updates keyrings
# Updates all installed packages
# Installs additional packages (if requested)
# Clears package cache
cat <<EOF > container-update.sh
reflector --protocol https --score 5 --sort rate --save /etc/pacman.d/mirrorlist
fakeroot -- pacman -q -Syy 2>/dev/null
yes | fakeroot -- pacman -q -S archlinux-keyring 2>/dev/null
yes | fakeroot -- pacman -q -S chaotic-keyring 2>/dev/null
rm -rf /etc/pacman.d/gnupg
fakeroot -- pacman-key --init
fakeroot -- pacman-key --populate archlinux
fakeroot -- pacman-key --populate chaotic
yes | fakeroot -- pacman -q --overwrite "*" -Su 2>/dev/null
yes | fakeroot -- pacman -q -S ${packagelist} 2>/dev/null
rm -f /var/cache/pacman/pkg/*
update-ca-trust
EOF
bind_items="--bind sqfs/var /var --bind sqfs/etc /etc --bind sqfs/usr /usr \
--ro-bind-try /etc/resolv.conf /etc/resolv.conf \
--ro-bind-try /etc/nsswitch.conf /etc/nsswitch.conf \
--ro-bind-try /etc/hosts /etc/hosts"
# Update all packages installed inside the container
# Execute the previously generated script
clear
echo "Updating packages"
mkdir -p pacman_pkg_cache
bash "${script}" ${bind_items} \
bash -c 'yes | fakeroot pacman -q --cachedir pacman_pkg_cache --overwrite "*" -Syu 2>/dev/null'
# Install additional packages if requested
shift
if [ -n "$1" ]; then
clear
echo "Installing additional packages"
export packagelist="$@"
bash "${script}" ${bind_items} \
bash -c 'yes | fakeroot pacman -q --cachedir pacman_pkg_cache -S ${packagelist} 2>/dev/null'
fi
echo "Updating and installing packages"
bash "${script}" ${bind_items} bash container-update.sh
# Create a squashfs image
clear