Revert r245355 "Release script: correctly symlink clang-tools-extra into the build...
[oota-llvm.git] / utils / release / tag.sh
1 #!/bin/sh
2 #===-- tag.sh - Tag the LLVM release candidates ----------------------------===#
3 #
4 #                     The LLVM Compiler Infrastructure
5 #
6 # This file is distributed under the University of Illinois Open Source
7 # License.
8 #
9 #===------------------------------------------------------------------------===#
10 #
11 # Create branches and release candidates for the LLVM release.
12 #
13 #===------------------------------------------------------------------------===#
14
15 set -e
16
17 release=""
18 rc=""
19 rebranch="no"
20 projects="llvm cfe test-suite compiler-rt libcxx libcxxabi clang-tools-extra polly lldb lld openmp libunwind"
21 dryrun=""
22 revision="HEAD"
23
24 base_url="https://llvm.org/svn/llvm-project"
25
26 function usage() {
27     echo "usage: `basename $0` -release <num> [-rebranch] [-revision <num>] [-dry-run]"
28     echo "usage: `basename $0` -release <num> -rc <num> [-dry-run]"
29     echo " "
30     echo "  -release <num>   The version number of the release"
31     echo "  -rc <num>        The release candidate number"
32     echo "  -rebranch        Remove existing branch, if present, before branching"
33     echo "  -final           Tag final release candidate"
34     echo "  -revision <num>  Revision to branch off (default: HEAD)"
35     echo "  -dry-run         Make no changes to the repository, just print the commands"
36 }
37
38 function tag_version() {
39     set -x
40     for proj in  $projects; do
41         if svn ls $base_url/$proj/branches/release_$branch_release > /dev/null 2>&1 ; then
42             if [ $rebranch = "no" ]; then
43                 continue
44             fi
45             ${dryrun} svn remove -m "Removing old release_$branch_release branch for rebranching." \
46                 $base_url/$proj/branches/release_$branch_release
47         fi
48         ${dryrun} svn copy -m "Creating release_$branch_release branch off revision ${revision}" \
49             -r ${revision} \
50             $base_url/$proj/trunk \
51             $base_url/$proj/branches/release_$branch_release
52     done
53     set +x
54 }
55
56 function tag_release_candidate() {
57     set -x
58     for proj in $projects ; do
59         if ! svn ls $base_url/$proj/tags/RELEASE_$tag_release > /dev/null 2>&1 ; then
60             ${dryrun} svn mkdir -m "Creating release directory for release_$tag_release." $base_url/$proj/tags/RELEASE_$tag_release
61         fi
62         if ! svn ls $base_url/$proj/tags/RELEASE_$tag_release/$rc > /dev/null 2>&1 ; then
63             ${dryrun} svn copy -m "Creating release candidate $rc from release_$tag_release branch" \
64                 $base_url/$proj/branches/release_$branch_release \
65                 $base_url/$proj/tags/RELEASE_$tag_release/$rc
66         fi
67     done
68     set +x
69 }
70
71 while [ $# -gt 0 ]; do
72     case $1 in
73         -release | --release )
74             shift
75             release=$1
76             ;;
77         -rc | --rc )
78             shift
79             rc="rc$1"
80             ;;
81         -rebranch | --rebranch )
82             rebranch="yes"
83             ;;
84         -final | --final )
85             rc="final"
86             ;;
87         -revision | --revision )
88             shift
89             revision="$1"
90             ;;
91         -dry-run | --dry-run )
92             dryrun="echo"
93             ;;
94         -h | --help | -help )
95             usage
96             exit 0
97             ;;
98         * )
99             echo "unknown option: $1"
100             usage
101             exit 1
102             ;;
103     esac
104     shift
105 done
106
107 if [ "x$release" = "x" ]; then
108     echo "error: need to specify a release version"
109     echo
110     usage
111     exit 1
112 fi
113
114 branch_release=`echo $release | sed -e 's,\([0-9]*\.[0-9]*\).*,\1,' | sed -e 's,\.,,g'`
115 tag_release=`echo $release | sed -e 's,\.,,g'`
116
117 if [ "x$rc" = "x" ]; then
118     tag_version
119 else
120     if [ "$revision" != "HEAD" ]; then
121         echo "error: cannot use -revision with -rc"
122         echo
123         usage
124         exit 1
125     fi
126
127     tag_release_candidate
128 fi
129
130 exit 0