build/build-all.sh

226 lines
7.4 KiB
Bash
Raw Normal View History

#!/bin/bash
#
2017-01-02 18:08:03 +01:00
# Copyright (c) Authors: http://www.armbian.com/authors
#
# 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.
#
2016-04-17 00:01:27 +03:00
# This file is a part of tool chain https://github.com/igorpecovnik/lib
#
# Include here to make "display_alert" and "prepare_host" available
source $SRC/lib/general.sh
2016-12-13 18:04:03 +01: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"
eval $parameter=$value
fi
done
FORCEDRELEASE=$RELEASE
# when we want to build from certain start
2017-02-06 09:49:40 +01:00
#from=147
#stop=148
rm -rf /run/armbian
mkdir -p /run/armbian
RELEASE_LIST=("xenial" "jessie")
BRANCH_LIST=("default" "next" "dev")
pack_upload ()
{
2017-01-02 18:08:03 +01:00
# pack into .7z and upload to server
# stage: init
display_alert "Signing and compressing" "Please wait!" "info"
2017-01-18 22:14:35 +01:00
local version="Armbian_${REVISION}_${BOARD^}_${DISTRIBUTION}_${RELEASE}_${BRANCH}_${VER/-$LINUXFAMILY/}"
2017-01-02 18:08:03 +01:00
local subdir="archive"
[[ $BUILD_DESKTOP == yes ]] && version=${version}_desktop
[[ $BETA == yes ]] && local subdir=nightly
local filename=$CACHEDIR/$DESTIMG/${version}.7z
2017-01-02 18:08:03 +01:00
# stage: generate sha256sum.sha
cd $CACHEDIR/$DESTIMG
sha256sum -b ${version}.img > sha256sum.sha
2017-01-02 18:08:03 +01:00
# stage: sign with PGP
if [[ -n $GPG_PASS ]]; then
echo $GPG_PASS | gpg --passphrase-fd 0 --armor --detach-sign --batch --yes ${version}.img
echo $GPG_PASS | gpg --passphrase-fd 0 --armor --detach-sign --batch --yes armbian.txt
fi
2017-01-02 18:08:03 +01:00
# create remote directory structure
ssh ${SEND_TO_SERVER} "mkdir -p /var/www/dl.armbian.com/${BOARD}/{archive,nightly};";
2017-01-02 18:08:03 +01:00
# pack and move file to server under new process
nice -n 19 bash -c "\
7za a -t7z -bd -m0=lzma2 -mx=3 -mfb=64 -md=32m -ms=on $filename ${version}.img armbian.txt *.asc sha256sum.sha >/dev/null 2>&1 ; \
2017-01-02 18:08:03 +01:00
find . -type f -not -name '*.7z' -print0 | xargs -0 rm -- ; \
while ! rsync -arP $CACHEDIR/$DESTIMG/. -e 'ssh -p 22' ${SEND_TO_SERVER}:/var/www/dl.armbian.com/${BOARD}/${subdir};do sleep 5;done; \
rm -r $CACHEDIR/$DESTIMG" &
}
build_main ()
{
2016-12-30 17:56:37 +01:00
touch "/run/armbian/Armbian_${BOARD^}_${BRANCH}_${RELEASE}_${BUILD_DESKTOP}.pid";
source $SRC/lib/main.sh;
[[ $KERNEL_ONLY != yes ]] && pack_upload
rm "/run/armbian/Armbian_${BOARD^}_${BRANCH}_${RELEASE}_${BUILD_DESKTOP}.pid"
}
create_images_list()
{
#
# if parameter is true, than we build beta list
#
for board in $SRC/lib/config/boards/*.conf; do
BOARD=$(basename $board | cut -d'.' -f1)
source $SRC/lib/config/boards/$BOARD.conf
if [[ -n $CLI_TARGET && -z $1 ]]; then
2016-04-20 19:12:46 +03:00
# RELEASES : BRANCHES
CLI_TARGET=($(tr ':' ' ' <<< "$CLI_TARGET"))
2016-04-20 19:12:46 +03:00
build_settings_target=($(tr ',' ' ' <<< "${CLI_TARGET[0]}"))
build_settings_branch=($(tr ',' ' ' <<< "${CLI_TARGET[1]}"))
2016-04-20 19:12:46 +03:00
[[ ${build_settings_target[0]} == "%" ]] && build_settings_target[0]="${RELEASE_LIST[@]}"
[[ ${build_settings_branch[0]} == "%" ]] && build_settings_branch[0]="${BRANCH_LIST[@]}"
2016-04-20 19:12:46 +03:00
for release in ${build_settings_target[@]}; do
for kernel in ${build_settings_branch[@]}; do
buildlist+=("$BOARD $kernel $release no")
done
done
fi
if [[ -n $DESKTOP_TARGET && -z $1 ]]; then
2016-04-20 19:12:46 +03:00
# RELEASES : BRANCHES
DESKTOP_TARGET=($(tr ':' ' ' <<< "$DESKTOP_TARGET"))
2016-04-20 19:12:46 +03:00
build_settings_target=($(tr ',' ' ' <<< "${DESKTOP_TARGET[0]}"))
build_settings_branch=($(tr ',' ' ' <<< "${DESKTOP_TARGET[1]}"))
2016-04-20 19:12:46 +03:00
[[ ${build_settings_target[0]} == "%" ]] && build_settings_target[0]="${RELEASE_LIST[@]}"
[[ ${build_settings_branch[0]} == "%" ]] && build_settings_branch[0]="${BRANCH_LIST[@]}"
2016-04-20 19:12:46 +03:00
for release in ${build_settings_target[@]}; do
for kernel in ${build_settings_branch[@]}; do
buildlist+=("$BOARD $kernel $release yes")
done
done
fi
if [[ -n $CLI_BETA_TARGET && -n $1 ]]; then
# RELEASES : BRANCHES
CLI_BETA_TARGET=($(tr ':' ' ' <<< "$CLI_BETA_TARGET"))
build_settings_target=($(tr ',' ' ' <<< "${CLI_BETA_TARGET[0]}"))
build_settings_branch=($(tr ',' ' ' <<< "${CLI_BETA_TARGET[1]}"))
[[ ${build_settings_target[0]} == "%" ]] && build_settings_target[0]="${RELEASE_LIST[@]}"
[[ ${build_settings_branch[0]} == "%" ]] && build_settings_branch[0]="${BRANCH_LIST[@]}"
for release in ${build_settings_target[@]}; do
for kernel in ${build_settings_branch[@]}; do
buildlist+=("$BOARD $kernel $release no")
done
done
fi
if [[ -n $DESKTOP_BETA_TARGET && -n $1 ]]; then
# RELEASES : BRANCHES
DESKTOP_BETA_TARGET=($(tr ':' ' ' <<< "$DESKTOP_BETA_TARGET"))
build_settings_target=($(tr ',' ' ' <<< "${DESKTOP_BETA_TARGET[0]}"))
build_settings_branch=($(tr ',' ' ' <<< "${DESKTOP_BETA_TARGET[1]}"))
[[ ${build_settings_target[0]} == "%" ]] && build_settings_target[0]="${RELEASE_LIST[@]}"
[[ ${build_settings_branch[0]} == "%" ]] && build_settings_branch[0]="${BRANCH_LIST[@]}"
for release in ${build_settings_target[@]}; do
for kernel in ${build_settings_branch[@]}; do
buildlist+=("$BOARD $kernel $release yes")
done
done
2016-12-30 17:56:37 +01:00
fi
2017-01-02 18:09:56 +01:00
unset CLI_TARGET CLI_BRANCH DESKTOP_TARGET DESKTOP_BRANCH KERNEL_TARGET CLI_BETA_TARGET DESKTOP_BETA_TARGET
done
}
2016-02-20 16:39:04 +01:00
create_kernels_list()
{
for board in $SRC/lib/config/boards/*.conf; do
BOARD=$(basename $board | cut -d'.' -f1)
source $SRC/lib/config/boards/$BOARD.conf
if [[ -n $KERNEL_TARGET ]]; then
for kernel in $(tr ',' ' ' <<< $KERNEL_TARGET); do
buildlist+=("$BOARD $kernel")
done
fi
unset KERNEL_TARGET
done
}
buildlist=()
if [[ $KERNEL_ONLY == yes ]]; then
create_kernels_list
printf "%-3s %-20s %-10s %-10s %-10s\n" \# BOARD BRANCH
else
create_images_list $BETA
printf "%-3s %-20s %-10s %-10s %-10s\n" \# BOARD BRANCH RELEASE DESKTOP
fi
n=0
for line in "${buildlist[@]}"; do
n=$[$n+1]
printf "%-3s %-20s %-10s %-10s %-10s\n" $n $line
done
echo -e "\n${#buildlist[@]} total\n"
[[ $BUILD_ALL == demo ]] && exit 0
buildall_start=`date +%s`
n=0
for line in "${buildlist[@]}"; do
2017-04-29 13:32:09 +03:00
unset LINUXFAMILY LINUXCONFIG KERNELDIR KERNELSOURCE KERNELBRANCH BOOTDIR BOOTSOURCE BOOTBRANCH ARCH UBOOT_USE_GCC KERNEL_USE_GCC \
2017-04-23 16:56:19 +03:00
CPUMIN CPUMAX UBOOT_VER KERNEL_VER GOVERNOR BOOTSIZE BOOTFS_TYPE UBOOT_TOOLCHAIN KERNEL_TOOLCHAIN PACKAGE_LIST_EXCLUDE KERNEL_IMAGE_TYPE \
write_uboot_platform family_tweaks setup_write_uboot_platform BOOTSCRIPT UBOOT_TARGET_MAP LOCALVERSION UBOOT_COMPILER KERNEL_COMPILER \
MODULES MODULES_NEXT MODULES_DEV INITRD_ARCH HAS_UUID_SUPPORT BOOTENV_FILE BOOTDELAY MODULES_BLACKLIST MODULES_BLACKLIST_NEXT \
MODULES_BLACKLIST_DEV MOUNT SDCARD BOOTPATCHDIR KERNELPATCHDIR buildtext RELEASE IMAGE_TYPE OVERLAY_PREFIX
2016-05-03 23:28:56 +03:00
read BOARD BRANCH RELEASE BUILD_DESKTOP <<< $line
n=$[$n+1]
2016-12-13 18:04:03 +01:00
[[ -z $RELEASE ]] && RELEASE=$FORCEDRELEASE;
if [[ $from -le $n ]]; then
2017-01-19 19:53:15 +01:00
[[ -z $BUILD_DESKTOP ]] && BUILD_DESKTOP="no"
jobs=$(ls /run/armbian | wc -l)
if [[ $jobs -lt $MULTITHREAD ]]; then
display_alert "Building in the back $n / ${#buildlist[@]}" "Board: $BOARD Kernel:$BRANCH${RELEASE:+ Release: $RELEASE}${BUILD_DESKTOP:+ Desktop: $BUILD_DESKTOP}" "ext"
(build_main) &
[[ $KERNEL_ONLY != yes ]] && sleep $(( ( RANDOM % 10 ) + 1 ))
else
display_alert "Building $buildtext $n / ${#buildlist[@]}" "Board: $BOARD Kernel:$BRANCH${RELEASE:+ Release: $RELEASE}${BUILD_DESKTOP:+ Desktop: $BUILD_DESKTOP}" "ext"
build_main
fi
fi
2017-02-06 09:49:40 +01:00
if [[ -n $stop && $n -ge $stop ]]; then exit; fi
done
buildall_end=`date +%s`
buildall_runtime=$(((buildall_end - buildall_start) / 60))
display_alert "Runtime" "$buildall_runtime min" "info"