keiths / rpms / gdb

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