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
15set -e
16
17release=""
18rc=""
19
20base_url="https://llvm.org/svn/llvm-project"
21
22function usage() {
23    echo "usage: `basename $0` -release <num>"
24    echo "usage: `basename $0` -release <num> -rc <num>"
25    echo " "
26    echo "  -release <num>  The version number of the release"
27    echo "  -rc <num>       The release candidate number"
28}
29
30function tag_version() {
31    set -x
32    for proj in llvm cfe dragonegg test-suite compiler-rt libcxx libcxxabi ; do
33        if ! svn ls $base_url/$proj/branches/release_$release > /dev/null 2>&1 ; then
34            svn copy -m "Creating release_$release branch" \
35                $base_url/$proj/trunk \
36                $base_url/$proj/branches/release_$release
37        fi
38    done
39    set +x
40}
41
42function tag_release_candidate() {
43    set -x
44    for proj in llvm cfe dragonegg test-suite compiler-rt libcxx libcxxabi ; do
45        if ! svn ls $base_url/$proj/tags/RELEASE_$release > /dev/null 2>&1 ; then
46            svn mkdir -m "Creating release directory for release_$release." $base_url/$proj/tags/RELEASE_$release
47        fi
48        if ! svn ls $base_url/$proj/tags/RELEASE_$release/rc$rc > /dev/null 2>&1 ; then
49            svn copy -m "Creating release candidate $rc from release_$release branch" \
50                $base_url/$proj/branches/release_$release \
51                $base_url/$proj/tags/RELEASE_$release/rc$rc
52        fi
53    done
54    set +x
55}
56
57while [ $# -gt 0 ]; do
58    case $1 in
59        -release | --release )
60            shift
61            release=$1
62            ;;
63        -rc | --rc )
64            shift
65            rc=$1
66            ;;
67        -h | --help | -help )
68            usage
69            exit 0
70            ;;
71        * )
72            echo "unknown option: $1"
73            usage
74            exit 1
75            ;;
76    esac
77    shift
78done
79
80if [ "x$release" = "x" ]; then
81    echo "error: need to specify a release version"
82    echo
83    usage
84    exit 1
85fi
86
87release=`echo $release | sed -e 's,\.,,g'`
88
89if [ "x$rc" = "x" ]; then
90    tag_version
91else
92    tag_release_candidate
93fi
94
95exit 1
96