Rework main.sh and configuration.sh to use board configuration files

This commit is contained in:
zador-blood-stained
2016-04-16 18:06:21 +03:00
parent a2b8ac6424
commit 52ff35adb2
3 changed files with 69 additions and 123 deletions

View File

@@ -28,26 +28,22 @@
# common options
REVISION="5.07" # all boards have same revision
ARCH="armhf"
CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-"
TARGETS="zImage"
ROOTPWD="1234" # Must be changed @first login
MAINTAINER="Igor Pecovnik" # deb signature
MAINTAINERMAIL="igor.pecovnik@****l.com" # deb signature
SDSIZE="4000" # SD image size in MB
TZDATA=`cat /etc/timezone` # Timezone for target is taken from host or defined here.
USEALLCORES="yes" # Use all CPU cores for compiling
OFFSET="1" # Bootloader space in MB (1 x 2048 = default)
BOOTSIZE=${BOOTSIZE-0} # Mb size of boot partition
EXIT_PATCHING_ERROR="" # exit patching if failed
SERIALCON="ttyS0"
MISC1="https://github.com/linux-sunxi/sunxi-tools.git" # Allwinner fex compiler / decompiler
MISC1_DIR="sunxi-tools" # local directory
MISC5="https://github.com/hglm/a10disp/" # Display changer for Allwinner
MISC5_DIR="sunxi-display-changer" # local directory
CACHEDIR=$DEST/cache
# board configurations
# board configurations (obsolete, used only for build-all.sh to determine build targets)
# please edit board templates in config/boards to change configuration
if false; then
case $BOARD in
@@ -374,17 +370,8 @@ case $BOARD in
SERIALCON="ttyS0"
CLI_TARGET="%,%"
;;
*)
if [[ -f $SRC/lib/config/boards/$BOARD.board ]]; then
source $SRC/lib/config/boards/$BOARD.board
else
exit_with_error "Board configuration not found" "$BOARD"
fi
;;
esac
fi
# board family configurations
case $LINUXFAMILY in
@@ -608,8 +595,13 @@ case $LINUXFAMILY in
;;
esac
# Let's set defalt data if not defined in board configuration above
[[ -z $OFFSET ]] && OFFSET=1 # Bootloader space in MB (1 x 2048 = default)
[[ -z $ARCH ]] && ARCH=armhf
[[ -z $SERIALCON ]] && SERIALCON=ttyS0
[[ -z $BOOTSIZE ]] && BOOTSIZE=0 # Mb size of boot partition
[[ -z $LINUXCONFIG ]] && LINUXCONFIG="linux-$LINUXFAMILY-$BRANCH"
[[ -z $LINUXKERNEL ]] && eval LINUXKERNEL=\$KERNEL_${BRANCH^^}
[[ -z $LINUXSOURCE ]] && eval LINUXSOURCE=\$KERNEL_${BRANCH^^}"_SOURCE"
@@ -626,7 +618,19 @@ esac
[[ -z $CPUMIN && ($LINUXFAMILY == udoo || $LINUXFAMILY == neo ) ]] && CPUMIN="392000" && CPUMAX="996000" && GOVERNOR="interactive"
[[ -z $GOVERNOR ]] && GOVERNOR="ondemand"
if [[ $ARCH == *64* ]]; then ARCHITECTURE=arm64; else ARCHITECTURE=arm; fi
case $ARCH in
arm64)
TARGETS=Image
CROSS_COMPILE="$CCACHE aarch64-linux-gnu-"
ARCHITECTURE=arm64
;;
armhf)
TARGETS=zImage
CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-"
ARCHITECTURE=arm
;;
esac
# Essential packages
PACKAGE_LIST="automake bash-completion bc bridge-utils build-essential cmake cpufrequtils \

View File

@@ -287,7 +287,7 @@ prepare_host() {
PAK="ca-certificates device-tree-compiler pv bc lzop zip binfmt-support build-essential ccache debootstrap ntpdate pigz \
gawk gcc-arm-linux-gnueabihf gcc-arm-linux-gnueabi qemu-user-static u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev ntpdate \
parted pkg-config libncurses5-dev whiptail debian-keyring debian-archive-keyring f2fs-tools libfile-fcntllock-perl rsync libssl-dev \
nfs-kernel-server btrfs-tools gcc-aarch64-linux-gnu"
nfs-kernel-server btrfs-tools gcc-aarch64-linux-gnu ncurses-term"
# warning: apt-cacher-ng will fail if installed and used both on host and in container/chroot environment with shared network
# set NO_APT_CACHER=yes to prevent installation errors in such case

144
main.sh
View File

@@ -70,118 +70,60 @@ backtitle="Armbian building script, http://www.armbian.com | Author: Igor Pecovn
# Check and fix dependencies, directory structure and settings
prepare_host
# Choose destination - creating board list from file configuration.sh
if [ "$BOARD" == "" ]; then
IFS=";"
MYARRAY=($(cat $SRC/lib/configuration.sh | awk '/\)#enabled/ || /#des/' | sed -e 's/\t\t//' | sed 's/)#enabled//g' \
| sed 's/#description //g' | sed -e 's/\t//' | sed ':a;N;$!ba;s/\n/;/g'))
MYPARAMS=( --title "Choose a board" --backtitle $backtitle --menu "\n Supported:" 36 67 26 )
i=0; j=1
while [[ $i -lt ${#MYARRAY[@]} ]]; do
MYPARAMS+=( "${MYARRAY[$i]}" " ${MYARRAY[$j]}" )
i=$[$i+2]; j=$[$j+2]
done
whiptail "${MYPARAMS[@]}" 2>results
BOARD=$(<results)
rm results
unset MYARRAY
if [[ -z $KERNEL_ONLY ]]; then
options+=("yes" "Kernel, u-boot and other packages")
options+=("no" "Full OS image for writing to SD card")
KERNEL_ONLY=$(dialog --stdout --title "Choose an option" --backtitle "$backtitle" --no-tags --menu "Select what to build" $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $KERNEL_ONLY ]] && exit_with_error "No option selected"
fi
if [ "$BOARD" == "" ]; then echo "ERROR: You have to choose one board"; exit; fi
# This section is left out if we only compile kernel
if [ "$KERNEL_ONLY" != "yes" ]; then
# Choose for which distribution you want to compile
if [ "$RELEASE" == "" ]; then
IFS=";"
declare -a MYARRAY=('wheezy' 'Debian 7 Wheezy | oldstable' 'jessie' 'Debian 8 Jessie | stable' \
'trusty' 'Ubuntu Trusty Tahr 14.04.x LTS | stable' 'xenial' 'Ubuntu Xenial Xerus 16.04.x LTS | testing');
MYPARAMS=( --title "Choose a distribution" --backtitle $backtitle --menu "\n Root file system:" 11 66 4 )
i=0; j=1
while [[ $i -lt ${#MYARRAY[@]} ]]; do
MYPARAMS+=( "${MYARRAY[$i]}" " ${MYARRAY[$j]}" )
i=$[$i+2]; j=$[$j+2]
if [[ -z $BOARD ]]; then
options=()
for board in $SRC/lib/config/boards/*.conf; do
options+=("$(basename $board | cut -d'.' -f1)" "$(head -1 $board | cut -d'#' -f2)")
done
whiptail "${MYPARAMS[@]}" 2>results
RELEASE=$(<results)
rm results
unset MYARRAY
fi
if [ "$RELEASE" == "" ]; then echo "ERROR: You have to choose one distribution"; exit; fi
# Choose to build a desktop
if [ "$BUILD_DESKTOP" == "" ]; then
IFS=";"
declare -a MYARRAY=('No' 'Command line interface' 'Yes' 'XFCE graphical interface');
MYPARAMS=( --title "Install desktop?" --backtitle $backtitle --menu "" 10 60 3 )
i=0; j=1
while [[ $i -lt ${#MYARRAY[@]} ]]; do
MYPARAMS+=( "${MYARRAY[$i]}" " ${MYARRAY[$j]}" )
i=$[$i+2]; j=$[$j+2]
done
whiptail "${MYPARAMS[@]}" 2>results
BUILD_DESKTOP=$(<results)
BUILD_DESKTOP=${BUILD_DESKTOP,,}
rm results
unset MYARRAY
fi
if [ "$BUILD_DESKTOP" == "" ]; then echo "ERROR: You need to choose"; exit; fi
BOARD=$(dialog --stdout --title "Choose a board" --backtitle "$backtitle" --scrollbar --menu "Select one of supported boards" $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $BOARD ]] && exit_with_error "No board selected"
fi
# Choose for which branch you want to compile
if [ "$BRANCH" == "" ]; then
# get info crom configuration which kernel can be build for certain board
line_number=$(grep -n "$BOARD)" $SRC/lib/configuration.sh | grep -Eo '^[^:]+' | head -1)
display_para=$(tail -n +$line_number $SRC/lib/configuration.sh | grep -in "#build" | head -1 | awk '{print $NF}')
source $SRC/lib/config/boards/$BOARD.conf
if [[ "$display_para" == *wip ]]; then
display_para=${display_para//[!0-9]/}
whiptail --title "Warning Warning Warning" --msgbox "This is a work in progress. \
Building might not succeed. \n\nYou must hit OK to continue." 9 63
fi
[[ -z $KERNEL_TARGET ]] && exit_with_error "Board configuration does not define valid kernel config"
IFS=";"
# define all possible combinations
if [[ $display_para == "1" ]]; then
declare -a MYARRAY=('default' '3.4.x - 3.14.x legacy');
if [[ -z $BRANCH ]]; then
options=()
[[ $KERNEL_TARGET == *default* ]] && options+=("default" "3.4.x - 3.14.x legacy")
[[ $KERNEL_TARGET == *next* ]] && options+=("next" "Latest stable @kernel.org")
[[ $KERNEL_TARGET == *dev* ]] && options+=("dev" "Latest dev @kernel.org")
# do not display selection dialog if only one kernel branch is available
if [[ "${#options[@]}" == 2 ]]; then
BRANCH="${#options[0]}"
else
BRANCH=$(dialog --stdout --title "Choose a kernel" --backtitle "$backtitle" --menu "Select one of supported kernels" $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
fi
if [[ $display_para == "2" ]]; then
declare -a MYARRAY=('next' 'Latest stable @kernel.org');
fi
if [[ $display_para == "3" ]]; then
declare -a MYARRAY=('default' '3.4.x - 3.14.x legacy' 'next' 'Latest stable @kernel.org');
fi
if [[ $display_para == "4" ]]; then
declare -a MYARRAY=('dev' 'Latest dev @kernel.org');
fi
if [[ $display_para == "5" ]]; then
declare -a MYARRAY=('next' 'Latest stable @kernel.org' 'dev' 'Latest dev @kernel.org');
fi
if [[ $display_para == "6" || $display_para == "0" ]]; then
declare -a MYARRAY=('default' '3.4.x - 3.14.x legacy' 'next' 'Latest stable @kernel.org' 'dev' 'Latest dev @kernel.org');
fi
MYPARAMS=( --title "Choose a branch" --backtitle "$backtitle" --menu "\n Kernel:" 10 60 3 )
i=0; j=1
while [[ $i -lt ${#MYARRAY[@]} ]]; do
MYPARAMS+=( "${MYARRAY[$i]}" " ${MYARRAY[$j]}" )
i=$[$i+2]; j=$[$j+2]
done
whiptail "${MYPARAMS[@]}" 2>results
BRANCH=$(<results)
rm results
unset MYARRAY
unset options
[[ -z $BRANCH ]] && exit_with_error "No kernel branch selected"
fi
if [ "$BRANCH" == "" ]; then echo "ERROR: You have to choose one branch"; exit; fi
if [[ $KERNEL_ONLY != yes && -z $RELEASE ]]; then
options=()
options+=("wheezy" "Debian 7 Wheezy (oldstable)")
options+=("jessie" "Debian 8 Jessie (stable)")
options+=("trusty" "Ubuntu Trusty 14.04.x LTS")
options+=("xenial" "Ubuntu Xenial 16.04.x LTS")
RELEASE=$(dialog --stdout --title "Choose a release" --backtitle "$backtitle" --menu "Select one of supported releases" $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $RELEASE ]] && exit_with_error "No release selected"
# back to normal
unset IFS
options=()
options+=("no" "Image with console interface")
options+=("yes" "Image with desktop environment")
BUILD_DESKTOP=$(dialog --stdout --title "Choose image type" --backtitle "$backtitle" --no-tags --menu "Select image type" $TTY_Y $TTY_X $(($TTY_Y - 8)) "${options[@]}")
unset options
[[ -z $BUILD_DESKTOP ]] && exit_with_error "No option selected"
fi
# naming to distro
if [[ $RELEASE == trusty || $RELEASE == xenial ]]; then DISTRIBUTION="Ubuntu"; else DISTRIBUTION="Debian"; fi