2017-12-08 04:31:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Generic function to print an error message and bail out.
|
|
|
|
die ()
|
|
|
|
{
|
|
|
|
echo $1 > /dev/stderr
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Print usage
|
|
|
|
usage ()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
$0 -- Generate a git repository from .patch files
|
|
|
|
|
|
|
|
Usage:
|
2020-06-05 22:45:45 +00:00
|
|
|
$0 [-u] [-h] <REPOSITORY>
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
<REPOSITORY> is the directory where the rebase was performed. You
|
|
|
|
need to clone the repository first.
|
|
|
|
|
|
|
|
Options are:
|
|
|
|
|
|
|
|
-h: Print this message
|
2020-06-05 22:45:45 +00:00
|
|
|
-u: Uncommit all patches and initialize stgit repo
|
2017-12-08 04:31:26 +00:00
|
|
|
EOF
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
test -f gdb.spec || die "This script needs to run from the same directory as gdb.spec."
|
|
|
|
|
|
|
|
test -z $1 && die "You need to specify the repository."
|
|
|
|
test "$1" = "-h" && usage
|
|
|
|
|
2020-06-05 22:45:45 +00:00
|
|
|
uncommit=0
|
|
|
|
if [ "$1" = "-u" ]; then
|
|
|
|
uncommit=1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
git_repo=$1
|
|
|
|
if [ ! -e $git_repo ]; then
|
|
|
|
echo "$0: repository \"$git_repo\" does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
test -f _git_upstream_commit || die "Cannot find _git_upstream_commit file."
|
|
|
|
test -f _patch_order || die "Cannot find _patch_order file."
|
2020-06-05 22:45:45 +00:00
|
|
|
command -v stg > /dev/null 2>&1 || die "Cannot find stg. Is stgit installed?"
|
2017-12-08 04:31:26 +00:00
|
|
|
|
|
|
|
last_ancestor_commit=`cat _git_upstream_commit`
|
2018-07-25 21:35:59 +00:00
|
|
|
|
2017-12-08 04:31:26 +00:00
|
|
|
cd $1
|
2018-07-25 21:35:59 +00:00
|
|
|
|
|
|
|
git name-rev $last_ancestor_commit
|
|
|
|
test $? -eq 0 || die "Could not find $last_ancestor_commit in the repository $1. Did you run 'git fetch'?"
|
|
|
|
|
2020-06-05 22:45:45 +00:00
|
|
|
f=`cd .. && pwd`
|
2020-06-09 14:54:16 +00:00
|
|
|
|
|
|
|
# Create a branch for the checkout if using stgit; use the distro name in
|
|
|
|
# the name of this branch.
|
|
|
|
if (($uncommit)); then
|
|
|
|
name=devel-`basename $f`
|
|
|
|
branch="-b $name"
|
|
|
|
else
|
|
|
|
branch=""
|
|
|
|
fi
|
|
|
|
git checkout $branch $last_ancestor_commit
|
|
|
|
|
2020-06-05 22:45:45 +00:00
|
|
|
echo "Applying patches..."
|
2017-12-08 04:31:26 +00:00
|
|
|
for p in `cat ../_patch_order` ; do
|
|
|
|
git am ../$p
|
2018-07-25 21:35:59 +00:00
|
|
|
test $? -eq 0 || die "Could not apply patch '$p'."
|
2017-12-08 04:31:26 +00:00
|
|
|
done
|
2020-06-05 22:45:45 +00:00
|
|
|
|
|
|
|
if (($uncommit)); then
|
|
|
|
echo "Uncommitting patches..."
|
|
|
|
stg init
|
|
|
|
stg uncommit -t $last_ancestor_commit -x
|
|
|
|
fi
|