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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
#!/bin/bash
# Style
NC='\e[0m'
red='\e[0;31m'
blue='\e[1;34m'
green='\e[0;32m'
bold='\e[1m'
italic='\e[3m'
lines="$(perl -E 'say "-" x 80')"
EDITOR="${EDITOR:-vim}"
# ==============================================================================
# Usage and Help
# ==============================================================================
usage() {
# Format this section with 75 columns.
cat << EOF
${release_script} [-a FILE] [-b BRANCH] [-d DATE] [-h] [-e REMOTE] -n
[-r [RC] [SPIN]] [-R [SPIN]] [-S [SPIN]] [-t TAG] [-u]
EOF
return 0
}
extended_usage() {
echo -e "${bold}Usage:${NC}"
usage;
print_info "Run \"${release_script} -help\" for detailed usage information."
}
help()
{
# Format this section of text with 75 columns.
#cat << EOF
echo -e "\
${bold}NAME${NC}
${release_script} - The Linaro GCC snapshot, and release script.
${bold}SYNOPSIS${NC}"
usage
echo -e "\
${bold}DESCRIPTION${NC}"
echo -e "\
\"${release_script}\" is a utility that is used to create tarballs
and branches for Linaro toolchain GCC monthly snapshots, quarterly
releases.
By default ${release_script} creates a snapshot tarball, branch,
and tag.
${bold}PRECONDITIONS${NC}
${release_script} needs to be executed in the top-level GCC source
directory.
The GCC source directory must be a git repository. This script will
not work on a GCC source tarball or a GCC SVN repository.
The GCC source git repository must have the branch that the release or
snapshot will based on currently checked out.
${bold}OPTIONS${NC}"
cat << EOF
-a FILE
FILE is the path to the optional amend file to pass to
gitlog-to-changelog. For more information on how to use
this feature please run gitlog-to-changelog --help.
-b BRANCH
Derive (track) the snapshot, release, or release candidate
from branch BRANCH. The default is to use the existing
branch. Using -t with -b is not allowed since -t and -b
are both aliases for a single commit.
-d DATE
Create DATE snapshot or release. The DATE may be in the
following formats: YYYY.MM, YYYY-MM, YYYY/MM, YYYY.MM.DD,
YYYY-MM-DD, YYYY/MM/DD. The Default is the current date.
-e REMOTE
This specifies the remote (as REMOTE) to use when
outputting the push instructions. NOTE: This script does
not actually push to the remotes.
It is necessary to designate an alternate FSF remote in
order to push tags and gcc/LINARO-VERSION updates to the
upstream branches for snapshots.
-h
Print this extended help text.
-n
No build. Skip the 'build' stage.
-R [SPIN]
This tells ${release_script} to create a release tarball,
branch and tag with an optional spin number SPIN. By
default no SPIN number is used. SPIN must be > 0 if
specified.
-S [SPIN]
[Default] This explicitly tells ${release_script} to create
a snapshot tarball, branch, and tag with an optional spin
number SPIN. By default no SPIN number is used. SPIN must
be > 0 if specified.
-r [RC] [SPIN]
This tells ${release_script} to create a release candidate
tarball, branch and tag with an optional release candidate
number RC and an optional spin number SPIN. By default RC
number '1' is used and SPIN is left blank/off. RC must be
>= 1. SPIN must be >= 1 if used. This option will append
"[-SPIN]-rcRC" on the end of the release string.
Note: If you want to specify a SPIN you MUST specify an RC
argument as well or ${release_script} will make the first
argument the RC value.
-t TAG
Derive (track) the snapshot, release, or release candidate
from tag TAG. The default is to use the existing branch
and not use a TAG. Using -t with -b is not allowed since
-t and -b are both aliases for a single commit.
-u
EOF
echo -e "\
Print the short form usage text. See '${bold}SYNOPSIS${NC}' above.
${bold}EXAMPLES${NC}
${bold}Snapshot Examples:
${bold}Implicit Snapshot Based on Current Branch:${NC}
${release_script}
${bold}Explicit Snapshot Based on Current Branch With Today's Date:${NC}
${release_script} -S
${bold}Snapshot Based on Current Branch With Commit Message Fixup With
Today's Date:${NC}
${release_script} -S \\
-a <path-to>/tcwg-release-tools/gitlog-amend-gcc-5
${bold}Snapshot Based on Linaro GCC 5 Branch With Today's Date:${NC}
${release_script} -S -b remotes/origin/linaro/gcc-5-branch
${bold}Respin Snapshot Based On A Snapshot Branch And An Explicit Date:${NC}
${release_script} -S 1 -d 2015.06 \\
-b remotes/origin/linaro-local/snapshots/linaro-5.1-2015.06
${bold}Release Candidate Examples:
${bold}Release Candidate With Implicit Spin Number Based On A Snapshot
Branch And An Explicit Date:${NC}
${release_script} -d 2015.06 \\
-b remotes/origin/linaro-local/snapshots/linaro-5.1-2015.06
${bold}Release Candidate Based On A Snapshot Branch And An Explicit Date:${NC}
${release_script} -r 1 -d 2015.06 \\
-b remotes/origin/linaro-local/snapshots/linaro-5.1-2015.06
${bold}Release Candidate Respin Based On The Release Branch With An
Explicit Date:${NC}
${release_script} -r 2 -d 2015.06 \\
-b remotes/origin/linaro-local/releases/linaro-5.1-2015.06
${bold}Release Examples:
${bold}Release Based on Current Branch With Today's Date:${NC}
${release_script} -R
${bold}Release Based on Release Branch With An Explicit Date:${NC}
${release_script} -R -d 2015.05 \\
-b remotes/origin/linaro-local/releases/linaro-5.1-2015.06
${bold}Release Respin Based on Release Branch With An Explicit Date:${NC}
${release_script} -R 1 -d 2015.05 \\
-b remotes/origin/linaro-local/releases/linaro-5.1-2015.06
${bold}AUTHORS${NC}
${release_script} was written by:
Yvan Roux <yvan.roux@linaro.org>
Christophe Lyon <christophe.lyon@linaro.org>
Ryan S Arnold <ryan.arnold@linaro.org>
"
return 0
}
# ==============================================================================
# Functions
# ==============================================================================
print_step() {
echo -e "${blue}${lines}\n${red}** ${1}\n${blue}${lines}${NC}\n"
}
print_info() {
echo -e "${blue}** ${NC}${1}${NC}"
}
clean() {
# This will bring us back to the starting directory even if we're already
# there.
popd &>/dev/null
ask "May I remove ${REL_DIR}/git [N/y] ?" user_ok
if [ "$user_ok" = "y" ]; then
if [ -d "$REL_DIR/git" ]; then
rm -rf $REL_DIR/git
if [ $? -eq 0 ]; then
print_info "Removed ${REL_DIR}/git"
fi
fi
fi
git_out=""
# check to see if the local_branch has been created.
git rev-parse --verify ${local_branch} &>/dev/null
if [ $? -eq 0 ]; then
ask "May I remove the local branch named \"${local_branch}\" as part of the cleanup process [N/y] ?" user_ok
if [ "$user_ok" = "y" ]; then
git_out=$(git branch -D ${local_branch})
print_info "${git_out}"
fi
fi
if [ "${SNAPSHOT:+set}" = "set" ]; then
# check to see if the local_int_branch has been created.
git rev-parse --verify ${local_int_branch} &>/dev/null
if [ $? -eq 0 ]; then
ask "May I remove the local integration branch named \"${local_int_branch}\" as part of the cleanup process [N/y] ?" user_ok
if [ "$user_ok" = "y" ]; then
git_out=$(git branch -D ${local_int_branch})
print_info "${git_out}"
fi
fi
fi
# If there is a tag created/associated with this release then it should be
# removed as well.
if [ x"$(git tag -l ${release_tag})" != x ]; then
ask "May I remove the local tag named \"${release_tag}\" as part of the cleanup process [N/y] ?" user_ok
if [ "$user_ok" = "y" ]; then
git_out=$(git tag -d ${release_tag})
print_info "${git_out}"
fi
fi
}
clean_and_die() {
echo -e "${red}${bold}ERROR: ${NC}${bold}${1}${NC}"
clean
exit 1
}
die() {
echo -e "${red}${bold}ERROR: ${NC}${bold}${1}${NC}"
exit 1
}
handle_ctrl_c() {
clean_and_die "User hit ctrl-c. Operation aborted."
}
# arg1: a date in any format
# print a sanitized version of the date, or the error
# as generated by `date` if the input is invalid. The
# return value is non-zero if there's an error.
sanitize_input_date() {
local in_date="$1"
in_date=${in_date//./-}
# If the in_date doesn't include the 'day' add it on
# because `date` expects it.
[[ ${#in_date} -lt 8 ]] && { in_date="${in_date}-01"; }
local sanitized_date=
sanitized_date="$(date -d ${in_date} +%Y-%m-%d 2>&1)"
ret=$?
echo "${sanitized_date}"
return $ret;
}
# arg1 : a sentence
# arg2 : a variable
# print arg1 and gather user input in arg2
ask() {
echo -n -e "${blue}** ${NC}${bold}${1} ${NC}"
eval "read ${2}"
}
changelog() {
echo "${SNAPSHOT:+Snapshot }${release}" > $REL_DIR/git/gcc/LINARO-VERSION
for cl in $(find $REL_DIR/git -name 'ChangeLog.linaro'); do
if [ x"$cl" = x"$REL_DIR/git/gcc/ChangeLog.linaro" ]; then
cat - $cl > $cl.new <<EOF
$today $NAME <$EMAIL>
$chglmsg
* LINARO-VERSION: Update.
EOF
else
cat - $cl > $cl.new <<EOF
$today $NAME <$EMAIL>
$chglmsg
EOF
fi
mv $cl.new $cl
done
pushd $REL_DIR/git 1>/dev/null
if [ ${vstring%%.*} -ge "5" ]; then
git commit -a -F- <<EOF
${commitmsg}
gcc/
* LINARO-VERSION: Update.
EOF
else
git commit -a -m "${commitmsg}"
fi
popd 1>/dev/null
}
bump_and_dev() {
local bump_to="$1"
echo "${bump_to}" > $REL_DIR/git/gcc/LINARO-VERSION
pushd $REL_DIR/git 1>/dev/null
git commit -q -a -F- <<EOF
gcc/
* LINARO-VERSION: Bump version number, post ${SNAPSHOT:+snapshot}${RELEASE:+release}${CANDIDATE:+release candidate}.
EOF
print_info "${bold}Bumped gcc/LINARO-VERSION to ${bump_to} in $(git rev-parse --abbrev-ref HEAD)"
popd 1>/dev/null
}
export_source() {
pushd $REL_DIR/git 1>/dev/null
git checkout-index -f -a --prefix=$REL_DIR/gcc-linaro-${rname}/
popd 1>/dev/null
}
build() {
pushd $REL_DIR/gcc-linaro-${rname} 1>/dev/null
env SOURCEDIR="$PWD/gcc/doc" DESTDIR="$PWD/INSTALL" ./gcc/doc/install.texi2html
env MAKE="make -j4" contrib/gcc_build -d $REL_DIR/gcc-linaro-${rname} \
-o $REL_DIR/objdir -c \
"--enable-generated-files-in-srcdir --disable-multilib" build
mv -v $REL_DIR/objdir/gcc/po/*.gmo $REL_DIR/gcc-linaro-${rname}/gcc/po/
popd 1>/dev/null
}
md5() {
pushd $REL_DIR/gcc-linaro-${rname} 1>/dev/null
cat - >MD5SUMS <<EOF
# This file contains the MD5 checksums of the files in the
# gcc-linaro-${rname}.tar.xz tarball.
#
# Besides verifying that all files in the tarball were correctly expanded,
# it also can be used to determine if any files have changed since the
# tarball was expanded or to verify that a patchfile was correctly applied.
#
# Suggested usage:
# md5sum -c MD5SUMS | grep -v "OK$"
EOF
find . -type f | sed -e 's:^\./::' -e '/MD5SUMS/d' | LC_ALL=C sort | xargs md5sum >>MD5SUMS
popd 1>/dev/null
}
tag() {
git tag -a ${release_tag} -m "${tagmsg}"
if [ $? != 0 ]; then
clean_and_die "Creation of git tag ${release_tag} failed."
fi
# Query the git repo for the tag as a sanity step.
print_info "${bold}Created tag \"${red}$(git tag -l ${release_tag})${NC}${bold}\" with tag message \"${red}${tagmsg}${NC}${bold}\""
ask "Does this look right [N/y] ?" user_ok
if [ "$user_ok" != "y" ]; then
clean
exit 1
fi
}
info() {
print_info "${bold}${italic}You are about to create ${SNAPSHOT:+snapshot }${RELEASE:+release }${CANDIDATE:+release candidate }${red}${rname}"
print_info "${bold}+--------------------------------------------------------------------------------"
print_info "${bold}+ Tracking remote ${BRANCH:+branch}${TAG:+tag}:"
print_info "${bold}| ${red}${track}"
print_info "${bold}+ With new local branch:"
print_info "${bold}| ${red}${local_branch}"
print_info "${bold}+ The ${RELEASE:+release}${SNAPSHOT:+snapshot}${CANDIDATE:+release candidate} will be tagged as:"
print_info "${bold}| ${red}${release_tag}"
print_info "${bold}+ The local branch has gcc/LINARO-VERSION set:"
print_info "${bold}| ${italic}to: ${red}$(git show ${track}:gcc/LINARO-VERSION)"
print_info "${bold}+ For the ${SNAPSHOT:+snapshot}${RELEASE:+release}${CANDIDATE:+release candidate} gcc/LINARO-VERSION will be set:"
print_info "${bold}| ${italic}to: ${red}${SNAPSHOT:+Snapshot }${release}"
print_info "${bold}+ The gcc/LINARO-VERSION will be bumped:"
print_info "${bold}| ${italic}to: ${red}${bump_mode_to}"
print_info "${bold}+ The local branch should be pushed to:"
print_info "${bold}| ${red}${remote_mode_branch}"
if [ "${SNAPSHOT:+set}" = "set" ]; then
print_info "${bold}| +-----------------------------------------------------------------------------"
print_info "${bold}| + The local integration branch is:"
print_info "${bold}| | ${red}${local_int_branch}"
print_info "${bold}| + The local integration branch will have gcc/LINARO-VERSION bumped:"
print_info "${bold}| | ${italic}from: ${red}$(git show ${remote_int__branch}:gcc/LINARO-VERSION)"
print_info "${bold}| | ${italic}to: ${red}${bump_int_to}"
print_info "${bold}| + The local integration branch should be pushed to:"
print_info "${bold}| | ${red}${remote_int_branch}"
print_info "${bold}+--+-----------------------------------------------------------------------------"
else
print_info "${bold}+--------------------------------------------------------------------------------"
fi
}
hint() {
url=$(git config --get remote.${REMOTE}.url)
if [ x"${url}" = x ]; then
print_info "Couldn't determine viable url from remote \"${REMOTE}\""
fi
print_info "${bold}Push local tag ${red}${release_tag}${NC}${bold} to remote \"${REMOTE}\" with:"
print_info " git push ${url/https:\/\//ssh://git@} ${release_tag}"
print_info "${bold}local branch ${red}${local_branch}${NC}${bold} to remote \"${REMOTE}\" with:"
print_info " git push ${url/https:\/\//ssh://git@} ${local_branch}:${remote_mode_branch/remotes\/${REMOTE}/refs/heads}"
if [ "${SNAPSHOT:+set}" = "set" ]; then
print_info "${bold}local integration branch ${red}${local_int_branch}${NC}${bold} to remote \"${REMOTE}\" with:"
print_info " git push ${url/https:\/\//ssh://git@} ${local_int_branch}:${remote_int_branch/remotes\/${REMOTE}/refs/heads}"
print_info ""
print_info "${italic}${bold}Note: ${NC}${italic}Someone with FSF write permission will need to cherry-pick the remote_int_branch changes into"
print_info " refs/heads/fsf/linaro/gcc-${vstring%.*}-branch."
fi
print_info ""
print_info "${bold}The ${SNAPSHOT:+snapshot}${RELEASE:+release}${CANDIDATE:+release candidate} tarball is in:"
print_info " ${REL_DIR}/gcc-linaro-${rname}.tar.xz"
}
# ==============================================================================
# Settings
# ==============================================================================
# Clear the directory stack so a popd in clean() always returns us to the right
# place.
dirs -c
GIT_REPO="$PWD"
# Leave these unset by default!
SPIN=
RELEASE=
SNAPSHOT=
RC=
CANDIDATE=
REMOTE=
BUILD="build"
NAME="$(git config user.name)"
EMAIL="$(git config user.email)"
today="$(date +%Y-%m-%d)"
gitlog_amend=
release_script="$(basename "$0")"
# Arguments. The first colon puts getopts into silent error reporting mode
# which sets $OPTARG to the unknown option if one is encountered.
while getopts ":a:b:d:e:hnrRSt:u" options
do
case $options in
a ) gitlog_amend="--amend $OPTARG"
;;
b ) BRANCH="$OPTARG"
;;
d ) DATE=$(sanitize_input_date "$OPTARG")
if [ $? -ne 0 ]; then
# ${DATE} will contain the error message
die "${DATE}"
fi
# We only use YYYY.MM format
DATE=$(date -d "$DATE" +%Y.%m 2>&1)
;;
e ) REMOTE="$OPTARG"
;;
h ) help; exit 1;
;;
n ) unset BUILD
;;
r ) CANDIDATE=1
# If the next input is not a -option then it is an optional RC arg.
[[ ${!OPTIND} =~ ^-. ]] || { RC=${!OPTIND} ; OPTIND=$(( OPTIND + 1 )); }
# If the next input is not a -option then it is an optional SPIN
# arg.
[[ ${!OPTIND} =~ ^-. ]] || { SPIN=${!OPTIND} ; OPTIND=$(( OPTIND + 1 )); }
# The default RC for release candidates is '1'. Set it if it's
# undefined or the null string. The leading colon causes the
# variable expansion to take place without evaluating the expansion
# as a statement.
: ${RC:=1}
# SPIN is left unset if not provided by the user.
;;
R ) RELEASE=1
# If the next input is not a -option then it is an optional SPIN
# arg.
[[ ${!OPTIND} =~ ^-. ]] || { SPIN=${!OPTIND} ; OPTIND=$(( OPTIND + 1 )); }
;;
S ) SNAPSHOT=1
# If the next input is not a -option then it is an optional SPIN
# arg.
[[ ${!OPTIND} =~ ^-. ]] || { SPIN=${!OPTIND} ; OPTIND=$(( OPTIND + 1 )); }
;;
t ) TAG="$OPTARG"
;;
u ) extended_usage; exit 1;
;;
\?) print_info "Option -${BOLD}$OPTARG${NC} Unsupported."
;;
: ) extended_usage; die "Option \"-$OPTARG\" requires an argument."
;;
esac
done
if [ $# -lt 1 ]; then
extended_usage
fi
shift $(( OPTIND - 1 ))
# If DATE wasn't set by the user, set it.
: ${DATE:=$(date -d "$today" +%Y.%m)}
if [[ "${RELEASE:+rel}" = "rel" && "${SNAPSHOT:+snap}" = "snap" ]]; then
die "-R and -S can not be specified at the same time."
elif [[ "${RELEASE:+rel}" = "rel" && "${CANDIDATE:+rc}" = "rc" ]]; then
die "-R and -r can not be specified at the same time."
elif [[ "${CANDIDATE:+rc}" = "rc" && "${SNAPSHOT:+snap}" = "snap" ]]; then
die "-r and -S can not be specified at the same time."
fi
# This uses variable substitution to test if SPIN is set, and NOT the empty
# string which protects against -S "" or -R "" (which sets SPIN to the empty
# string).
if [ "${SPIN:+set}" = "set" ]; then
# Test if the user input contains anything other than numbers.
if [[ ${SPIN} =~ [^0-9] ]]; then
die "${RELEASE:+Release}${Snapshot:+Snapshot}${CANDIDATE:+Release candidate} with SPIN input \"${SPIN}\" is not a number."
elif [[ ${SPIN} -le 0 ]]; then
die "${RELEASE:+Release}${Snapshot:+Snapshot}${CANDIDATE:+Release candidate} with SPIN number '${SPIN}' must be greater than zero."
fi
fi
if [ "${RC:+set}" = "set" ]; then
# Test if the user input contains anything other than numbers.
if [[ ${RC} =~ [^0-9] ]]; then
die "Release candidate with RC input \"${RC}\" is not a number."
elif [[ ${RC} -lt 1 ]]; then
die "Release candidate with RC number '${RC}' must be greater than one."
fi
fi
# Test if the current working directory is a git directory.
if [ x"$(git rev-parse --is-inside-work-tree 2>/dev/null)" != xtrue ]; then
die "${GIT_REPO} is not a git repository."
elif [ ! -d "${GIT_REPO}/gcc" ]; then
die "${GIT_REPO} is not the top-level GCC source directory."
fi
if [[ "${TAG:+t}" = "t" && "${BRANCH:+b}" = "b" ]]; then
die "Using -t and -b together is not allowed."
fi
# Track either the BRANCH or the TAG
track="${BRANCH:+${BRANCH}}${TAG:+${TAG}}"
if [ "x${track}" = "x" ]; then
# If the user didn't specify a tracking branch, just use the current
# branch.
track="$(git rev-parse --abbrev-ref HEAD)"
# Set this because we use it to expand the "Branch" text later.
BRANCH=$track
fi
# Test to make sure the branch or tag exists
git rev-parse --abbrev-ref $track &>/dev/null || die "${TAG:+Tag }${BRANCH:+Branch }\"$track\" doesn't exist."
# If the REMOTE hasn't been specified, default to 'origin'.
: ${REMOTE:=origin}
if [[ x"$(git remote -v | grep "${REMOTE}")" = x ]]; then
die "remote ${REMOTE} is not in your git repository."
fi
# Place this here so that all info output is after all die conditions.
if [[ "${RELEASE:+rel}" != "rel" && "${SNAPSHOT:+snap}" != "snap" && "${CANDIDATE:+rc}" != "rc" ]]; then
print_info "${bold}${release_script} will default to creating a snapshot."
SNAPSHOT=1
fi
vstring=$(git show "$track":gcc/BASE-VER)
release=${vstring%.*}-"$DATE"
# Some things are only necessary when we're in snapshot mode.
if [ "${SNAPSHOT:+set}" = "set" ]; then
# The snapshot branch only gets the spin number bumped.
bump_mode_to="${release}-$(( SPIN + 1 ))~dev"
# The local integration branch only gets its DATE bumped. Ask `date` to
# figure out what the next month is. Use mid-month as a starting point to
# allow `date` to compute with accuracy.
bump_int_date="$(date -d "$(date -d "${DATE//./-}-15" +%Y-%m-%d) +1 month" +%Y.%m)"
# For next month on the integration branch there is no SPIN number.
bump_int_to="${vstring%.*}-${bump_int_date}~dev"
# Due to a change in the GCC branch naming policy, all new GCC releases
# start with a single digit release.
if [ ${vstring%%.*} -ge "5" ]; then
int_vstring=${vstring%%.*}
else
# The 4.[1-9] branches have the .[digit] in the branch name.
int_vstring=${vstring%.*}
fi
# This is the local branch where we bump the gcc/LINARO-VERSION to indicate
# the next month. We don't need ~dev in the local int branch name.
local_int_branch="snapshots/gcc-${int_vstring}-integration-branch-${bump_int_to%\~dev}"
# At the end of the script it will recommend that changes to the
# local_int_branch will be pushed to the remote_int_branch.
remote_int_branch="remotes/${REMOTE}/linaro-local/gcc-${int_vstring}-integration-branch"
elif [ "${CANDIDATE:+set}" = "set" ]; then
bump_mode_to="${release}-${SPIN}-rc$(( RC + 1 ))~dev"
else
bump_mode_to="${release}-$(( SPIN + 1 ))-rc$(( RC + 1 ))~dev"
fi
# The local branch can have the SPIN number on the name.
local_branch=${SNAPSHOT:+snapshots/}${RELEASE:+releases/}${CANDIDATE:+releases/}linaro-${release}${SPIN:+-$SPIN}${CANDIDATE:+-rc${RC}}
if [ x"${local_branch}" = x"$(git rev-parse --abbrev-ref HEAD)" ]; then
die "Local branch \"${local_branch}\" already exists and your tree is checked out in it."
fi
# Release candidates and releases always push against the future or current
# release branch. Snapshots always go into the snapshots namespace.
remote_mode_branch="remotes/${REMOTE}/linaro-local/${SNAPSHOT:+snapshots}${RELEASE:+releases}${CANDIDATE:+releases}/linaro-${release}"
# The rest of the uses of ${release} should include the SPIN number so add the
# SPIN number if it was specified.
release="${release}${SPIN:+-${SPIN}}${CANDIDATE:+-rc${RC}}"
# Differentiate between Snapshots and Releases, depending on what's set.
rname=${SNAPSHOT:+snapshot-}$release
chglmsg="GCC Linaro ${release} ${SNAPSHOT:+snapshot}${RELEASE:+release}${CANDIDATE:+release candidate}."
commitmsg="Make Linaro GCC ${SNAPSHOT:+Snapshot }${RELEASE:+Release }${CANDIDATE:+Release Candidate }${release}."
#Remove 'Make' for the front, and '.' from the back for the tag message.
tagmsg=${commitmsg#Make }
tagmsg=${tagmsg%.}
release_tag="linaro-${rname}"
REL_DIR="$PWD/../release/gcc-linaro-${rname}"
# ==============================================================================
# Prepare Sources
# ==============================================================================
# Display informational output about this run of ${release_script}.
info
# Terminal lines (minus 7 to account for interesting prior output.
terminal_lines=$(( $(tput lines) - 7 ))
ask "To see the most recent commits on the tracked ${BRANCH:+branch}${TAG:+tag} press [Enter]." user_ok
# the last ten commits should be more than enough.
git log -n 10 ${track} 2>/dev/null| head -n ${terminal_lines}
ask "Does this look OK [N/y] ?" user_ok
if [ "$user_ok" != "y" ]; then
# No need to clean here since we haven't actually done anything.
exit 1
fi
# trap ctrl-c and call the handler function. We don't need to register the
# handler until we actually need to do cleanup.
trap handle_ctrl_c INT
print_info "${bold}Creating git work dir \"${REL_DIR}/git\"..."
git-new-workdir $GIT_REPO $REL_DIR/git || die "Couldn't extract sources."
print_info "${bold}Checking out branch \"${local_branch}\"..."
pushd $REL_DIR/git 1>/dev/null
git checkout -B ${local_branch} ${track} 2>/dev/null
save_branch="$(git rev-parse --abbrev-ref HEAD)"
echo "Saved branch ${save_branch}"
popd 1>/dev/null
if [ "${SNAPSHOT:+set}" = "set" ]; then
print_info "${bold}Checking out branch \"${local_int_branch}\"..."
pushd $REL_DIR/git 1>/dev/null
git checkout -B ${local_int_branch} --track ${remote_int_branch} 1>/dev/null
# Bump the integration branch gcc/LINARO-VERSION
bump_and_dev "${bump_int_to}"
print_info "${bold}Returning to git branch \"${save_branch}\"..."
git checkout ${save_branch} 1>/dev/null
popd 1>/dev/null
fi
print_info "${bold}Creating ${SNAPSHOT:+snapshot}${RELEASE:+release}${CANDIDATE:+release candidate} ChangeLog entries..."
changelog
print_info "${bold}The following commit was made when updating the ChangeLog entries."
# Display the changes from the ChangeLog commit.
git log -n 1 ${local_branch} 2>/dev/null
# Empty line seems appropriate for visual continuity.
echo ""
ask "Does this look OK [N/y] ?" user_ok
if [ "$user_ok" != "y" ]; then
clean
exit 1
fi
tag
print_info "${bold}Exporting sources from git..."
export_source
# Generate ChangeLog.linaro from git commit messages for GCC branches >= 5
if [ ${vstring%%.*} -ge "5" ]; then
print_info "${bold}Generating ChangeLog.linaro from git commit messages..."
SINCE=$(git log --format=%ai --grep="git-svn-id" | head -n 1)
mydir="$(dirname "$(readlink -f "$0")")"
${mydir}/gitlog-to-changelog --since ${SINCE%% *} --no-cluster \
--strip-change-id --format=%B --strip-tab \
${gitlog_amend} > $REL_DIR/gcc-linaro-${rname}/ChangeLog.linaro
# Some git commit messages are not formatted correctly. Fix them manually.
ask "Please check the generated ChangeLog and update it if needed by pressing [Enter]." user_ok
$EDITOR $REL_DIR/gcc-linaro-${rname}/ChangeLog.linaro
fi
if [ "${BUILD:+set}" = "set" ]; then
print_info "${bold}Building ${release}..."
build
else
print_info "${bold}Skipping build for ${release}..."
fi
md5
pushd $REL_DIR 1>/dev/null
tar cfJ gcc-linaro-${rname}.tar.xz gcc-linaro-${rname}
popd 1>/dev/null
if [ "${SNAPSHOT:+set}" = "set" ]; then
bump_and_dev "${bump_mode_to}"
fi
hint
|