From 6848564543d7863f9ac680b1ae93fed72c857733 Mon Sep 17 00:00:00 2001 From: Marc Mattmueller Date: Wed, 13 Oct 2021 11:37:41 +0200 Subject: [PATCH] src-rev/jenkins: adapted src-rev to handle packages from a file the file autorev-packages.inc holds holds all recipes with a SRCREV set to AUTOREV. When releasing this file shall be used as base which recipes to update. BugzID: 75209 Signed-off-by: Marc Mattmueller --- Jenkinsfile_Common | 2 +- Jenkinsfile_update2head | 2 +- src-rev.sh | 57 +++++++++++++++++++++++++++++------------ 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile_Common b/Jenkinsfile_Common index a7ee63e..2b0fe5a 100644 --- a/Jenkinsfile_Common +++ b/Jenkinsfile_Common @@ -70,7 +70,7 @@ def cleanupAutoRevIncludeFile(versionParam) { def updateSourceRevisions() { println "update source revisions to head..." - sh(returnStdout: true, script: "bash -c '. ./env.image-ostree > /dev/null && cd ../ && ./src-rev.sh -v -d -r -l ./srcrev.log'") + sh(returnStdout: true, script: "bash -c '. ./env.image-ostree > /dev/null && cd ../ && ./src-rev.sh -v -d -r -l ./srcrev.log -a ./autorev-packages.inc'") } diff --git a/Jenkinsfile_update2head b/Jenkinsfile_update2head index 1af3958..78d80ab 100644 --- a/Jenkinsfile_update2head +++ b/Jenkinsfile_update2head @@ -111,7 +111,7 @@ def updateMachineSrcRevs(machine) { println "update source revisions for ${env.MACHINE} to head..." sh("echo '==> ${env.MACHINE} =======================' >> ./${env.SOURCE_REVISION_UPDATE_LOG}") sh("bash -c '. ./env.image-ostree > /dev/null && cd ../'") - sh(returnStdout: true, script: "./src-rev.sh -v -d -r -l ./srcrev.log") + sh(returnStdout: true, script: "./src-rev.sh -v -d -r -l ./srcrev.log -a ./autorev-packages.inc") sh("cat ./srcrev.log >> ./${env.SOURCE_REVISION_UPDATE_LOG}") } diff --git a/src-rev.sh b/src-rev.sh index 5957873..a506560 100755 --- a/src-rev.sh +++ b/src-rev.sh @@ -6,10 +6,11 @@ SCRIPT_NAME=$(basename ${SCRIPT_PATHNAME}) SCRIPT_PATH=$(dirname ${SCRIPT_PATHNAME}) YOCTO_DIR="${YOCTO_DIR:-$SCRIPT_PATH}" -export LOGFILE=/dev/null -export IS_REPLACE_SRCREV=false -export IS_VERBOSE=false -export IS_DISPLAY=false +LOGFILE=/dev/null +IS_REPLACE_SRCREV=false +IS_VERBOSE=false +IS_DISPLAY=false +LIST="" #********************************************************************************************** # local helper functions @@ -18,13 +19,19 @@ export IS_DISPLAY=false function printUsage() { echo -e "\nUsage: ${SCRIPT_NAME} [OPTIONS]\n" + echo -e "find the source revision of the packages within the netmodule meta layers and" + echo -e "display/replace them with the latest hashes." + echo -e "NOTE: there is a list containing packages set to AUTOREV. Use option -a to handle" + echo -e "only revisions of this list. Otherwise we might get incompatible versions of 3rd" + echo -e "party packages.\n" echo -e "" - echo -e " OPTIONS:" - echo -e " -r|--replace replace SRCREVs" - echo -e " -d|--display display found SRVREVs" - echo -e " -l|--log=LOGFILE write command output to LOGFILE (default = $LOGFILE)" - echo -e " -h|--help Show this help" - echo -e " -v|--verbose Set script to verbose" + echo -e " OPTIONS:" + echo -e " -r|--replace replace SRCREVs" + echo -e " -d|--display display found SRVREVs" + echo -e " -a|--autorev-list=LIST handle only revisions of LIST (e.g. autorev-packages.inc)" + echo -e " -l|--log=LOGFILE write command output to LOGFILE (default = $LOGFILE)" + echo -e " -h|--help show this help" + echo -e " -v|--verbose set script to verbose" } #---------------------------------------------------------------------------------------------- function logMessage() @@ -55,18 +62,28 @@ function checkingEnvironment() fi } #---------------------------------------------------------------------------------------------- +function getBBFiles() +{ + if [[ "${LIST}" == "" ]]; then + files=$(find ${YOCTO_DIR}/meta-netmodule* -name "*.bb" | xargs -i sh -c "grep -q SRCREV {} && echo {}") + else + files=$(cat $LIST | grep "#" | cut -d'#' -f2) + fi + echo "${files}" +} +#---------------------------------------------------------------------------------------------- function displayItem() { local bbfile="${1}" local recipeName="${2}" local revision="${3}" - printMessage "Recipe: $recipe" - printMessage "New Revision: $newrev" + printMessage "Recipe: $recipeName" + printMessage "New Revision: $revision" printMessage "BB File: $bbfile" if [[ "${IS_DISPLAY}" == "true" && "${IS_VERBOSE}" == "false" ]]; then - echo "Recipe: $recipe" - echo "New Revision: $newrev" + echo "Recipe: $recipeName" + echo "New Revision: $revision" echo "BB File: $bbfile" fi } @@ -75,7 +92,7 @@ function displayItem() #********************************************************************************************** # main #********************************************************************************************** -O=$(getopt -o hl:vrd --long help,log:,verbose,replace,display -- "$@") || exit 1 +O=$(getopt -o hl:a:vrd --long help,log:,autorev-list:,verbose,replace,display -- "$@") if [ $? != 0 ]; then echo "ERROR: Could not parse command line options" exit 1 @@ -96,6 +113,11 @@ while true; do export IS_REPLACE_SRCREV=true shift ;; + -a|--autorev-list) + export LIST="${2}" + export LIST=$(realpath "${LIST}") + shift 2 + ;; -l|--log) export LOGFILE="${2}" export LOGFILE=$(realpath "${LOGFILE}") @@ -118,8 +140,8 @@ done echo "${SCRIPT_NAME} called with ${SCRIPT_PARAMS}" > $LOGFILE checkingEnvironment -printMessage "> get bbfiles..." -bbfiles=$(find ${YOCTO_DIR}/meta-netmodule* -name "*.bb" | xargs -i sh -c "grep -q SRCREV {} && echo {}") +printMessage "> get bbfiles (LIST='${LIST}')..." +bbfiles=$(getBBFiles) logMessage "${bbfiles}" printMessage "> getting recipes residing in bbfiles..." @@ -128,6 +150,7 @@ logMessage "${recipes}" printMessage "> getting check-upgrade-status..." newcommits=$(devtool check-upgrade-status $recipes 2>&1 | grep "new commits") +logMessage "${newcommits}" IFS=$'\n' for newcommit in $newcommits; do