From bd1720b44494151faf17aeb7c8d640070c61e3d1 Mon Sep 17 00:00:00 2001 From: zador-blood-stained Date: Fri, 9 Dec 2016 13:37:20 +0300 Subject: [PATCH] Modify patching functions This displays if patch was applied from userpatches or additional subdirectory --- common.sh | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/common.sh b/common.sh index 2c3df3e172..f258a673ae 100644 --- a/common.sh +++ b/common.sh @@ -37,7 +37,7 @@ compile_uboot() fi cd "$ubootdir" - [[ $FORCE_CHECKOUT == yes ]] && advanced_patch "u-boot" "$BOOTPATCHDIR" "$BOARD" "${LINUXFAMILY}-${BOARD}-${BRANCH}" + [[ $FORCE_CHECKOUT == yes ]] && advanced_patch "u-boot" "$BOOTPATCHDIR" "$BOARD" "" "${LINUXFAMILY}-${BOARD}-${BRANCH}" # create patch for manual source changes [[ $CREATE_PATCHES == yes ]] && userpatch_create "u-boot" @@ -155,7 +155,7 @@ compile_kernel() [[ $FORCE_CHECKOUT == yes ]] && patch --batch --silent -t -p1 < $SRC/lib/patch/kernel/compiler.patch >> $DEST/debug/output.log 2>&1 fi - [[ $FORCE_CHECKOUT == yes ]] && advanced_patch "kernel" "$LINUXFAMILY-$BRANCH" "$BOARD" "$LINUXFAMILY-$BRANCH" + [[ $FORCE_CHECKOUT == yes ]] && advanced_patch "kernel" "$LINUXFAMILY-$BRANCH" "$BOARD" "" "$LINUXFAMILY-$BRANCH" # create patch for manual source changes in debug mode [[ $CREATE_PATCHES == yes ]] && userpatch_create "kernel" @@ -295,38 +295,49 @@ find_toolchain() eval $"$var_name"="$toolchain" } -# advanced_patch +# advanced_patch # # parameters: # : u-boot, kernel # : u-boot: u-boot, u-boot-neo; kernel: sun4i-default, sunxi-next, ... -# : cubieboard, cubieboard2, cubietruck, ... +# : cubieboard, cubieboard2, cubietruck, ... +# : optional subdirectory # : additional description text # # priority: -# $SRC/userpatches/// +# $SRC/userpatches///target_ +# $SRC/userpatches///board_ # $SRC/userpatches// -# $SRC/lib/patch/// +# $SRC/lib/patch///target_ +# $SRC/lib/patch///board_ # $SRC/lib/patch// # advanced_patch() { local dest=$1 local family=$2 - local device=$3 - local description=$4 + local board=$3 + local target=$4 + local description=$5 display_alert "Started patching process for" "$dest $description" "info" display_alert "Looking for user patches in" "userpatches/$dest/$family" "info" local names=() - local dirs=("$SRC/userpatches/$dest/$family/$device" "$SRC/userpatches/$dest/$family" "$SRC/lib/patch/$dest/$family/$device" "$SRC/lib/patch/$dest/$family") + local dirs=( + "$SRC/userpatches/$dest/$family/target_${target}:[\e[33mu\e[0m][\e[34mt\e[0m]" + "$SRC/userpatches/$dest/$family/board_${board}:[\e[33mu\e[0m][\e[35mb\e[0m]" + "$SRC/userpatches/$dest/$family:[\e[33mu\e[0m][\e[32mc\e[0m]" + "$SRC/lib/patch/$dest/$family/target_${target}:[\e[32ml\e[0m][\e[34mt\e[0m]" + "$SRC/lib/patch/$dest/$family/board_${board}:[\e[32ml\e[0m][\e[35mb\e[0m]" + "$SRC/lib/patch/$dest/$family:[\e[32ml\e[0m][\e[32mc\e[0m]" + ) # required for "for" command shopt -s nullglob dotglob # get patch file names for dir in "${dirs[@]}"; do - for patch in $dir/*.patch; do + for patch in ${dir%%:*}/*.patch; do names+=($(basename $patch)) done done @@ -335,11 +346,11 @@ advanced_patch() # apply patches for name in "${names_s[@]}"; do for dir in "${dirs[@]}"; do - if [[ -f $dir/$name ]]; then - if [[ -s $dir/$name ]]; then - process_patch_file "$dir/$name" "$description" + if [[ -f ${dir%%:*}/$name ]]; then + if [[ -s ${dir%%:*}/$name ]]; then + process_patch_file "${dir%%:*}/$name" "${dir##*:}" else - display_alert "... $name" "skipped" "info" + display_alert "... ${dir##*:} $name" "skipped" fi break # next name fi @@ -351,27 +362,26 @@ advanced_patch() # # parameters: # : path to patch file -# : additional description text +# : additional status text # process_patch_file() { local patch=$1 - local description=$2 + local status=$2 # detect and remove files which patch will create lsdiff -s --strip=1 $patch | grep '^+' | awk '{print $2}' | xargs -I % sh -c 'rm -f %' - # main patch command echo "Processing file $patch" >> $DEST/debug/patching.log patch --batch --silent -p1 -N < $patch >> $DEST/debug/patching.log 2>&1 + echo >> $DEST/debug/patching.log if [[ $? -ne 0 ]]; then - display_alert "... $(basename $patch)" "failed" "wrn"; + display_alert "... $status $(basename $patch)" "failed" "wrn" [[ $EXIT_PATCHING_ERROR == yes ]] && exit_with_error "Aborting due to" "EXIT_PATCHING_ERROR" else - display_alert "... $(basename $patch)" "succeeded" "info" + display_alert "... $status $(basename $patch)" "succeeded" "info" fi - echo >> $DEST/debug/patching.log } install_external_applications()