Added function to abort build with verbose error message

This commit is contained in:
zador-blood-stained 2016-03-05 21:26:01 +03:00
parent 88ed428ab2
commit 6f2ab07175
5 changed files with 74 additions and 81 deletions

View File

@ -20,8 +20,9 @@ compile_uboot (){
#---------------------------------------------------------------------------------------------------------------------------------
# Compile uboot from sources
#---------------------------------------------------------------------------------------------------------------------------------
if [ -d "$SOURCES/$BOOTSOURCEDIR" ]; then
if [[ ! -d "$SOURCES/$BOOTSOURCEDIR" ]]; then
exit_with_error "Error building u-boot: source directory does not exist" "$BOOTSOURCEDIR"
fi
local branch="${BRANCH//default/}"
[[ -n "$branch" ]] && branch="-"$branch
@ -141,14 +142,10 @@ END
FILESIZE=$(wc -c $DEST/debs/$CHOOSEN_UBOOT | cut -f 1 -d ' ')
if [[ $FILESIZE -lt 50000 ]]; then
display_alert "Building failed, check configuration." "$CHOOSEN_UBOOT deleted" "err"
rm $DEST/debs/$CHOOSEN_UBOOT
exit
exit_with_error "Building u-boot failed, check configuration." "$CHOOSEN_UBOOT deleted" "err"
fi
else
display_alert "Source file $1 does not exists. Check fetch_from_github configuration." "" "err"
fi
}
compile_sunxi_tools (){
@ -176,7 +173,9 @@ compile_kernel (){
# Compile kernel
#---------------------------------------------------------------------------------------------------------------------------------
if [ -d "$SOURCES/$LINUXSOURCEDIR" ]; then
if [[ ! -d "$SOURCES/$LINUXSOURCEDIR" ]]; then
exit_with_error "Error building kernel: source directory does not exist" "$LINUXSOURCEDIR"
fi
local branch="${BRANCH//default/}"
[[ -n "$branch" ]] && branch="-"$branch
@ -223,51 +222,43 @@ if [ -d "$SOURCES/$LINUXSOURCEDIR" ]; then
make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
fi
eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" zImage modules 2>&1' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling kernel..." 20 80'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" zImage modules 2>&1' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling kernel..." 20 80'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
if [ ${PIPESTATUS[0]} -ne 0 ] || [ ! -f arch/arm/boot/zImage ]; then
display_alert "Kernel was not built" "@host" "err"
exit 1
fi
eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" dtbs 2>&1' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling Device Tree..." 20 80'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
if [ ${PIPESTATUS[0]} -ne 0 ] || [ ! -f arch/arm/boot/zImage ]; then
exit_with_error "Kernel was not built" "@host"
fi
eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" dtbs 2>&1' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling Device Tree..." 20 80'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
if [ ${PIPESTATUS[0]} -ne 0 ]; then
display_alert "DTBs was not build" "@host" "err"
exit 1
fi
if [ ${PIPESTATUS[0]} -ne 0 ]; then
exit_with_error "DTBs were not build" "@host"
fi
# different packaging for 4.3+ // probably temporaly soution
KERNEL_PACKING="deb-pkg"
IFS='.' read -a array <<< "$VER"
if (( "${array[0]}" == "4" )) && (( "${array[1]}" >= "3" )); then
KERNEL_PACKING="bindeb-pkg"
fi
# different packaging for 4.3+ // probably temporaly soution
KERNEL_PACKING="deb-pkg"
IFS='.' read -a array <<< "$VER"
if (( "${array[0]}" == "4" )) && (( "${array[1]}" >= "3" )); then
KERNEL_PACKING="bindeb-pkg"
fi
# make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
# produce deb packages: image, headers, firmware, libc
eval 'make -j1 $KERNEL_PACKING KDEB_PKGVERSION=$REVISION LOCALVERSION="-"$LINUXFAMILY KBUILD_DEBARCH=armhf ARCH=arm DEBFULLNAME="$MAINTAINER" \
DEBEMAIL="$MAINTAINERMAIL" CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" 2>&1 ' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Creating kernel packages..." 20 80'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
# make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
# produce deb packages: image, headers, firmware, libc
eval 'make -j1 $KERNEL_PACKING KDEB_PKGVERSION=$REVISION LOCALVERSION="-"$LINUXFAMILY KBUILD_DEBARCH=armhf ARCH=arm DEBFULLNAME="$MAINTAINER" \
DEBEMAIL="$MAINTAINERMAIL" CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" 2>&1 ' \
${PROGRESS_LOG_TO_FILE:+' | tee -a $DEST/debug/compilation.log'} \
${OUTPUT_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Creating kernel packages..." 20 80'} \
${OUTPUT_VERYSILENT:+' >/dev/null 2>/dev/null'}
# we need a name
CHOOSEN_KERNEL=linux-image"$branch"-"$CONFIG_LOCALVERSION$LINUXFAMILY"_"$REVISION"_armhf.deb
cd ..
mv *.deb $DEST/debs/ || exit
else
display_alert "Source file $1 does not exists. Check fetch_from_github configuration." "" "err"
exit
fi
sync
# we need a name
CHOOSEN_KERNEL=linux-image"$branch"-"$CONFIG_LOCALVERSION$LINUXFAMILY"_"$REVISION"_armhf.deb
cd ..
mv *.deb $DEST/debs/ || exit_with_error "Failed moving kernel DEBs"
}
@ -431,8 +422,7 @@ write_uboot()
( dd if=/tmp/usr/lib/"$CHOOSEN_UBOOT"/u-boot-sunxi-with-spl.bin of=$LOOP bs=1024 seek=8 status=noxfer >/dev/null 2>&1)
fi
if [ $? -ne 0 ]; then
display_alert "U-boot failed to install" "@host" "err"
exit 1
exit_with_error "U-boot failed to install" "@host" "err"
fi
rm -r /tmp/usr
sync

View File

@ -322,8 +322,7 @@ case $BOARD in
SERIALCON="ttyS0"
;;
*) echo "Board configuration not found"
exit
*) exit_with_error "Board configuration not found" "$BOARD"
;;
esac
@ -500,8 +499,7 @@ case $LINUXFAMILY in
UBOOT_DEV_SOURCE=$UBOOT_DEFAULT_SOURCE
;;
*) echo "Defaults not found"
exit
*) exit_with_error "Defaults not found" "$LINUXFAMILY"
;;
esac
@ -530,7 +528,7 @@ PACKAGE_LIST="alsa-utils automake bash-completion bc bridge-utils build-essentia
iw less libtool libwrap0-dev libfuse2 libssl-dev lirc lsof makedev fake-hwclock wpasupplicant \
module-init-tools nano ntp parted pkg-config pv rfkill rsync sudo curl dialog \
sysfsutils toilet u-boot-tools unattended-upgrades unzip usbutils vlan wireless-tools wget \
iptables libdigest-sha-perl libproc-processtable-perl w-scan libusb-dev \
iptables libdigest-sha-perl libproc-processtable-perl w-scan libusb-dev ncurses-term \
console-setup console-data kbd console-common unicode-data openssh-server man-db"
# Non-essential packages

View File

@ -30,20 +30,18 @@ debootstrap_ng()
fi
if [[ "ext4 f2fs btrfs nfs fel" != *"$ROOTFS_TYPE"* ]]; then
display_alert "Unknown rootfs type" "$ROOTFS_TYPE" "err"
exit -1
exit_with_error "Unknown rootfs type" "$ROOTFS_TYPE"
fi
# Fixed image size is in 1M dd blocks (MiB)
# to get size of block device /dev/sdX execute as root:
# echo $(( $(blockdev --getsize64 /dev/sdX) / 1024 / 1024 ))
if [[ "btrfs f2fs" == *"$ROOTFS_TYPE"* && -z $FIXED_IMAGE_SIZE ]]; then
display_alert "$ROOTFS_TYPE root needs user-defined SD card size" "FIXED_IMAGE_SIZE" "err"
exit 1
exit_with_error "$ROOTFS_TYPE root needs user-defined SD card size" "FIXED_IMAGE_SIZE"
fi
if [[ $ROOTFS_TYPE != ext4 ]]; then
display_alert "Please make sure selected kernel version supports $ROOTFS_TYPE" "$CHOOSEN_KERNEL" "wrn"
display_alert "Assuming $CHOOSEN_KERNEL supports $ROOTFS_TYPE" "" "wrn"
fi
# small SD card with kernel, boot scritpt and .dtb/.bin files
@ -342,8 +340,7 @@ prepare_partitions()
local sdsize=$FIXED_IMAGE_SIZE
# basic sanity check
if [[ $ROOTFS_TYPE != nfs && $sdsize -lt $rootfs_size ]]; then
display_alert "User defined image size is too small" "$sdsize <= $rootfs_size" "err"
exit 1
exit_with_error "User defined image size is too small" "$sdsize <= $rootfs_size" "err"
fi
else
local imagesize=$(( $rootfs_size + $OFFSET + $BOOTSIZE )) # MiB
@ -387,8 +384,7 @@ prepare_partitions()
LOOP=$(losetup -f)
if [[ -z $LOOP ]]; then
# NOTE: very unlikely with this debootstrap process
display_alert "Unable to find free loop device" "err"
exit 1
exit_with_error "Unable to find free loop device"
fi
# NOTE: losetup -P option is not available in Trusty
@ -530,6 +526,6 @@ unmount_on_exit()
losetup -d $LOOP >/dev/null 2>&1
exit 1
exit_with_error "debootstrap-ng was interrupted"
} #############################################################################
} #############################################################################

View File

@ -11,10 +11,10 @@
# Functions:
# cleaning
# exit_with_error
# get_package_list_hash
# fetch_from_github
# display_alert
# check_error
# grab_version
# fingerprint_image
# umount_image
@ -60,6 +60,26 @@ cleaning()
esac
}
# exit_with_error <message> <highlight>
#
# a way to terminate build process
# with verbose error message
#
exit_with_error()
{
local _file=$(basename ${BASH_SOURCE[1]})
local _line=${BASH_LINENO[0]}
local _function=${FUNCNAME[1]}
local _description=$1
local _highlight=$2
display_alert "ERROR in function $_function" "$_file:$_line" "err"
display_alert "$_description" "$_highlight" "err"
display_alert "Process terminated" "" "info"
exit -1
}
# get_package_list_hash <package_list>
#
# outputs md5hash for space-separated <package_list>
@ -128,16 +148,6 @@ else
fi
}
check_error ()
# check last command and display warning only
{
if [ $? -ne 0 ]; then
# display warning if patching fails
display_alert "... failed. More info: debug/install.log" "$1" "wrn";
fi
}
#---------------------------------------------------------------------------------------------------------------------------------
# grab_version <PATH>
#
@ -257,10 +267,9 @@ prepare_host() {
display_alert "Preparing" "host" "info"
if [[ $(dpkg --print-architecture) == armhf ]]; then
display_alert "Running this tool on board itself is not supported" "..." "err"
display_alert "Please read documentation to set up proper compilation environment" "..." "err"
display_alert "http://www.armbian.com/using-armbian-tools/" "..." "err"
exit 1
display_alert "Please read documentation to set up proper compilation environment" "..." "info"
display_alert "http://www.armbian.com/using-armbian-tools/" "..." "info"
exit_with_error "Running this tool on board itself is not supported"
fi
# dialog may be used to display progress

View File

@ -92,7 +92,7 @@ process_patch_file() {
if [ $? -ne 0 ]; then
display_alert "... $(basename $patch)" "failed" "wrn";
if [[ $EXIT_PATCHING_ERROR == "yes" ]]; then exit; fi
if [[ $EXIT_PATCHING_ERROR == "yes" ]]; then exit_with_error "Aborting due to" "EXIT_PATCHING_ERROR"; fi
else
display_alert "... $(basename $patch)" "succeeded" "info"
fi