From 2d802bc7746f522c19369b36add50a92f968ef94 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Mon, 7 Dec 2015 17:11:41 +0300 Subject: [PATCH 01/10] Better handling of KERNEL_KEEP_CONFIG option --- common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.sh b/common.sh index 681df05e6f..fb9fd1535e 100644 --- a/common.sh +++ b/common.sh @@ -148,7 +148,7 @@ if [ "$KERNEL_CLEAN" = "yes" ]; then make ARCH=arm CROSS_COMPILE=arm-linux-gnuea if [[ -n "$FIRMWARE" ]]; then unzip -o $SRC/lib/$FIRMWARE -d $SOURCES/$LINUXSOURCE/firmware; fi # use proven config -if [ "$KERNEL_KEEP_CONFIG" != "yes" ]; then cp $SRC/lib/config/$LINUXCONFIG.config $SOURCES/$LINUXSOURCE/.config; fi +if [ "$KERNEL_KEEP_CONFIG" != "yes" ] || [ ! -f $SOURCES/$LINUXSOURCE/.config ]; then cp $SRC/lib/config/$LINUXCONFIG.config $SOURCES/$LINUXSOURCE/.config; fi # hacks for banana if [[ $BOARD == banana* || $BOARD == orangepi* || $BOARD == lamobo* ]] ; then From 4594184be78c49d1b025ece66d9ebde841b5d4b1 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Mon, 7 Dec 2015 17:15:19 +0300 Subject: [PATCH 02/10] Change make oldconfig and make menuconfig handling --- common.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common.sh b/common.sh index fb9fd1535e..d483702204 100644 --- a/common.sh +++ b/common.sh @@ -158,12 +158,16 @@ fi # hack for deb builder. To pack what's missing in headers pack. cp $SRC/lib/patch/misc/headers-debian-byteshift.patch /tmp -if [ "$KERNEL_CONFIGURE" = "yes" ]; then make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig; fi - export LOCALVERSION="-"$LINUXFAMILY # this way of compilation is much faster. We can use multi threading here but not later -make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig +if [ "$KERNEL_CONFIGURE" != "yes" ]; then + make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- olddefconfig +else + make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig +fi + +if [ "$KERNEL_CONFIGURE" = "yes" ]; then make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig; fi make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" zImage modules 2>&1 | dialog --backtitle "$backtitle" --progressbox "Compiling kernel $CCACHE ..." 20 80 From a5a9fd83989fd5c4eeda30e22927528c79451de9 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Mon, 7 Dec 2015 19:31:22 +0300 Subject: [PATCH 03/10] Advanced patching enhancement --- patching.sh | 123 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 49 deletions(-) diff --git a/patching.sh b/patching.sh index 62ae6bf093..0dc57bf8dd 100644 --- a/patching.sh +++ b/patching.sh @@ -13,48 +13,82 @@ # # - +# advanced_patch +# +# parameters: +# : u-boot, kernel +# : u-boot: u-boot, u-boot-neo; kernel: sun4i-default, sunxi-next, ... +# : cubieboard, cubieboard2, cubietruck, ... +# : additional description text +# +# priority: +# $SRC/userpatches/// +# $SRC/userpatches// +# $SRC/lib/patch/// +# $SRC/lib/patch// +# advanced_patch () { -#--------------------------------------------------------------------------------------------------------------------------------- -# Patching from certain subdirectory -#--------------------------------------------------------------------------------------------------------------------------------- - # count files - shopt -s nullglob dotglob # To include hidden files - local files=($1/*.patch) - if [ ${#files[@]} -gt 0 ]; then - display_alert "Patching $2" "$3" "info"; - fi - - # go through all patch files - for patch in $1*.patch; do - - # check if directory exits - if [[ ! -d $1 ]]; then - display_alert "... directory not exists" "$1" "wrn"; - break; - fi - - # check if files exits - test -f "$patch" || continue - - # detect and remove files which patch will create - LANGUAGE=english patch --batch --dry-run -p1 -N < $patch | grep create \ - | awk '{print $NF}' | sed -n 's/,//p' | xargs -I % sh -c 'rm %' - - # main patch command - echo "$patch" >> $DEST/debug/install.log - patch --batch --silent -p1 -N < $patch >> $DEST/debug/install.log 2>&1 - - if [ $? -ne 0 ]; then - # display warning if patching fails - display_alert "... "${patch#*$1} "failed" "wrn"; - else - # display patching information - display_alert "... "${patch#*$1} "succeeded" "info" - fi + local dest=$1 + local family=$2 + local device=$3 + local description=$4 + + local names=() + local dirs=("$SRC/userpatches/$dest/$family/$device" "$SRC/userpatches/$dest/$family" "$SRC/lib/patch/$dest/$family/$device" "$SRC/lib/patch/$dest/$family") + + # required for "for" command + shopt -s nullglob dotglob + + # get patch file names + for dir in "${dirs[@]}"; do + for patch in $dir/*.patch; do + names+=($(basename $patch)) + done done + # remove duplicates + names=$(echo "${names[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') + + # apply patches + for name in "${names[@]}"; do + for dir in "${dirs[@]}"; do + if [ -f "$dir/$name" ] || [ -L "$dir/$name" ]; then + if [ -s "$dir/$name" ]; then + process_patch_file "$dir/$name" "$description" + else + display_alert "... ${description} ${name}" "skipped" "info" + fi + break # next name + fi + done + done +} + +# process_patch_file +# +# parameters: +# : path to patch file +# : additional description text +# +process_patch_file() { + + local patch=$1 + local description=$2 + + # detect and remove files which patch will create + LANGUAGE=english patch --batch --dry-run -p1 -N < $patch | grep create \ + | awk '{print $NF}' | sed -n 's/,//p' | xargs -I % sh -c 'rm %' + + # main patch command + echo "$patch" >> $DEST/debug/install.log + patch --batch --silent -p1 -N < $patch >> $DEST/debug/install.log 2>&1 + + if [ $? -ne 0 ]; then + display_alert "... $(basename $patch) $description" "failed" "wrn"; + else + display_alert "... $(basename $patch) $description" "succeeded" "info" + fi } @@ -89,11 +123,7 @@ patching_sources(){ LINUXFAMILY="banana"; fi - # system patches - advanced_patch "$SRC/lib/patch/kernel/$LINUXFAMILY-$BRANCH/" "kernel" "$LINUXFAMILY-$BRANCH $VER" - - # user patches - advanced_patch "$SRC/userpatches/kernel/" "kernel with user patches" "$LINUXFAMILY-$BRANCH $VER" + advanced_patch "kernel" "$LINUXFAMILY-$BRANCH" "$BOARD" "$LINUXFAMILY-$BRANCH $VER" # it can be changed in this process grab_kernel_version @@ -112,12 +142,7 @@ patching_sources(){ git checkout $FORCE -q $UBOOTTAG; fi - # system patches - advanced_patch "$SRC/lib/patch/u-boot/$BOOTSOURCE/" "u-boot" "$UBOOTTAG" - - # user patches - advanced_patch "$SRC/userpatches/u-boot/" "u-boot with user patches" "$UBOOTTAG" - + advanced_patch "u-boot" "$BOOTSOURCE" "$BOARD" "$UBOOTTAG" #--------------------------------------------------------------------------------------------------------------------------------- # Patching others: FBTFT drivers, ... From 051e3f0b2befc8232bf02e2bf903be9a754f438b Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Tue, 8 Dec 2015 14:13:44 +0300 Subject: [PATCH 04/10] Fixed patch that prevented DTBs compilation --- patch/kernel/sunxi-next/0013-lamobo_r1_dts.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patch/kernel/sunxi-next/0013-lamobo_r1_dts.patch b/patch/kernel/sunxi-next/0013-lamobo_r1_dts.patch index ec14eef6ff..3d7dc6e432 100644 --- a/patch/kernel/sunxi-next/0013-lamobo_r1_dts.patch +++ b/patch/kernel/sunxi-next/0013-lamobo_r1_dts.patch @@ -7,10 +7,10 @@ index 246473a..becd814 100644 dtb-$(CONFIG_MACH_SUN7I) += \ sun7i-a20-bananapi.dtb \ sun7i-a20-bananapi-r1.dtb \ -+ sun7i-a20-lamobo-r1.dtb \ ++ sun7i-a20-lamobo-r1.dtb \ sun7i-a20-bananapro.dtb \ sun7i-a20-cubieboard2.dtb \ - sun7i-a20-cubietruck.dtb \ + sun7i-a20-cubietruck.dtb \ diff --git a/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts b/arch/arm/boot/dts/sun7i-a20-lamobo-r1.dts new file mode 100644 index 0000000..69b11dc From dfa5564f480949549a28f5c7b70e6c0b5b54732a Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Tue, 8 Dec 2015 17:09:13 +0300 Subject: [PATCH 05/10] Olddefconfig is not supported by legacy kernel --- common.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common.sh b/common.sh index d483702204..0364a253a1 100644 --- a/common.sh +++ b/common.sh @@ -162,7 +162,11 @@ export LOCALVERSION="-"$LINUXFAMILY # this way of compilation is much faster. We can use multi threading here but not later if [ "$KERNEL_CONFIGURE" != "yes" ]; then - make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- olddefconfig + if [ "$BRANCH" = "default" ]; then + make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- silentoldconfig + else + make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- olddefconfig + fi else make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig fi From 66eff1d5402215773f9cc115e0784ecefd8afbab Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Tue, 8 Dec 2015 17:10:54 +0300 Subject: [PATCH 06/10] Cleaning command here is obsolete, removing --- common.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/common.sh b/common.sh index 0364a253a1..587bedcdc8 100644 --- a/common.sh +++ b/common.sh @@ -141,8 +141,6 @@ sleep 2 if [ -d "$SOURCES/$LINUXSOURCE" ]; then cd $SOURCES/$LINUXSOURCE -# delete previous creations -if [ "$KERNEL_CLEAN" = "yes" ]; then make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- clean | dialog --backtitle "$backtitle" --progressbox "Cleaning kernel source ..." 20 70; fi # adding custom firmware to kernel source if [[ -n "$FIRMWARE" ]]; then unzip -o $SRC/lib/$FIRMWARE -d $SOURCES/$LINUXSOURCE/firmware; fi From 8e1551e9faef962d4abca603fe6d8f88d377075b Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Tue, 8 Dec 2015 19:03:54 +0300 Subject: [PATCH 07/10] Added two options: USE_DIALOG and USE_DIALOG_LOGGING --- common.sh | 13 +++++++++---- main.sh | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common.sh b/common.sh index 587bedcdc8..9579aa89ba 100644 --- a/common.sh +++ b/common.sh @@ -34,9 +34,11 @@ if [ -d "$SOURCES/$BOOTSOURCE" ]; then echo "CONFIG_OLD_SUNXI_KERNEL_COMPAT=y" >> $SOURCES/$BOOTSOURCE/.config fi fi - make $CTHREADS CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" >> $DEST/debug/install.log 2>&1 + eval 'make $CTHREADS CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" 2>&1' \ + ${USE_DIALOG_LOGGING:+' | tee -a $DEST/debug/compilation.log'} ${USE_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." 20 80'} else - make $CTHREADS $BOOTCONFIG CROSS_COMPILE=arm-linux-gnueabihf- >> $DEST/debug/install.log 2>&1 + eval 'make $CTHREADS $BOOTCONFIG CROSS_COMPILE=arm-linux-gnueabihf- 2>&1' \ + ${USE_DIALOG_LOGGING:+' | tee -a $DEST/debug/compilation.log'} ${USE_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling kernel..." 20 80'} fi @@ -171,13 +173,16 @@ fi if [ "$KERNEL_CONFIGURE" = "yes" ]; then make $CTHREADS ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig; fi -make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" zImage modules 2>&1 | dialog --backtitle "$backtitle" --progressbox "Compiling kernel $CCACHE ..." 20 80 +eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" zImage modules 2>&1' \ + ${USE_DIALOG_LOGGING:+' | tee -a $DEST/debug/compilation.log'} ${USE_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling kernel..." 20 80'} if [ ${PIPESTATUS[0]} -ne 0 ] || [ ! -f arch/arm/boot/zImage ]; then display_alert "Kernel was not built" "@host" "err" exit 1 fi -make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" dtbs 2>&1 | dialog --backtitle "$backtitle" --progressbox "Compiling DTB $CCACHE ..." 20 80 +eval 'make $CTHREADS ARCH=arm CROSS_COMPILE="$CCACHE arm-linux-gnueabihf-" dtbs 2>&1' \ + ${USE_DIALOG_LOGGING:+' | tee -a $DEST/debug/compilation.log'} ${USE_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling Device Tree..." 20 80'} + if [ ${PIPESTATUS[0]} -ne 0 ]; then display_alert "DTBs was not build" "@host" "err" exit 1 diff --git a/main.sh b/main.sh index 0c694fb385..685b10669b 100644 --- a/main.sh +++ b/main.sh @@ -25,6 +25,10 @@ # We'll use this tittle on all menus backtitle="Armbian building script, http://www.armbian.com | Author: Igor Pecovnik" + + if [ "$USE_DIALOG" = "no" ]; then unset USE_DIALOG; else USE_DIALOG=yes; fi + if [ "$USE_DIALOG_LOGGING" = "yes" ]; then rm -f $DEST/debug/compilation.log; fi + mkdir -p $DEST/debug $SRC/userpatches/kernel $SRC/userpatches/u-boot echo -e "Place your patches and kernel.config / u-boot.config here.\n" > $SRC/userpatches/readme.txt echo -e "They'll be automaticly included if placed here!" >> $SRC/userpatches/readme.txt From 1e94e7a84f5d5c362583d90357d702041e524887 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Tue, 8 Dec 2015 20:18:00 +0300 Subject: [PATCH 08/10] Fixed copy-paste mistake --- common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.sh b/common.sh index 9579aa89ba..79db796976 100644 --- a/common.sh +++ b/common.sh @@ -38,7 +38,7 @@ if [ -d "$SOURCES/$BOOTSOURCE" ]; then ${USE_DIALOG_LOGGING:+' | tee -a $DEST/debug/compilation.log'} ${USE_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." 20 80'} else eval 'make $CTHREADS $BOOTCONFIG CROSS_COMPILE=arm-linux-gnueabihf- 2>&1' \ - ${USE_DIALOG_LOGGING:+' | tee -a $DEST/debug/compilation.log'} ${USE_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling kernel..." 20 80'} + ${USE_DIALOG_LOGGING:+' | tee -a $DEST/debug/compilation.log'} ${USE_DIALOG:+' | dialog --backtitle "$backtitle" --progressbox "Compiling u-boot..." 20 80'} fi From 8e21284e3db8b0c5589ee5d0d3b34325f5cc5a5a Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Tue, 8 Dec 2015 23:27:23 +0300 Subject: [PATCH 09/10] Failsafe: checking version of copied compile.sh --- compile.sh | 4 ++++ main.sh | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/compile.sh b/compile.sh index b51f45a48f..03f38a0827 100644 --- a/compile.sh +++ b/compile.sh @@ -87,3 +87,7 @@ if [ "$BUILD_ALL" == "yes" ]; then else source $SRC/lib/main.sh fi + +# If you are editing this file, increment VERSION +# Only integers are supported +# VERSION=3 diff --git a/main.sh b/main.sh index a9a97328b2..1f62f98d5a 100644 --- a/main.sh +++ b/main.sh @@ -23,6 +23,14 @@ fi done + # compile.sh version checking + ver1=$(grep '^# VERSION' "$SRC/compile.sh" | cut -d'=' -f2) + ver2=$(grep '^# VERSION' "$SRC/lib/compile.sh" | cut -d'=' -f2) + if [ -z "$ver1" ] || [ "$ver1" -lt "$ver2" ]; then + echo -e "[\e[0;35m warn \x1B[0m] File $0 is outdated. Please copy it again, \nchange options if needed and restart compilation process" + read -p "Press to abort compilation, to continue" + fi + # We'll use this tittle on all menus backtitle="Armbian building script, http://www.armbian.com | Author: Igor Pecovnik" From 4514b909c261600477267beedc598e0cad69d320 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Wed, 9 Dec 2015 00:07:52 +0300 Subject: [PATCH 10/10] Clarification --- compile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compile.sh b/compile.sh index 03f38a0827..7bd621230e 100644 --- a/compile.sh +++ b/compile.sh @@ -88,6 +88,6 @@ else source $SRC/lib/main.sh fi -# If you are editing this file, increment VERSION +# If you are committing new version of this file, increment VERSION # Only integers are supported # VERSION=3