Skip to content

Commit

Permalink
Do not update package cache on install/upgrade. It takes quite a long…
Browse files Browse the repository at this point in the history
… time and we don't do this for dnf/yum either.

Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Nov 26, 2023
1 parent 2338c9e commit 0094c47
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions automated install/basic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,10 @@ package_manager_detect() {
# Set some global variables here
# We don't set them earlier since the installed package manager might be rpm, so these values would be different
PKG_MANAGER="apt-get"
# A variable to store the command used to update the package cache
UPDATE_PKG_CACHE="${PKG_MANAGER} update"
# The command we will use to actually install packages
PKG_INSTALL=("${PKG_MANAGER}" -qq --no-install-recommends install)
# grep -c will return 1 if there are no matches. This is an acceptable condition, so we OR TRUE to prevent set -e exiting the script.
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
# Update package cache
update_package_cache || exit 1
# Packages required to perform the os_check and FTL binary detection
OS_CHECK_DEPS=(grep dnsutils binutils)
# Packages required to run this install script
Expand Down Expand Up @@ -1290,30 +1286,6 @@ disable_resolved_stublistener() {
fi
}

update_package_cache() {
# Update package cache on apt based OSes. Do this every time since
# it's quick and packages can be updated at any time.

# Local, named variables
local str="Update local cache of available packages"
printf " %b %s..." "${INFO}" "${str}"
# Create a command from the package cache variable
if eval "${UPDATE_PKG_CACHE}" &> /dev/null; then
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${str}"
else
# Otherwise, show an error and exit

# In case we used apt-get and apt is also available, we use this as recommendation as we have seen it
# gives more user-friendly (interactive) advice
if [[ ${PKG_MANAGER} == "apt-get" ]] && is_command apt ; then
UPDATE_PKG_CACHE="apt update"
fi
printf "%b %b %s\\n" "${OVER}" "${CROSS}" "${str}"
printf " %b Error: Unable to update package cache. Please try \"%s\"%b\\n" "${COL_LIGHT_RED}" "sudo ${UPDATE_PKG_CACHE}" "${COL_NC}"
return 1
fi
}

# Let user know if they have outdated packages on their system and
# advise them to run a package update at soonest possible.
notify_package_updates_available() {
Expand Down

0 comments on commit 0094c47

Please sign in to comment.