Skip to content

Commit

Permalink
Merge pull request #29 from bith3ad/flags
Browse files Browse the repository at this point in the history
Add umpf-flags support to control the EXTRAVERSION patching
  • Loading branch information
michaelolbrich authored Nov 15, 2023
2 parents acf990f + 5c659bb commit 78ce139
Showing 1 changed file with 76 additions and 2 deletions.
78 changes: 76 additions & 2 deletions umpf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ GIT_FALLBACK_REMOTE=""
SERIES=""
BASE=""
NAME=""
FLAGS=""
PATCH_DIR="umpf-patches"
IDENTICAL=false
STABLE=false
Expand Down Expand Up @@ -76,6 +77,15 @@ GIT_DIR="${GIT_DIR:-$(${GIT} rev-parse --git-dir 2> /dev/null)}"
GIT_DIR="${GIT_DIR:-.git}"
STATE="${GIT_DIR}/umpf"

### flags ####
SUPPORTED_FLAGS=("extraversion")

declare -A flag_extraversion

flag_extraversion[val]="replace"
flag_extraversion[values]="replace conflictfree"
##############

info() {
if [ -z "$*" ]; then
echo >&2
Expand All @@ -94,6 +104,7 @@ bailout() {
IDENTICAL="${IDENTICAL}"
STABLE="${STABLE}"
UPDATE="${UPDATE}"
FLAGS="${FLAGS}"
VERSION_SEPARATOR="${VERSION_SEPARATOR}"
VERSION="${VERSION}"
EOF
Expand Down Expand Up @@ -153,6 +164,7 @@ usage() {
--bb with format-patch: write patch series for bitbake
-h, --help
-f, --force
--flags specify/override umpf-flags
-i, --identical use exact commit hashes, not tip of branches
-s, --stable create a 'stable' tag from a branch based on an
existing tag. Implies '--identical'.
Expand Down Expand Up @@ -213,7 +225,7 @@ setup() {
fi

o="fhisub:n:p:r:v:"
l="auto-rerere,bb,force,help,identical,stable,update,base:,name:,patchdir:,relative:,override:,remote:,version:"
l="auto-rerere,bb,flags:,force,help,identical,stable,update,base:,name:,patchdir:,relative:,override:,remote:,version:"
if ! args="$(getopt -n umpf -o "${o}" -l "${l}" -- "${@}")"; then
usage
exit 1
Expand All @@ -236,6 +248,10 @@ setup() {
-f|--force)
FORCE=true
;;
--flags)
FLAGS="${1}"
shift
;;
-h|--help)
usage
exit
Expand Down Expand Up @@ -731,6 +747,35 @@ check_topic_range() {
echo "topic-range" >> "${STATE}/check"
}
verify_flag() {
local flag validval=0
flag=flag_$flagname
declare -p ${flag} &>/dev/null || abort "Unknown umpf-flag: ${flagname} (supported flags: ${SUPPORTED_FLAGS[*]})"
declare -n flag
for v in ${flag[values]}; do
[ "${v}" != "${flagval}" ] && continue
# shellcheck disable=SC2154
flag[val]="${v}"
validval=1
done
[ ${validval} -eq 1 ] || abort "Invalid umpf-flag value: ${flagval} (allowed values: ${flag[values]})!"
}
check_flags() {
local flagval flagname
for keyval in ${content}; do
flagname=${keyval%%=*}
flagval=${keyval#*=}
verify_flag
done
}
check_end() {
verify_topic
echo "end" > "${STATE}/check"
Expand Down Expand Up @@ -811,6 +856,20 @@ parse() {
line="# umpf-relative: ${content}"
do_exec relative
fi
if [ -n "${FLAGS}" ]; then
echo "${line}" >> "${STATE}/done"
content="${FLAGS}"
line="# umpf-flags: ${content}"
do_exec flags
fi
;;
flags)
${has_base} || bailout "${cmd} before base"
test -n "${content}" || bailout "${cmd} line without value"
if [ -z "${FLAGS}" ]; then
do_exec flags
fi
;;
relative)
${has_base} || bailout "${cmd} before base"
Expand Down Expand Up @@ -1046,6 +1105,10 @@ rebase_hashinfo() {
fi
}
rebase_flags() {
echo "$line" >&${series_out}
}
rebase_end() {
local version="$(<"${STATE}/version")"
local version_file
Expand All @@ -1054,7 +1117,11 @@ rebase_end() {
${GIT} rev-parse HEAD > "${STATE}/prev_head"
if grep -sq '^EXTRAVERSION =' Makefile; then
sed -i -r "s:^(EXTRAVERSION =.*)\$:\1-${version}:" Makefile
if [ ${flag_extraversion[val]} == "conflictfree" ]; then
sed -i -r "s;^(KERNELRELEASE =.*)\$;EXTRAVERSION := \$(EXTRAVERSION)-${version}\n\1;" Makefile
else
sed -i -r "s:^(EXTRAVERSION =.*)\$:\1-${version}:" Makefile
fi
git add Makefile
elif grep -sq '^VERSION_STRING\s*:=' Makefile; then
Expand Down Expand Up @@ -1276,6 +1343,10 @@ format_patch_topic_range() {
echo "${num}" > "${STATE}/num"
}
format_patch_flags() {
echo "$line" >&${series_out}
}
format_patch_end() {
echo "$line" >&${series_out}
}
Expand Down Expand Up @@ -1719,6 +1790,9 @@ do_init() {
if [ -n "${GIT_RELATIVE}" ]; then
echo "# umpf-relative: ${GIT_RELATIVE}" >> "${SERIES}"
fi
if [ -n "${FLAGS}" ]; then
echo "# umpf-flags: ${FLAGS}" >> "${series}"
fi
if [ -z "${NAME}" ]; then
read -e -p "name: " NAME
fi
Expand Down

0 comments on commit 78ce139

Please sign in to comment.