build/compile.sh
Przemysław Sztoch bc0fbb85bc Add USERPATCHES_PATH optional setting to config file. (#1450)
Required if userpatches folder is conflicted between two different configs.
This is frequent and requires maintaining two copies of the builder.
2019-07-09 22:50:49 -04:00

101 lines
3.2 KiB
Bash
Executable file

#!/bin/bash
#
# Copyright (c) 2015 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 for more info
SRC="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
# fallback for Trusty
[[ -z "${SRC}" ]] && SRC="$(pwd)"
# 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 [[ -f "${SRC}"/lib/general.sh && -L "${SRC}"/main.sh ]]; then
# shellcheck source=lib/general.sh
source "${SRC}"/lib/general.sh
else
echo "Error: missing build directory structure"
echo "Please clone the full repository https://github.com/armbian/build/"
exit 255
fi
# source build configuration file
if [[ -n $1 && -f "${SRC}/config-$1.conf" ]]; then
display_alert "Using config file" "config-$1.conf" "info"
# shellcheck source=/dev/null
source "${SRC}/config-$1.conf"
else
# copy default config from the template
if [[ ! -f "${SRC}"/config-default.conf ]]; then
display_alert "Create example config file using template" "config-default.conf" "info"
if [[ ! -f "${SRC}"/config-example.conf ]]; then
cp "${SRC}"/config/templates/config-example.conf "${SRC}"/config-example.conf || exit 1
fi
ln -s config-example.conf "${SRC}"/config-default.conf || exit 1
fi
display_alert "Using config file" "config-default.conf" "info"
# shellcheck source=/dev/null
source "${SRC}"/config-default.conf
fi
[[ -z "${USERPATCHES_PATH}" ]] && USERPATCHES_PATH="$SRC/userpatches"
if [[ $EUID != 0 ]]; then
display_alert "This script requires root privileges, trying to use sudo" "" "wrn"
sudo "$SRC/compile.sh" "$@"
exit $?
fi
# Script parameters handling
for i in "$@"; do
if [[ $i == *=* ]]; then
parameter=${i%%=*}
value=${i##*=}
display_alert "Command line: setting $parameter to" "${value:-(empty)}" "info"
eval "$parameter=\"$value\""
fi
done
if [[ ! -f $SRC/.ignore_changes ]]; then
echo -e "[\e[0;32m o.k. \x1B[0m] This script will try to update"
git pull
CHANGED_FILES=$(git diff --name-only)
if [[ -n $CHANGED_FILES ]]; then
echo -e "[\e[0;35m warn \x1B[0m] Can't update since you made changes to: \e[0;32m\n${CHANGED_FILES}\x1B[0m"
while true; do
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m or \e[0;33mexit\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue, \e[0;33mdiff\x1B[0m to display changes"
read -r
if [[ "$REPLY" == "diff" ]]; then
git diff
elif [[ "$REPLY" == "exit" ]]; then
exit 1
elif [[ "$REPLY" == "" ]]; then
break
else
echo "Unknown command!"
fi
done
else
git checkout "${LIB_TAG:-master}"
fi
fi
if [[ $BUILD_ALL == yes || $BUILD_ALL == demo ]]; then
# shellcheck source=lib/build-all.sh
source "${SRC}"/lib/build-all.sh
else
# shellcheck source=lib/main.sh
source "${SRC}"/lib/main.sh
fi