diff --git a/scripts/prepare-maint-update b/scripts/prepare-maint-update index 7439b40..6e358a6 100755 --- a/scripts/prepare-maint-update +++ b/scripts/prepare-maint-update @@ -9,24 +9,30 @@ nrm=$(tput sgr0) sn="${0##*/}" usage() { - printf "${Red}usage:${nrm} %s [-h] [-g ] [-t tbranch] branch\n" "$sn" + printf "${Red}usage:${nrm} %s [-h] [-g | -G] [-t tbranch] branch\n" "$sn" #rintf "usage: " printf " Arg Example\n" - printf " kgraft_prj SLE15-SP5_Update_9\n" - printf " tbranch SLE15-SP5 (specify target when branch is a user branch)\n" - printf " branch SLE15-SP5\n" + printf " -g kgraft_prj SLE15-SP5_Update_9\n" + printf " -G no livepatch submission (e.g. when resubmitting)\n" + printf " -t tbranch SLE15-SP5 (specify target when branch is a user branch)\n" + printf " branch SLE15-SP5\n" } -OPTS=$(getopt -o g:t:h -n "$sn" -- "$@") +OPTS=$(getopt -o g:Gt:h -n "$sn" -- "$@") eval set -- "$OPTS" unset OPTS +nolp= while true ; do case "$1" in '-g') lp_proj="$2" shift 2 ;; + '-G') + nolp=1 + shift 1 + ;; '-t') tbranch="$2" shift 2 @@ -49,6 +55,9 @@ done if [ $# -ne 1 ]; then usage >&2 exit 1 +elif [ -n "$lp_proj" -a -n "$nolp" ] ; then + printf "${Red}-g and -G cannot be combined.${nrm}\n" >&2 + exit 1 fi branch="$1" @@ -100,7 +109,9 @@ printf "Submission branch: ${blu}%s${nrm}\n" "$branch" printf "Commit: ${grn}%s${nrm}\n" \ $(git --no-pager show -s --pretty='%h' "$branch") printf "Version: ${blu}%s${nrm}\n" "$version" -printf "Kgraft prj: ${blu}%s${nrm}\n" "$lp_proj" +if [ -z "$nolp" ] ; then + printf "Kgraft prj: ${blu}%s${nrm}\n" "$lp_proj" +fi echo if ! git merge-base --is-ancestor "$branch" "$tbranch"; then @@ -126,38 +137,42 @@ while read a; do archs="${archs}${archs:+ }${a#${smlp}}" done < <($OSC ls "$chanprj" | egrep "^$smlp") -kgraft_prj="${kgraft_dir}:${lp_proj}" -printf "${grn}* Copy kernel-livepatch-%s_Update_%u package...${nrm}\n" \ - "$prod" "$upd" -$OSC copypac "$kgraft_prj" \ - "kernel-livepatch-${prod}_Update_${upd}" "$prj" - -inc_upd="s/${prod}_Update_[[:digit:]]+/${prod}_Update_${upd}/g" -fixme="s/(${version//./_})-[[:digit:]_]+-/\1-FIXME-/" -printf "${grn}* Branch %s* and update _channel...${nrm}\n" "$smlp" -for a in $archs; do - printf "${grn} * architecture %s...${nrm}\n" "$a" - $OSC bco "$chanprj" "${smlp}${a}" "$prj" - pushd "${prj}/${smlp}${a}" >/dev/null - # Copy last bunch packages of given product, update their versions and - # paste them in one block after last package - last_pkg=$(grep -E "${prod}_Update_[[:digit:]]+" _channel | tail -1) - last_upd=$(echo "$last_pkg" | grep -oE "${prod}_Update_[[:digit:]]+" | tail -1) - prev_pkgs=$(grep -E "${last_upd}" _channel) - new_pkgs=$(echo -n "$prev_pkgs" | sed -re "${inc_upd} ; ${fixme} ; s/\$/\\\/") - # Assume no '|' in XML rows, escaping magic not to insert a trailing newline - sed -re "\|${last_pkg}| a \\ -${new_pkgs%\\} -" -i _channel - $OSC commit -m "update channel file" - popd >/dev/null -done +if [ -z "$nolp" ] ; then + kgraft_prj="${kgraft_dir}:${lp_proj}" + printf "${grn}* Copy kernel-livepatch-%s_Update_%u package...${nrm}\n" \ + "$prod" "$upd" + $OSC copypac "$kgraft_prj" \ + "kernel-livepatch-${prod}_Update_${upd}" "$prj" + + inc_upd="s/${prod}_Update_[[:digit:]]+/${prod}_Update_${upd}/g" + fixme="s/(${version//./_})-[[:digit:]_]+-/\1-FIXME-/" + printf "${grn}* Branch %s* and update _channel...${nrm}\n" "$smlp" + for a in $archs; do + printf "${grn} * architecture %s...${nrm}\n" "$a" + $OSC bco "$chanprj" "${smlp}${a}" "$prj" + pushd "${prj}/${smlp}${a}" >/dev/null + # Copy last bunch packages of given product, update their versions and + # paste them in one block after last package + last_pkg=$(grep -E "${prod}_Update_[[:digit:]]+" _channel | tail -1) + last_upd=$(echo "$last_pkg" | grep -oE "${prod}_Update_[[:digit:]]+" | tail -1) + prev_pkgs=$(grep -E "${last_upd}" _channel) + new_pkgs=$(echo -n "$prev_pkgs" | sed -re "${inc_upd} ; ${fixme} ; s/\$/\\\/") + # Assume no '|' in XML rows, escaping magic not to insert a trailing newline + sed -re "\|${last_pkg}| a \\ + ${new_pkgs%\\} + " -i _channel + $OSC commit -m "update channel file" + popd >/dev/null + done +fi echo -e "\n\nTo submit the update, run\n" printf "${red} %s mr %s \\\\\n" "$OSC" "$prj" printf " kernel-source \\\\\n" -printf " kernel-livepatch-%s_Update_%u \\\\\n" "$prod" "$upd" -while read p; do - printf " %s \\\\\n" "$p" -done < <($OSC ls "$prj" | egrep "^$smlp") +if [ -z "$nolp" ] ; then + printf " kernel-livepatch-%s_Update_%u \\\\\n" "$prod" "$upd" + while read p; do + printf " %s \\\\\n" "$p" + done < <($OSC ls "$prj" | egrep "^$smlp") +fi printf " %s${nrm}\n\n" "$target"