Skip to content

Commit

Permalink
init: arch Linux speed improvements (#828)
Browse files Browse the repository at this point in the history
* 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 <ekultails@gmail.com>

* init: do not force Pacman upgrades

Upgrades should only run when the "--upgrade" argument is passsed.

Related #826

Signed-off-by: Luke Short <ekultails@gmail.com>

---------

Signed-off-by: Luke Short <ekultails@gmail.com>
  • Loading branch information
LukeShortCloud authored Aug 3, 2023
1 parent a875ab6 commit 39ae791
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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="
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 39ae791

Please sign in to comment.