From 39ae791929bbd93f937ec3962b63bee978cd4704 Mon Sep 17 00:00:00 2001 From: Luke Short Date: Thu, 3 Aug 2023 01:54:10 -0600 Subject: [PATCH] init: arch Linux speed improvements (#828) * init: Avoid re-installing Pacman packages * Add the "--needed" argument to Pacman to only install new packages. * Pacman cache is also only updated once instead of during every command. These changes makes entering an Arch Linux container much faster. Resolves #826 Signed-off-by: Luke Short * init: do not force Pacman upgrades Upgrades should only run when the "--upgrade" argument is passsed. Related #826 Signed-off-by: Luke Short --------- Signed-off-by: Luke Short --- distrobox-init | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/distrobox-init b/distrobox-init index 40b5b8356e..8a9ecba2f2 100755 --- a/distrobox-init +++ b/distrobox-init @@ -617,9 +617,12 @@ if [ "${upgrade}" -ne 0 ] || ! command -v find || ! command -v mount || ! comman fi elif command -v pacman; then + # Update the package repository cache exactly once before installing packages. + pacman -S -y -y + # If we need to upgrade, do it and exit, no further action required. if [ "${upgrade}" -ne 0 ]; then - pacman -Syyu --noconfirm + pacman -S -u --noconfirm exit fi # In archlinux official images, pacman is configured to ignore locale and docs @@ -631,8 +634,7 @@ if [ "${upgrade}" -ne 0 ] || ! command -v find || ! command -v mount || ! comman # Check if shell_pkg is available in distro's repo. If not we # fall back to bash, and we set the SHELL variable to bash so # that it is set up correctly for the user. - pacman --noconfirm -Syyu - if ! pacman -Sy --noconfirm "${shell_pkg}"; then + if ! pacman -S --needed --noconfirm "${shell_pkg}"; then shell_pkg="bash" fi deps=" @@ -665,12 +667,12 @@ if [ "${upgrade}" -ne 0 ] || ! command -v find || ! command -v mount || ! comman fi done # shellcheck disable=SC2086 - pacman -Sy --noconfirm ${install_pkg} + pacman -S --needed --noconfirm ${install_pkg} # Install additional packages passed at distrbox-create time if [ -n "${container_additional_packages}" ]; then # shellcheck disable=SC2086 - pacman -Sy --noconfirm ${container_additional_packages} + pacman -S --needed --noconfirm ${container_additional_packages} fi elif command -v slackpkg; then