2016-02-17 00:06:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
shopt -qu globstar
|
|
|
|
export LC_COLLATE=C
|
|
|
|
export LC_ALL=C
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
retcode=0
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
exec 1>&2
|
|
|
|
retcode=$1
|
|
|
|
fi
|
|
|
|
echo usage: do-rebase \$releasever
|
|
|
|
exit $retcode
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! git status | grep -q 'nothing to commit, working directory clean' ; then
|
|
|
|
echo "Working directory is not clean, cannot rebase." 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
releasever=""
|
|
|
|
|
|
|
|
declare -a savedargs
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case $1 in
|
|
|
|
--help|-h|--usage|-?|-u)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
--dist=*)
|
|
|
|
releasever=${1##--dist=}
|
|
|
|
;;
|
|
|
|
--dist)
|
|
|
|
shift
|
|
|
|
releasever=$1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
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/')
|
|
|
|
;;
|
|
|
|
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
|
|
|
|
|
|
|
|
if ! git remote show -n github >/dev/null 2>&1 ; then
|
|
|
|
git remote add \
|
|
|
|
github git@github.com:vathpela/grub2-fedora.git >/dev/null 2>&1
|
|
|
|
echo "Could not add remote: github" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
git fetch github
|
|
|
|
remote=$(git branch --list -r "github/${releasever}" 2>/dev/null)
|
|
|
|
if [ "${remote}" != " github/${releasever}" ]; then
|
|
|
|
echo branch \"${releasever}\" does not appear to exist 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset LC_ALL
|
|
|
|
git rm -q 0*.patch
|
|
|
|
(cat <<EOF
|
|
|
|
From: Peter Jones <pjones@redhat.com>
|
|
|
|
Date: Wed Jul 22 10:18:00 2015 -0400
|
|
|
|
Subject: Stop trying to "git format-patch" across a merge that confuses it
|
|
|
|
|
|
|
|
EOF
|
2016-03-04 18:32:29 +00:00
|
|
|
git diff --full-index --binary refs/tags/grub-2.02-beta3..refs/remotes/github/master
|
|
|
|
) > grub-2.02-beta3-to-origin-master.patch
|
2016-02-17 00:06:49 +00:00
|
|
|
|
|
|
|
patches=$(git format-patch refs/remotes/github/master..refs/remotes/github/${releasever})
|
2016-03-04 18:32:29 +00:00
|
|
|
echo Patch0000: grub-2.02-beta3-to-origin-master.patch > grub.patches
|
2016-02-17 00:06:49 +00:00
|
|
|
for x in $patches ; do
|
|
|
|
echo Patch$(echo ${x} | cut -d- -f1): ${x} >> grub.patches
|
|
|
|
done
|
|
|
|
rpmdev-bumpspec -c "- Rebased to newer upstream for ${releasever}" grub2.spec
|
2016-03-04 18:32:29 +00:00
|
|
|
git add 0*.patch grub2.spec grub-2.02-beta3-to-origin-master.patch grub.patches
|
2016-02-17 00:06:49 +00:00
|
|
|
fedpkg commit -s -c
|