1#!/bin/sh
2#set -x
3
4# Prepares a patch for the patch tester.
5# Copyright (C) 2007  Free Software Foundation, Inc.
6# Contributed by Sebastian Pop <sebastian.pop@amd.com>
7
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 3 of the License, or
11# (at your option) any later version.
12
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
22usage() {
23    cat <<EOF
24prepare_patch.sh <source_dir> [patches_dir]
25
26    SOURCE_DIR is the directory containing GCC's toplevel configure.
27
28    PATCHES_DIR is the directory where the patch will be copied to.
29    Default is SOURCE_DIR/patches.
30
31EOF
32    exit 1
33}
34
35test $# -eq 0 && usage
36
37SOURCE=$1
38PATCHES=
39
40if [[ "$#" < 2 ]]; then
41    PATCHES=$SOURCE/patches
42else
43    PATCHES=$2
44fi
45
46[ -f $SOURCE/config.guess ] || usage
47[ -d $PATCHES ] || mkdir -p $PATCHES
48
49echo "Enter a name for this patch: "
50read name
51PATCH=$PATCHES/`TZ=UTC date +"%Y_%m_%d_%H_%M_%S"`_$name.diff
52
53echo "Enter the email where the report should be sent: "
54read email
55echo "email:$email" >> $PATCH
56
57branch=`svn info $SOURCE | grep URL: | sed -e "s/^URL: //g"`
58echo "Enter svn branch (svn info in $SOURCE reports $branch, default is trunk): "
59read svn_branch
60if [ x$svn_branch = x ]; then
61    svn_branch=trunk
62fi
63echo "branch:$svn_branch" >> $PATCH
64
65revision=`svn info $SOURCE | grep Revision: | sed -e "s/^Revision: //g"`
66echo "Enter svn revision (svn info in $SOURCE reports $revision, default is HEAD): "
67read svn_revision
68if [ x$svn_revision = x ]; then
69    svn_revision=HEAD
70fi
71echo "revision:$svn_revision" >> $PATCH
72
73echo "Enter configure options: "
74read configure_options
75echo "configure:$configure_options" >> $PATCH
76
77echo "Enter make options: "
78read make_options
79echo "make:$make_options" >> $PATCH
80
81echo "Enter make check options: "
82read check_options
83echo "check:$check_options" >> $PATCH
84
85echo "" >> $PATCH
86
87svn diff $SOURCE | tee -a $PATCH
88
89cat <<EOF
90
91You can now edit your patch, include a ChangeLog, and before
92submitting to the patch tester, don't forget to sign it with:
93
94  gpg --clearsign $PATCH
95
96EOF
97