2015-12-02 19:33:32 +00:00
#!/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.
#
2017-08-01 09:51:10 +00:00
# This file is a part of the Armbian build script
# https://github.com/armbian/build/
2015-12-02 19:33:32 +00:00
2017-08-06 14:11:16 +00:00
# DO NOT EDIT THIS FILE
# use configuration files like config-default.conf to set the build configuration
# check Armbian documentation for more info
2019-05-30 20:19:53 +00:00
SRC = " $( dirname " $( realpath " ${ BASH_SOURCE [0] } " ) " ) "
2017-07-11 09:39:32 +00:00
# fallback for Trusty
2017-09-14 10:13:26 +00:00
[ [ -z " ${ SRC } " ] ] && SRC = " $( pwd ) "
2017-09-13 10:59:03 +00:00
# check for whitespace in $SRC and exit for safety reasons
2017-09-14 10:13:26 +00:00
grep -q "[[:space:]]" <<< " ${ SRC } " && { echo " \" ${ SRC } \" contains whitespace. Not supported. Aborting. " >& 2 ; exit 1 ; }
2017-09-13 10:59:03 +00:00
2019-05-30 20:19:53 +00:00
cd " ${ SRC } " || exit
2015-12-02 19:33:32 +00:00
2019-05-30 20:19:53 +00:00
if [ [ -f " ${ SRC } " /lib/general.sh && -L " ${ SRC } " /main.sh ] ] ; then
# shellcheck source=lib/general.sh
source " ${ SRC } " /lib/general.sh
2017-07-11 09:39:32 +00:00
else
echo "Error: missing build directory structure"
echo "Please clone the full repository https://github.com/armbian/build/"
2019-05-30 20:19:53 +00:00
exit 255
2015-12-02 19:33:32 +00:00
fi
2017-07-11 09:46:08 +00:00
# source build configuration file
2019-05-30 20:19:53 +00:00
if [ [ -n $1 && -f " ${ SRC } /config- $1 .conf " ] ] ; then
2017-07-11 09:46:08 +00:00
display_alert "Using config file" " config- $1 .conf " "info"
2019-05-30 20:19:53 +00:00
# shellcheck source=/dev/null
source " ${ SRC } /config- $1 .conf "
2017-07-11 09:46:08 +00:00
else
2019-07-06 20:35:43 +00:00
# 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
2017-07-11 09:46:08 +00:00
display_alert "Using config file" "config-default.conf" "info"
2019-05-30 20:19:53 +00:00
# shellcheck source=/dev/null
source " ${ SRC } " /config-default.conf
2017-07-11 09:46:08 +00:00
fi
2019-07-10 02:50:50 +00:00
[ [ -z " ${ USERPATCHES_PATH } " ] ] && USERPATCHES_PATH = " $SRC /userpatches "
2017-07-11 09:46:08 +00:00
2015-12-29 18:26:14 +00:00
if [ [ $EUID != 0 ] ] ; then
2017-07-11 09:39:32 +00:00
display_alert "This script requires root privileges, trying to use sudo" "" "wrn"
sudo " $SRC /compile.sh " " $@ "
2016-07-27 10:37:23 +00:00
exit $?
2015-12-07 13:55:53 +00:00
fi
2015-12-02 19:33:32 +00:00
2018-05-24 19:33:16 +00:00
# Script parameters handling
for i in " $@ " ; do
if [ [ $i = = *= * ] ] ; then
parameter = ${ i %%=* }
value = ${ i ##*= }
display_alert " Command line: setting $parameter to " " ${ value :- (empty) } " "info"
2019-05-30 20:19:53 +00:00
eval " $parameter =\" $value \" "
2018-05-24 19:33:16 +00:00
fi
done
2016-03-22 14:32:53 +00:00
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
2016-07-27 10:37:23 +00:00
echo -e " [\e[0;35m warn \x1B[0m] Can't update since you made changes to: \e[0;32m\n ${ CHANGED_FILES } \x1B[0m "
2019-07-06 20:35:43 +00:00
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
2016-03-22 14:32:53 +00:00
else
2019-05-30 20:19:53 +00:00
git checkout " ${ LIB_TAG :- master } "
2016-03-22 14:32:53 +00:00
fi
2016-03-19 07:54:56 +00:00
fi
2016-07-27 10:37:23 +00:00
2016-04-16 18:42:53 +00:00
if [ [ $BUILD_ALL = = yes || $BUILD_ALL = = demo ] ] ; then
2019-05-30 20:19:53 +00:00
# shellcheck source=lib/build-all.sh
source " ${ SRC } " /lib/build-all.sh
2015-12-02 19:33:32 +00:00
else
2019-05-30 20:19:53 +00:00
# shellcheck source=lib/main.sh
source " ${ SRC } " /lib/main.sh
2015-12-02 19:33:32 +00:00
fi