forked from foss-for-synopsys-dwc-arc-processors/toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag-release.sh
executable file
·188 lines (148 loc) · 4.75 KB
/
tag-release.sh
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/env bash
# Copyright (C) 2012-2017 Synopsys Inc.
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
# Contributor Anton Kolesov <Anton.Kolesov@synopsys.com>
# This script is used to tag a particular release.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
# Tag all the current HEADs of releases for testing.
# Usage:
# ./tag-release.sh <tagname>
# For each repository, the branch chosen by arc-versions.sh will be tagged,
# and that branch MUST have an associated upstream.
# This does the following steps
# 1. Run arc-versions.sh to checkout the heads of all component trees
# 2. Tags all the component trees *except* toolchain.
# 3. Checks out arc-staging branch.
# 4. Merges arc-staging with -dev.
# 5. Edits arc-versions.sh so it checks out the tagged versions of all
# components.
# 6. Commits this change and tags that commit.
# At the end, the toolchain branch will be checked out on that tag. For
# ongoing development we'll need to checkout the dev branch.
# We take a simplistic view of where ARC_GNU is
d=`pwd`
cd .. > /dev/null 2>&1
ARC_GNU=`pwd`
export ARC_GNU
cd ${d} > /dev/null 2>&1
# Get the argument
if [ $# != 1 ]
then
echo "Usage: ./tag-release.sh <tagname>"
exit 1
else
tagname=$1
fi
# Default Linux directory if not already set.
if [ "x${LINUXDIR}" = "x" ]
then
if [ -d "${ARC_GNU}"/linux ]
then
LINUXDIR="${ARC_GNU}"/linux
else
echo "ERROR: Cannot find Linux sources."
exit 1
fi
fi
export LINUXDIR
# Make sure we are up to date. It is possible we are detached, so pull will
# fail, but that doesn't matter.
echo "Pulling toolchain repo"
git pull > /dev/null 2>&1 || true
# Check out heads of component trees
echo "Checking out all repos"
if ! ./arc-versions.sh
then
echo "ERROR: Failed to check out component repos."
exit 1
fi
echo "All repos checked out"
# Sanity check that each branch has a remote
for repo in binutils gcc gdb glibc newlib toolchain
do
cd ../${repo} > /dev/null 2>&1
if ! branch=`git symbolic-ref -q HEAD --short`
then
echo "ERROR: $repo is in detached head mode"
exit 1
fi
if ! remote=`git config branch.${branch}.remote`
then
echo "ERROR: branch ${branch} of ${repo} has no upstream"
exit 1
fi
cd - > /dev/null 2>&1
done
# Tag each component
for repo in binutils gcc gdb glibc newlib
do
cd ../${repo} > /dev/null 2>&1
# Special case for GDB, since we can't have two identical tags in the
# binutils-gdb repo.
# And another special case for Linux, since it is a separate product, we
# don't want it to be clear that this tag is for toolchian.
case $repo in
gdb) tag=${tagname}-gdb ;;
*) tag=$tagname
esac
if ! git tag -a -m "Create tag for $tagname release" $tag
then
echo "ERROR: Failed to tag ${repo}"
exit 1
fi
cd - > /dev/null 2>&1
done
branch=`git symbolic-ref -q HEAD --short`
# Merge with a releases branch
if ! git checkout arc-staging ; then
echo "Failed to checkout branch arc-staging"
exit 1
fi
if ! git merge $branch </dev/null ; then
echo "Failed to merge arc-staging with $branch"
exit 1
fi
# Create toolchain configuration file for release.
# For Linux and uClibc-ng just copy whatever is in the arc-dev.sh at the
# moment, because those are upstream repositories.
cat > config/$tagname.sh <<EOF
binutils=binutils:$tagname
gcc=gcc:$tagname
gdb=gdb:$tagname-gdb
glibc=glibc:$tagname
newlib=newlib:$tagname
$(grep -e uclibc=uclibc-ng config/arc-dev.sh)
$(grep -e linux=linux config/arc-dev.sh)
EOF
# Now tell arc-versions.sh to use this file instead of arc-dev:
if ! sed -i \
-e "s/^default_toolchain_config=.*$/default_toolchain_config=$tagname/" \
arc-versions.sh
then
echo "ERROR: Failed to edit arc-versions.sh"
exit 1
fi
git add config/$tagname.sh
if ! git commit -a -m "Create arc-versions.sh for tag ${tagname}"
then
echo "ERROR: Failed to commit arc-versions.sh"
exit 1
fi
# Tag the commit
if ! git tag -a -m "Create tag for $tagname release" $tagname
then
echo "ERROR: Failed to tag toolchain"
exit 1
fi
echo "All repositories tagged as ${tagname}"
# vim: noexpandtab sts=4 ts=8: