Enahnce newdracut.sh
to preserve current status of patches. Related: #1947892,#1992464,#2017787,#2017846,#2024502,#2050556,#2050560,#2050562,#2050567,#2050570
This commit is contained in:
parent
e26fcbe196
commit
b6d5cc59a7
31
newdracut.sh
31
newdracut.sh
@ -1,6 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
bash -n "$0" || exit 1
|
||||
shopt -s extglob
|
||||
|
||||
patchnr() {
|
||||
local nr
|
||||
while [[ -n "$1" ]]; do
|
||||
nr=$(cut -d'.' -f1 <<< "$1")
|
||||
shift
|
||||
[[ $((10#$nr)) -gt 0 ]] || echo "Invalid patch number: $nr" >&2
|
||||
echo "$nr"
|
||||
done
|
||||
}
|
||||
|
||||
if [[ -e "$HOME/git/dracut/$1" ]]; then
|
||||
srcrpm="$HOME/git/dracut/$1"
|
||||
elif [[ -e "$HOME/dev/upstream/dracut/$1" ]]; then
|
||||
@ -9,16 +21,21 @@ else
|
||||
srcrpm="$1"
|
||||
fi
|
||||
|
||||
[[ -f $srcrpm ]] || exit 0
|
||||
[[ -f $srcrpm ]] || exit 3
|
||||
|
||||
old_release=$(rpmspec -D "_sourcedir $(pwd)" -q --srpm --qf '%{release}' dracut.spec)
|
||||
old_release=${old_release%%.*}
|
||||
|
||||
cp dracut.spec dracut.spec.old
|
||||
for i in *.patch; do git rm -f $i;done
|
||||
|
||||
rm *.patch; git reset --hard HEAD
|
||||
last_patch_nr=$(patchnr *.patch | sort -n | tail -n 1)
|
||||
#for i in *.patch; do git rm -f $i;done
|
||||
|
||||
if rpm -ivh --define "_srcrpmdir $PWD" --define "_specdir $PWD" --define "_sourcedir $PWD" "$srcrpm"; then
|
||||
ls *.patch &>/dev/null && git add *.patch
|
||||
for nr in $(patchnr *.patch); do
|
||||
[[ $((10#$nr)) -gt $((10#$last_patch_nr)) ]] && git add "${nr}.patch"
|
||||
done
|
||||
|
||||
new_version=$(rpmspec -D "_sourcedir $(pwd)" -q --srpm --qf '%{version}' dracut.spec)
|
||||
new_release=$(rpmspec -D "_sourcedir $(pwd)" -q --srpm --qf '%{release}' dracut.spec)
|
||||
@ -46,6 +63,9 @@ if rpm -ivh --define "_srcrpmdir $PWD" --define "_specdir $PWD" --define "_sourc
|
||||
fi
|
||||
done < dracut.spec.old >> dracut.spec
|
||||
|
||||
# Patch list:
|
||||
# ls *.patch | tr -s ' ' '\n' | cut -d'.' -f1 | xargs -i zsh -c "nr=\$((10#{})); echo \"Patch\${nr}: {}.patch\""
|
||||
|
||||
git add dracut.spec
|
||||
|
||||
msg="Resolves: $(
|
||||
@ -54,9 +74,8 @@ if rpm -ivh --define "_srcrpmdir $PWD" --define "_specdir $PWD" --define "_sourc
|
||||
if [ -n "$resolves" ]; then
|
||||
echo "${resolves#Resolves: }"
|
||||
fi
|
||||
done | sort -u | tr '\n' ',')"
|
||||
git commit -m "dracut-${new_version}-${new_release_full}
|
||||
done | sed -e 's/rhbz#/#/g' | sort -u | tr -s '\n' ',')"
|
||||
|
||||
${msg%,}"
|
||||
git commit -m "$(echo -e "dracut-${new_version}-${new_release_full}\n\n${msg%,}")"
|
||||
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user