Code cleanup and optimization (#2965)

* prepare_host_basic: Code cleanup and optimization

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* Checking and install at the beginning the basic utilities

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>

* Logging has been removed because it makes little sense.

Signed-off-by: The-going <48602507+The-going@users.noreply.github.com>
This commit is contained in:
The-going
2021-07-05 00:25:40 +03:00
committed by GitHub
parent fb69b203d6
commit eca7bbb12d
3 changed files with 21 additions and 52 deletions

View File

@@ -130,26 +130,19 @@ else
exit $?
fi
if [ "$OFFLINE_WORK" == "yes" ]; then
# Check for required packages
if [[ -z "$(command -v dialog)" ]]; then
sudo apt-get update
sudo apt-get install -y dialog
fi
echo -e "\n"
display_alert "* " "You are working offline."
display_alert "* " "Sources, time and host will not be checked"
echo -e "\n"
sleep 3s
if [[ -z "$(command -v fuser)" ]]; then
sudo apt-get update
sudo apt-get install -y psmisc
fi
else
if [[ -z "$(command -v getfacl)" ]]; then
sudo apt-get update
sudo apt-get install -y acl
fi
# check and install the basic utilities here
prepare_host_basic
if [[ -z "$(command -v uuidgen)" ]]; then
sudo apt-get update
sudo apt-get install -y uuid-runtime
fi
# Check for Vagrant
@@ -193,14 +186,6 @@ if [[ "${1}" == docker && -f /etc/debian_version && -z "$(command -v docker)" ]]
display_alert "Docker not installed." "Installing" "Info"
echo "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/${codeid} ${codename} stable" > /etc/apt/sources.list.d/docker.list
# minimal set of utilities that are needed for prep
packages=("curl" "gnupg")
for i in "${packages[@]}"
do
[[ ! $(command -v "${i}") ]] && install_packages+=${i}" "
done
[[ -z "${install_packages}" ]] && apt-get update;apt-get install -y -qq --no-install-recommends ${install_packages}
curl -fsSL "https://download.docker.com/linux/${codeid}/gpg" | apt-key add -qq - > /dev/null 2>&1
export DEBIAN_FRONTEND=noninteractive
apt-get update

View File

@@ -968,22 +968,26 @@ wait_for_package_manager()
# prepare_host_basic
#
# * installs only basic packages
#
prepare_host_basic()
{
# wait until package manager finishes possible system maintanace
wait_for_package_manager
# the checklist includes a list of package names separated by a space
local checklist="dialog psmisc acl uuid-runtime curl gnupg gawk"
# need to install dialog if person is starting with a interactive mode
# Don't use this function here.
# wait_for_package_manager
#
# The `psmisk` package is not installed yet.
# We will check one package and install the entire list.
if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dialog 2>/dev/null) != *ii* ]]; then
display_alert "Installing package" "dialog"
apt-get -q update && apt-get install -q -y --no-install-recommends dialog
display_alert "Installing basic packages" "$checklist"
apt-get -qq update && \
apt-get install -qq -y --no-install-recommends $checklist
fi
}
@@ -1092,7 +1096,7 @@ prepare_host()
grep -q i386 <(dpkg --print-foreign-architectures) || dpkg --add-architecture i386
# build aarch64
fi
if systemd-detect-virt -q -c; then
display_alert "Running in container" "$(systemd-detect-virt)" "info"
# disable apt-cacher unless NO_APT_CACHER=no is not specified explicitly

View File

@@ -151,26 +151,6 @@ fi
if [ "$OFFLINE_WORK" == "yes" ]; then
echo -e "\n"
display_alert "* " "You are working offline."
display_alert "* " "Sources, time and host will not be checked"
echo -e "\n"
sleep 3s
else
# we need dialog to display the menu in case not installed. Other stuff gets installed later
prepare_host_basic
fi
# if KERNEL_ONLY, KERNEL_CONFIGURE, BOARD, BRANCH or RELEASE are not set, display selection menu
if [[ -z $KERNEL_ONLY ]]; then