mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
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:
33
compile.sh
33
compile.sh
@@ -130,26 +130,19 @@ else
|
|||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$OFFLINE_WORK" == "yes" ]; then
|
||||||
|
|
||||||
# Check for required packages
|
echo -e "\n"
|
||||||
if [[ -z "$(command -v dialog)" ]]; then
|
display_alert "* " "You are working offline."
|
||||||
sudo apt-get update
|
display_alert "* " "Sources, time and host will not be checked"
|
||||||
sudo apt-get install -y dialog
|
echo -e "\n"
|
||||||
fi
|
sleep 3s
|
||||||
|
|
||||||
if [[ -z "$(command -v fuser)" ]]; then
|
else
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y psmisc
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "$(command -v getfacl)" ]]; then
|
# check and install the basic utilities here
|
||||||
sudo apt-get update
|
prepare_host_basic
|
||||||
sudo apt-get install -y acl
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "$(command -v uuidgen)" ]]; then
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y uuid-runtime
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for Vagrant
|
# 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"
|
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
|
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
|
curl -fsSL "https://download.docker.com/linux/${codeid}/gpg" | apt-key add -qq - > /dev/null 2>&1
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|||||||
@@ -968,22 +968,26 @@ wait_for_package_manager()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# prepare_host_basic
|
# prepare_host_basic
|
||||||
#
|
#
|
||||||
# * installs only basic packages
|
# * installs only basic packages
|
||||||
#
|
#
|
||||||
prepare_host_basic()
|
prepare_host_basic()
|
||||||
{
|
{
|
||||||
# wait until package manager finishes possible system maintanace
|
# the checklist includes a list of package names separated by a space
|
||||||
wait_for_package_manager
|
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
|
if [[ $(dpkg-query -W -f='${db:Status-Abbrev}\n' dialog 2>/dev/null) != *ii* ]]; then
|
||||||
display_alert "Installing package" "dialog"
|
display_alert "Installing basic packages" "$checklist"
|
||||||
apt-get -q update && apt-get install -q -y --no-install-recommends dialog
|
apt-get -qq update && \
|
||||||
|
apt-get install -qq -y --no-install-recommends $checklist
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1092,7 +1096,7 @@ prepare_host()
|
|||||||
grep -q i386 <(dpkg --print-foreign-architectures) || dpkg --add-architecture i386
|
grep -q i386 <(dpkg --print-foreign-architectures) || dpkg --add-architecture i386
|
||||||
# build aarch64
|
# build aarch64
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if systemd-detect-virt -q -c; then
|
if systemd-detect-virt -q -c; then
|
||||||
display_alert "Running in container" "$(systemd-detect-virt)" "info"
|
display_alert "Running in container" "$(systemd-detect-virt)" "info"
|
||||||
# disable apt-cacher unless NO_APT_CACHER=no is not specified explicitly
|
# disable apt-cacher unless NO_APT_CACHER=no is not specified explicitly
|
||||||
|
|||||||
20
lib/main.sh
20
lib/main.sh
@@ -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 KERNEL_ONLY, KERNEL_CONFIGURE, BOARD, BRANCH or RELEASE are not set, display selection menu
|
||||||
if [[ -z $KERNEL_ONLY ]]; then
|
if [[ -z $KERNEL_ONLY ]]; then
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user