forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.sh
executable file
·78 lines (67 loc) · 2.35 KB
/
compile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/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}")")"
# 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
if [[ -f $SRC/lib/general.sh && -L $SRC/main.sh ]]; then
source $SRC/lib/general.sh
else
echo "Error: missing build directory structure"
echo "Please clone the full repository https://github.com/armbian/build/"
exit -1
fi
# copy default config from the template
[[ ! -f $SRC/config-default.conf ]] && cp $SRC/config/templates/config-example.conf $SRC/config-default.conf
# source build configuration file
if [[ -n $1 && -f $SRC/config-$1.conf ]]; then
display_alert "Using config file" "config-$1.conf" "info"
source $SRC/config-$1.conf
else
display_alert "Using config file" "config-default.conf" "info"
source $SRC/config-default.conf
fi
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"
echo -e "Press \e[0;33m<Ctrl-C>\x1B[0m to abort compilation, \e[0;33m<Enter>\x1B[0m to ignore and continue"
read
else
git checkout ${LIB_TAG:- master}
fi
fi
if [[ $BUILD_ALL == yes || $BUILD_ALL == demo ]]; then
source $SRC/lib/build-all.sh
else
source $SRC/lib/main.sh
fi