From 3b99bc4d10c38ed47f82ed10f5e5ead58cc953a3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 19 Oct 2018 14:21:28 +0200 Subject: [kernel-vanilla] Refine determining required aufs branch --- core/modules/kernel-vanilla/module.build | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'core/modules/kernel-vanilla') diff --git a/core/modules/kernel-vanilla/module.build b/core/modules/kernel-vanilla/module.build index cc533582..167de9cb 100644 --- a/core/modules/kernel-vanilla/module.build +++ b/core/modules/kernel-vanilla/module.build @@ -160,11 +160,26 @@ patch_aufs() { git clone "git://github.com/sfjro/${AUFS}-standalone.git" || perror "Cloning ${AUFS} failed." fi # get the needed version - [ -n "${SYSTEM_KERNEL_LONG}" ] && local NEEDED_BRANCH=$(echo $REQUIRED_KERNEL | awk -F "." '{print $1"."$2}') \ - || perror "REQUIRED_KERNEL not set, this should not happen!" - pinfo "Getting branch origin/$NEEDED_BRANCH" cd "${MODULE_WORK_DIR}/${AUFS}-standalone" || perror "Could not CD to ${AUFS}-standalone" - git checkout "origin/aufs$NEEDED_BRANCH" || git checkout "origin/aufs4.x-rcN" || perror "Could not checkout needed branch." + local branches=( $( git branch -r | grep -oE 'aufs[0-9\.\+]+$' ) ) + local major minor patch + IFS=. read major minor patch _ <<<"$REQUIRED_KERNEL" + if [ -z "$major" ] || [ -z "$minor" ]; then + perror "REQUIRED_KERNEL not in properly set, this should not happen!" + fi + local NEEDED_BRANCH="aufs${major}.${minor}" + local testvar + while [ "${patch}" -gt 0 ]; do + for testvar in "${branches[@]}"; do + if [ "$testvar" = "${NEEDED_BRANCH}.${patch}" ] || [ "$testvar" = "${NEEDED_BRANCH}.${patch}+" ]; then + NEEDED_BRANCH="$testvar" + break 2 + fi + done + patch=$(( patch - 1 )) + done + pinfo "Getting branch origin/$NEEDED_BRANCH" + git checkout "origin/$NEEDED_BRANCH" || git checkout "origin/aufs4.x-rcN" || perror "Could not checkout needed branch." pinfo "Starting to patch... $NEEDED_BRANCH" tarcopy "Documentation fs" "$MODULE_WORK_DIR/ksrc" @@ -186,7 +201,7 @@ patch_aufs() { patch -p1 < "$MODULE_WORK_DIR/${AUFS}-standalone/${PATCH}.patch" || pwarning "${PATCH}.patch failed!" pinfo "Applied '$MODULE_WORK_DIR/${AUFS}-standalone/${PATCH}.patch'" done - pinfo "Patched kernel source with aufs-${NEEDED_BRANCH}" + pinfo "Patched kernel source with ${NEEDED_BRANCH}" cd "$MODULE_WORK_DIR" || perror "Where is WORK_DIR?" } -- cgit v1.2.3-55-g7522