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
17projects="llvm cfe dragonegg test-suite compiler-rt libcxx clang-tools-extra polly lldb"
18base_url="https://llvm.org/svn/llvm-project"
19
20release=""
21rc=""
22
23function usage() {
24    echo "Export the SVN sources and build tarballs from them"
25    echo "usage: `basename $0`"
26    echo " "
27    echo "  -release <num> The version number of the release"
28    echo "  -rc <num>      The release candidate number"
29    echo "  -final         The final tag"
30}
31
32function export_sources() {
33    release_no_dot=`echo $release | sed -e 's,\.,,g'`
34    tag_dir="tags/RELEASE_$release_no_dot/$rc"
35
36    if [ "$rc" = "final" ]; then
37        rc=""
38    fi
39
40    for proj in $projects; do
41        echo "Exporting $proj ..."
42        svn export \
43            $base_url/$proj/$tag_dir \
44            $proj-$release$rc.src
45
46        echo "Creating tarball ..."
47        tar cfz $proj-$release$rc.src.tar.gz $proj-$release$rc.src
48    done
49}
50
51while [ $# -gt 0 ]; do
52    case $1 in
53        -release | --release )
54            shift
55            release=$1
56            ;;
57        -rc | --rc )
58            shift
59            rc="rc$1"
60            ;;
61        -final | --final )
62            rc="final"
63            ;;
64        -h | -help | --help )
65            usage
66            exit 0
67            ;;
68        * )
69            echo "unknown option: $1"
70            usage
71            exit 1
72            ;;
73    esac
74    shift
75done
76
77if [ "x$release" = "x" ]; then
78    echo "error: need to specify a release version"
79    exit 1
80fi
81
82export_sources
83exit 0
84