summaryrefslogtreecommitdiff
path: root/tcwg-new-branch.sh
blob: 03daad5bbbb1a20d09c0813865d109f31db0ab5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash

# ==============================================================================
# Linaro new development branches script.
#
# Usage: tcwg-new-branch.sh GCC_VERSION YYYY.MM
# ==============================================================================

NC='\e[0m'
RED='\e[0;31m'
BLUE='\e[1;34m'
BOLD='\e[1m'

msg() { echo -n -e "${BLUE}** ${NC}${BOLD}$1${NC}" ; }
ask() { msg "$1 " ; eval "read $2" ; }
die() { echo -e "${RED}${BOLD}ERROR: ${NC}${BOLD}${1}${NC}" ; exit 1 ; }

usage() {
  echo -e "\
  ${BOLD}Usage:${NC}

    $(basename $0) GCC_VERSION YYYY.MM

  ${BOLD}GCC_VERSION${NC} : GCC branch major release version number.
  ${BOLD}YYYY.MM${NC}     : Date of the next snapshot.\n"
}

extended_usage() {
    echo -e "\

  ${BOLD}$(basename $0)${NC} is a utility which creates and performs the initial setup
  of Linaro development branches (main and integration) for a given GCC release
  branch.  It should be executed from the top directory of a GCC clone and needs
  autoconf2.64.\n"

    usage

    exit 0
}

[ $# -eq 0 ] && extended_usage
[ $# -ne 2 ] && usage && exit 1

GCC_VERSION=$1
DATE=$2

# Create new development branch locally
git checkout -b linaro-gcc-${GCC_VERSION}-branch origin/gcc-${GCC_VERSION}-branch

# Create Linaro version string file
echo "$GCC_VERSION.1-$DATE~dev" > gcc/LINARO-VERSION
git add gcc/LINARO-VERSION

# Add Linaro version string to configure
sed -i 's:ACX_PKGVERSION(\[GCC\]):ACX_PKGVERSION(\[Linaro GCC `cat $srcdir/LINARO-VERSION`\]):' gcc/configure.ac
pushd gcc &>/dev/null
autoconf2.64 || die "autoconf2.64 failed."
popd &>/dev/null
git add gcc/configure.ac gcc/configure

# Add Linaro release macros
git cherry-pick -n 89cce49 &>/dev/null
git add gcc/Makefile.in gcc/cppbuiltin.c
git rm gcc/ChangeLog.linaro

# Add .gitreview file
cat << EOF > .gitreview
[gerrit]
host=review.linaro.org
port=29418
project=toolchain/gcc
defaultbranch=linaro-local/gcc-${GCC_VERSION}-integration-branch
EOF
git add .gitreview

ask "To verify the modifications press [Enter]" user_ok
git diff --cached

ask "Does this look OK [N/y] ?" user_ok
if [ "$user_ok" != "y" ]; then
    exit 1
fi

# Get base revision
REV=$(git log -n 1 --format="%b" | grep "branch@")
REV=${REV##*@}
REV=${REV%% *}

# Create commit message
MSG=`cat <<EOF
Create Linaro branch from gcc-${GCC_VERSION}-branch at r${REV}.

	* .gitreview: New file.

	gcc/
	* LINARO-VERSION: New file.
	* configure.ac: Add Linaro version string.
	* configure: Regenerate.

	gcc/
	Cherry-pick from linaro/gcc-4_9-branch r217544.
	2014-11-14  Yvan Roux  <yvan.roux@linaro.org>

	Add Linaro release macros (Linaro only patch.)

	* Makefile.in (LINAROVER, LINAROVER_C, LINAROVER_S): Define.
	(CFLAGS-cppbuiltin.o): Add LINAROVER macro definition.
	(cppbuiltin.o): Depend on \\$(LINAROVER).
	* cppbuiltin.c (parse_linarover): New.
	(define_GNUC__): Define __LINARO_RELEASE__ and __LINARO_SPIN__ macros.

EOF
`
git commit -e -m "$MSG"

msg "Push the new integration branch to gerrit remote with:\n\n"
echo -e "    git push gerrit linaro-gcc-${GCC_VERSION}-branch:linaro-local/gcc-${GCC_VERSION}-integration-branch\n"

msg "Push the branch to the FSF repository (assuming FSF is the remote name) with:\n\n"
echo -e "    git push FSF linaro-gcc-${GCC_VERSION}-branch:linaro/gcc-${GCC_VERSION}-branch\n"