2016-02-17 00:06:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2017-06-16 19:21:18 +00:00
|
|
|
set -u
|
2016-02-17 00:06:49 +00:00
|
|
|
shopt -qu globstar
|
2017-06-16 19:21:18 +00:00
|
|
|
shopt -qs expand_aliases
|
2016-02-17 00:06:49 +00:00
|
|
|
export LC_COLLATE=C
|
|
|
|
export LC_ALL=C
|
|
|
|
|
2018-05-11 14:33:02 +00:00
|
|
|
format_patch_ops="--stat=80 --summary -O.git.diff.order --patience -l0"
|
2017-06-16 19:21:18 +00:00
|
|
|
alias othergit="GIT_DIR=$PWD/.rhboot.git GIT_WORK_TREE=$PWD git"
|
2018-05-11 14:33:02 +00:00
|
|
|
alias formatpatch="othergit format-patch $format_patch_ops"
|
2017-06-16 19:21:18 +00:00
|
|
|
|
2016-02-17 00:06:49 +00:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
retcode=0
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
exec 1>&2
|
|
|
|
retcode=$1
|
|
|
|
fi
|
|
|
|
echo usage: do-rebase \$releasever
|
|
|
|
exit $retcode
|
|
|
|
}
|
|
|
|
|
2016-12-01 22:10:06 +00:00
|
|
|
if ! git status | grep -q 'nothing to commit, working .* clean' ; then
|
2016-02-17 00:06:49 +00:00
|
|
|
echo "Working directory is not clean, cannot rebase." 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
releasever=""
|
2016-04-07 14:44:51 +00:00
|
|
|
amend=""
|
2016-02-17 00:06:49 +00:00
|
|
|
|
|
|
|
declare -a savedargs
|
2017-06-16 19:21:18 +00:00
|
|
|
savedargs=()
|
2016-02-17 00:06:49 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
--help|-h|--usage|-?|-u)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
--dist=*)
|
|
|
|
releasever=${1##--dist=}
|
|
|
|
;;
|
|
|
|
--dist)
|
|
|
|
shift
|
|
|
|
releasever=$1
|
|
|
|
;;
|
2016-04-07 14:44:51 +00:00
|
|
|
--amend)
|
|
|
|
amend="--amend"
|
|
|
|
;;
|
2016-02-17 00:06:49 +00:00
|
|
|
*)
|
|
|
|
savedargs[${#savedargs[@]}]="$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
set -- "${savedargs[@]}"
|
|
|
|
|
|
|
|
if [ -z "${releasever}" -a $# -gt 0 ]; then
|
|
|
|
releasever=$1
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
dist=$(git status | grep "On branch" | cut -d\ -f3-)
|
|
|
|
if [ -z "$dist" ]; then
|
|
|
|
echo "Could not figure out distro release version" 1>&2
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
case "$(eval echo \${dist})" in
|
|
|
|
.fc*)
|
|
|
|
releasever=$(echo ${dist} | \
|
|
|
|
sed 's/^\.fc\([[:digit:]]\+\)$/fedora-\1/')
|
|
|
|
;;
|
|
|
|
.*)
|
|
|
|
releasever=$(echo $dist | \
|
|
|
|
sed 's/^\.\([[:alpha:]]\+\)\([[:digit:]]\+\)$/\1-\2/')
|
|
|
|
;;
|
2017-06-16 19:21:18 +00:00
|
|
|
rhel*)
|
|
|
|
releasever=${dist}
|
|
|
|
dist=.el${releasever##rhel-}
|
|
|
|
;;
|
2016-02-17 00:06:49 +00:00
|
|
|
esac
|
|
|
|
if [ -z "${releasever}" -o "${releasever}" = "${dist}" ]; then
|
|
|
|
echo "Could not figure out distro release version" 1>&2
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$releasever" ]; then
|
|
|
|
echo "Could not figure out distro release version" 1>&2
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -ge 1 ]; then
|
|
|
|
echo "Unknown argument \"$1\"" 1>&2
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
2017-06-16 19:21:18 +00:00
|
|
|
if [ ! -d $PWD/.rhboot.git ]; then
|
|
|
|
othergit init
|
|
|
|
if ! othergit remote add \
|
|
|
|
rhboot git@github.com:rhboot/grub2.git \
|
|
|
|
>/dev/null 2>&1 ; then
|
|
|
|
echo "Could not add remote: rhboot" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
elif othergit remote show -n rhboot | grep -q "URL: github$" ; then
|
|
|
|
if ! othergit remote add \
|
|
|
|
rhboot git@github.com:rhboot/grub2.git \
|
|
|
|
>/dev/null 2>&1 ; then
|
|
|
|
echo "Could not add remote: rhboot" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-02-17 00:06:49 +00:00
|
|
|
fi
|
|
|
|
|
2017-06-16 19:21:18 +00:00
|
|
|
othergit fetch rhboot
|
|
|
|
remote=$(othergit branch --list -r "rhboot/${releasever}" 2>/dev/null)
|
|
|
|
if [ "${remote}" != " rhboot/${releasever}" ]; then
|
2016-02-17 00:06:49 +00:00
|
|
|
echo branch \"${releasever}\" does not appear to exist 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset LC_ALL
|
|
|
|
git rm -q 0*.patch
|
|
|
|
|
2017-06-16 19:21:18 +00:00
|
|
|
> grub.patches
|
2018-05-11 14:33:02 +00:00
|
|
|
patches=$(formatpatch grub-2.02..refs/remotes/rhboot/${releasever})
|
2016-02-17 00:06:49 +00:00
|
|
|
for x in $patches ; do
|
|
|
|
echo Patch$(echo ${x} | cut -d- -f1): ${x} >> grub.patches
|
|
|
|
done
|
2016-04-07 14:44:51 +00:00
|
|
|
if [ -z "$amend" ]; then
|
|
|
|
rpmdev-bumpspec -c "- Rebased to newer upstream for ${releasever}" grub2.spec
|
|
|
|
fi
|
2017-06-16 19:21:18 +00:00
|
|
|
git add 0*.patch grub2.spec grub.patches
|
2016-04-07 14:44:51 +00:00
|
|
|
if [ -z "$amend" ]; then
|
|
|
|
fedpkg commit -s -c $amend
|
|
|
|
else
|
2018-01-17 20:37:31 +00:00
|
|
|
git commit --amend
|
2016-04-07 14:44:51 +00:00
|
|
|
fi
|