diff --git a/compile.sh b/compile.sh index d3f80d0..7a53b15 100755 --- a/compile.sh +++ b/compile.sh @@ -8,6 +8,10 @@ # # This file is a part of tool chain https://github.com/igorpecovnik/lib # +# command line parameter 1 (optional): +# source a script named "config-$1.conf" just before self-update +# of Armbian to override parameters defined below +# #-------------------------------------------------------------------------------------------------------------------------------- # Read build script documentation @@ -15,26 +19,26 @@ # for detailed explanation of these parameters # method -KERNEL_ONLY="" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt -KERNEL_CONFIGURE="no" # want to change my default configuration -CLEAN_LEVEL="make,debs" # comma-separated list of clean targets: "make" = make clean for selected kernel and u-boot, +: ${KERNEL_ONLY:=""} # leave empty to select each time, set to "yes" or "no" to skip dialog prompt +: ${KERNEL_CONFIGURE:="no"} # want to change my default configuration +: ${CLEAN_LEVEL:="make,debs"} # comma-separated list of clean targets: "make" = make clean for selected kernel and u-boot, # "debs" = delete packages in "./output/debs" for current branch and family, # "alldebs" - delete all packages in "./output/debs", "images" = delete "./output/images", # "cache" = delete "./output/cache", "sources" = delete "./sources" # user -DEST_LANG="en_US.UTF-8" # sl_SI.UTF-8, en_US.UTF-8 -CONSOLE_CHAR="UTF-8" +: ${DEST_LANG:="en_US.UTF-8"} # sl_SI.UTF-8, en_US.UTF-8 +: ${CONSOLE_CHAR:="UTF-8"} # advanced -KERNEL_KEEP_CONFIG="no" # overwrite kernel config before compilation -EXTERNAL="yes" # build and install extra applications and drivers -DEBUG_MODE="no" # wait that you make changes to uboot and kernel source and creates patches -FORCE_CHECKOUT="yes" # ignore manual changes to source -BUILD_ALL="no" # cycle through available boards and make images or kernel/u-boot packages. +: ${KERNEL_KEEP_CONFIG:="no"} # overwrite kernel config before compilation +: ${EXTERNAL:="yes"} # build and install extra applications and drivers +: ${DEBUG_MODE:="no"} # wait that you make changes to uboot and kernel source and creates patches +: ${FORCE_CHECKOUT:="yes"} # ignore manual changes to source +: ${BUILD_ALL:="no"} # cycle through available boards and make images or kernel/u-boot packages. # set KERNEL_ONLY to "yes" or "no" to build all kernels/all images # build script version to use -LIB_TAG="" # empty for latest version, +: ${LIB_TAG:=""} # empty for latest version, # one of listed here: https://github.com/igorpecovnik/lib/tags for stable versions, # or commit hash #-------------------------------------------------------------------------------------------------------------------------------- @@ -46,26 +50,38 @@ DEST=$SRC/output # sources for compilation SOURCES=$SRC/sources +# for output coloring +: ${COL_ERROR:="\e[0;31m"} # red +: ${COL_INFO:="\e[0;32m"} # green +: ${COL_MARKED:="\e[0;33m"} # yellow +: ${COL_WARN:="\e[0;35m"} # magenta +: ${COL_OFF:="\x1B[0m"} + #-------------------------------------------------------------------------------------------------------------------------------- -# To preserve proper librarires updating +# To preserve proper libraries updating #-------------------------------------------------------------------------------------------------------------------------------- if [[ -f $SRC/main.sh && -d $SRC/bin ]]; then - echo -e "[\e[0;31m error \x1B[0m] Copy this file one level up, alter and run again." + echo -e "[${COL_ERROR} error ${COL_OFF}] Copy this file one level up, alter and run again." exit fi +#-------------------------------------------------------------------------------------------------------------------------------- +# include user defined variable overrides +#-------------------------------------------------------------------------------------------------------------------------------- + +[[ -n $1 && -f $SRC/config-$1.conf ]] && source $SRC/config-$1.conf #-------------------------------------------------------------------------------------------------------------------------------- # Show warning for those who updated the script #-------------------------------------------------------------------------------------------------------------------------------- if [[ -d $DEST/output ]]; then - echo -e "[\e[0;35m warn \x1B[0m] Structure has been changed. Remove all files and start in a clean directory. \ + echo -e "[${COL_WARN} warn ${COL_OFF}] Structure has been changed. Remove all files and start in a clean directory. \ CTRL-C to exit or any key to continue. Only sources will be doubled ..." read fi if [[ $EUID != 0 ]]; then - echo -e "[\e[0;35m warn \x1B[0m] This script requires root privileges" + echo -e "[${COL_WARN} warn ${COL_OFF}] This script requires root privileges" sudo "$0" "$@" exit 1 fi @@ -81,17 +97,18 @@ if [[ ! -d $SRC/lib ]]; then fi cd $SRC/lib if [[ ! -f $SRC/.ignore_changes ]]; then - echo -e "[\e[0;32m o.k. \x1B[0m] This script will try to update" + echo -e "[${COL_INFO} o.k. ${COL_OFF}] 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 [\e[0;33mlib/\x1B[0m] since you made changes to: \e[0;32m\n${CHANGED_FILES}\x1B[0m" - echo -e "Press \e[0;33m\x1B[0m to abort compilation, \e[0;33m\x1B[0m to ignore and continue" + echo -e "[${COL_WARN} warn ${COL_OFF}] Can't update [${COL_MARKED}lib/${COL_OFF}] since you made changes to: ${COL_INFO}\n${CHANGED_FILES}${COL_OFF}" + echo -e "Press ${COL_MARKED}${COL_OFF} to abort compilation, ${COL_MARKED}${COL_OFF} to ignore and continue" read else git checkout ${LIB_TAG:- master} fi fi + #-------------------------------------------------------------------------------------------------------------------------------- # Do we need to build all images #-------------------------------------------------------------------------------------------------------------------------------- @@ -101,6 +118,9 @@ else source $SRC/lib/main.sh fi +# make current user owner of all files (instead of root) +[[ ! -z $SUDO_USER ]] && chown -R $SUDO_USER:$SUDO_USER $SRC + # If you are committing new version of this file, increment VERSION # Only integers are supported -# VERSION=19 +# VERSION=20