mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
154 lines
3.9 KiB
Bash
Executable File
154 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2013-2021 Igor Pecovnik, igor.pecovnik@gma**.com
|
|
#
|
|
# This file is licensed under the terms of the GNU General Public
|
|
# License version 2. This program is licensed "as is" without any
|
|
# warranty of any kind, whether express or implied.
|
|
#
|
|
# This file is a part of the Armbian build script
|
|
# https://github.com/armbian/build/
|
|
|
|
# DO NOT EDIT THIS FILE
|
|
# use configuration files like config-default.conf to set the build configuration
|
|
# check Armbian documentation https://docs.armbian.com/ for more info
|
|
|
|
SRC="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|
|
|
# check for whitespace in ${SRC} and exit for safety reasons
|
|
grep -q "[[:space:]]" <<< "${SRC}" && {
|
|
echo "\"${SRC}\" contains whitespace. Not supported. Aborting." >&2
|
|
exit 1
|
|
}
|
|
|
|
cd "${SRC}" || exit
|
|
|
|
if [[ "${ARMBIAN_ENABLE_CALL_TRACING}" == "yes" ]]; then
|
|
set -T # inherit return/debug traps
|
|
mkdir -p "${SRC}"/output/debug
|
|
echo -n "" > "${SRC}"/output/debug/calls.txt
|
|
trap 'echo "${BASH_LINENO[@]}|${BASH_SOURCE[@]}|${FUNCNAME[@]}" >> ${SRC}/output/debug/calls.txt ;' RETURN
|
|
fi
|
|
|
|
if [[ -f "${SRC}"/lib/import-functions.sh ]]; then
|
|
|
|
# Declare this folder as safe
|
|
if ! grep -q "directory = \*" "$HOME/.gitconfig" 2> /dev/null; then
|
|
git config --global --add safe.directory "*"
|
|
fi
|
|
|
|
# shellcheck source=lib/import-functions.sh
|
|
source "${SRC}"/lib/import-functions.sh
|
|
|
|
else
|
|
|
|
echo "Error: missing build directory structure"
|
|
echo "Please clone the full repository https://github.com/armbian/build/"
|
|
exit 255
|
|
|
|
fi
|
|
|
|
check_args "$@"
|
|
|
|
do_update_src
|
|
|
|
if [[ "${EUID}" == "0" ]] || [[ "${1}" == "vagrant" ]]; then
|
|
:
|
|
elif [[ "${1}" == docker || "${1}" == dockerpurge || "${1}" == docker-shell ]] && grep -q "$(whoami)" <(getent group docker); then
|
|
:
|
|
else
|
|
display_alert "This script requires root privileges, trying to use sudo" "" "wrn"
|
|
sudo "${SRC}/compile.sh" "$@"
|
|
exit $?
|
|
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
|
|
|
|
# check and install the basic utilities here
|
|
prepare_host_basic
|
|
|
|
fi
|
|
|
|
handle_vagrant "$@"
|
|
|
|
# Purge Armbian Docker images
|
|
if [[ "${1}" == dockerpurge && -f /etc/debian_version ]]; then
|
|
display_alert "Purging Armbian Docker containers" "" "wrn"
|
|
docker container ls -a | grep armbian | awk '{print $1}' | xargs docker container rm &> /dev/null
|
|
docker image ls | grep armbian | awk '{print $3}' | xargs docker image rm &> /dev/null
|
|
shift
|
|
set -- "docker" "$@"
|
|
fi
|
|
|
|
# Docker shell
|
|
if [[ "${1}" == docker-shell ]]; then
|
|
shift
|
|
#shellcheck disable=SC2034
|
|
SHELL_ONLY=yes
|
|
set -- "docker" "$@"
|
|
fi
|
|
|
|
handle_docker "$@"
|
|
|
|
prepare_userpatches
|
|
|
|
if [[ -z "${CONFIG}" && -n "$1" && -f "${SRC}/userpatches/config-$1.conf" ]]; then
|
|
CONFIG="userpatches/config-$1.conf"
|
|
shift
|
|
fi
|
|
|
|
# usind default if custom not found
|
|
if [[ -z "${CONFIG}" && -f "${SRC}/userpatches/config-default.conf" ]]; then
|
|
CONFIG="userpatches/config-default.conf"
|
|
fi
|
|
|
|
# source build configuration file
|
|
CONFIG_FILE="$(realpath "${CONFIG}")"
|
|
|
|
if [[ ! -f "${CONFIG_FILE}" ]]; then
|
|
display_alert "Config file does not exist" "${CONFIG}" "error"
|
|
exit 254
|
|
fi
|
|
|
|
CONFIG_PATH=$(dirname "${CONFIG_FILE}")
|
|
|
|
# Source the extensions manager library at this point, before sourcing the config.
|
|
# This allows early calls to enable_extension(), but initialization proper is done later.
|
|
# shellcheck source=lib/extensions.sh
|
|
source "${SRC}"/lib/extensions.sh
|
|
|
|
display_alert "Using config file" "${CONFIG_FILE}" "info"
|
|
pushd "${CONFIG_PATH}" > /dev/null || exit
|
|
# shellcheck source=/dev/null
|
|
source "${CONFIG_FILE}"
|
|
popd > /dev/null || exit
|
|
|
|
[[ -z "${USERPATCHES_PATH}" ]] && USERPATCHES_PATH="${CONFIG_PATH}"
|
|
|
|
# Script parameters handling
|
|
while [[ "${1}" == *=* ]]; do
|
|
|
|
parameter=${1%%=*}
|
|
value=${1##*=}
|
|
shift
|
|
display_alert "Command line: setting $parameter to" "${value:-(empty)}" "info"
|
|
eval "$parameter=\"$value\""
|
|
|
|
done
|
|
|
|
prepare_and_config_main_build_single
|
|
|
|
if [[ -z $1 ]]; then
|
|
do_default
|
|
else
|
|
eval "$@"
|
|
fi
|