mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-27 23:34:51 +00:00
9eb852fbc5
Removes the logic to search for a distro release version based on the --dist argument and instead makes this as required parameter provided by the user, reducing code size considerably as the expense of letting the user responsibility to define it. The --dist argument was also used as branch name in some cases (where --dist was not defined) so this change splits the original parameter semantic in two: one for defining the distro release version (--dist) and another to define the branch name (--branch). Finally, a short README with single scenario as example. Signed-off-by: Leo Sandoval <lsandova@redhat.com>
143 lines
2.8 KiB
Bash
Executable file
143 lines
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
set -u
|
|
|
|
shopt -qu globstar
|
|
shopt -qs expand_aliases
|
|
export LC_COLLATE=C
|
|
export LC_ALL=C
|
|
|
|
diff_ops="-O.git.diff.order --patience -l0"
|
|
format_patch_ops="--zero-commit --no-signature --no-numbered --stat=80 --summary $diff_ops"
|
|
alias othergit="GIT_DIR=$PWD/.rhboot.git GIT_WORK_TREE=$PWD git"
|
|
alias formatpatch="othergit format-patch $format_patch_ops"
|
|
|
|
usage()
|
|
{
|
|
retcode=0
|
|
if [ -n "${1:-}" ]; then
|
|
exec 1>&2
|
|
retcode=$1
|
|
fi
|
|
echo usage: "do-rebase [OPTIONS] --dist=<RELEASE_VER> --repo=<REPOSITORY> --branch=<BRANCH>"
|
|
echo OPTIONS: "--amend --commit --nocommit --bumpspec --nobumpspec"
|
|
exit "$retcode"
|
|
}
|
|
|
|
on_error() {
|
|
exec 1>&2
|
|
echo "An error occurred. Exiting..."
|
|
git reset --hard
|
|
exit 1
|
|
}
|
|
|
|
trap 'on_error' ERR
|
|
|
|
# Check if the working directory is clean (no changes)
|
|
if ! git diff-index --quiet HEAD --; then
|
|
echo "Working directory is not clean, cannot rebase." 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
gitrepo=""
|
|
branch=""
|
|
releasever=""
|
|
amend=""
|
|
commit=1
|
|
bumpspec=1
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case $1 in
|
|
--help|-h|--usage|-?|-u)
|
|
usage
|
|
;;
|
|
--dist=*)
|
|
releasever=${1##--dist=}
|
|
;;
|
|
--dist)
|
|
shift
|
|
releasever=$1
|
|
;;
|
|
--repo=*)
|
|
gitrepo=${1##--repo=}
|
|
;;
|
|
--repo)
|
|
shift
|
|
gitrepo=$1
|
|
;;
|
|
--branch=*)
|
|
branch=${1##--branch=}
|
|
;;
|
|
--branch)
|
|
shift
|
|
branch=$1
|
|
;;
|
|
--amend)
|
|
amend="--amend"
|
|
;;
|
|
--commit)
|
|
commit=1
|
|
;;
|
|
--nocommit|--no-commit|--nc)
|
|
# --nocommit implies nobumpspec, but --bumpspec after it will
|
|
# force bumpspec to get run.
|
|
commit=0
|
|
bumpspec=0
|
|
;;
|
|
--bumpspec)
|
|
bumpspec=2
|
|
;;
|
|
--nobumpspec|--no-bumpspec|--nb)
|
|
bumpspec=0
|
|
;;
|
|
*)
|
|
echo "Unknown parameter $1"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
# check must params
|
|
if [ -z "$releasever" ] || [ -z "$gitrepo" ] || [ -z "$branch" ]; then
|
|
usage
|
|
fi
|
|
|
|
if [ ! -d "$PWD/.rhboot.git" ]; then
|
|
othergit init
|
|
othergit config core.abbrev 11
|
|
if ! othergit remote add rhboot "$gitrepo" >/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 "$gitrepo" >/dev/null 2>&1 ; then
|
|
echo "Could not add remote: rhboot" 1>&2
|
|
exit 1
|
|
fi
|
|
else
|
|
othergit remote set-url rhboot "${gitrepo}"
|
|
fi
|
|
|
|
othergit fetch rhboot
|
|
|
|
unset LC_ALL
|
|
git rm -q 0*.patch
|
|
|
|
fedpkg --release "$releasever" sources
|
|
|
|
> grub.patches
|
|
patches=$(formatpatch refs/remotes/rhboot/master..refs/remotes/rhboot/"${branch}")
|
|
for x in $patches ; do
|
|
echo "Patch$(echo "${x}" | cut -d- -f1): ${x}" >> grub.patches
|
|
done
|
|
if [[ -z "$amend" && ${bumpspec} -gt 0 ]] || [[ ${bumpspec} -ge 2 ]] ; then
|
|
rpmdev-bumpspec -c "- Rebased to newer upstream for ${releasever}" grub2.spec
|
|
fi
|
|
git add 0*.patch grub2.spec grub.patches
|
|
if [[ ${commit} -eq 1 ]] ; then
|
|
if [ -z "$amend" ]; then
|
|
fedpkg --release "$releasever" commit -s -c
|
|
else
|
|
git commit --amend
|
|
fi
|
|
fi
|