orig-tar.sh 6.64 KB
Newer Older
1
#!/bin/sh
2
# This script will create the following tarballs:
3 4 5
# llvm-toolchain-snapshot-3.2_3.2repack.orig-clang.tar.bz2
# llvm-toolchain-snapshot-3.2_3.2repack.orig-clang-extra.tar.bz2
# llvm-toolchain-snapshot-3.2_3.2repack.orig-compiler-rt.tar.bz2
6
# llvm-toolchain-snapshot-3.2_3.2repack.orig-lld.tar.bz2
7 8
# llvm-toolchain-snapshot-3.2_3.2repack.orig-lldb.tar.bz2
# llvm-toolchain-snapshot-3.2_3.2repack.orig-polly.tar.bz2
9
# llvm-toolchain-snapshot-3.2_3.2repack.orig-openmp.tar.bz2
10 11
# llvm-toolchain-snapshot-3.2_3.2repack.orig-libcxx.tar.bz2
# llvm-toolchain-snapshot-3.2_3.2repack.orig-libcxxabi.tar.bz2
12
# llvm-toolchain-snapshot-3.2_3.2repack.orig.tar.bz2
13

14
set -e
15

Sylvestre Ledru's avatar
Sylvestre Ledru committed
16 17 18
# TODO rest of the options

# To create an rc1 release:
19
# sh 4.0/debian/orig-tar.sh RELEASE_40 rc1
Sylvestre Ledru's avatar
Sylvestre Ledru committed
20

21
SVN_BASE_URL=https://llvm.org/svn/llvm-project/
22
MAJOR_VERSION=7
Sylvestre Ledru's avatar
Sylvestre Ledru committed
23
CURRENT_VERSION=7.1.0 # Should be changed to 3.5.1 later
24 25

if test -n "$1"; then
26
# https://llvm.org/svn/llvm-project/{cfe,llvm,compiler-rt,...}/branches/google/stable/
27
# For example: sh 4.0/debian/orig-tar.sh release_400
28 29 30
    BRANCH=$1
fi

31
if test -n "$1" -a -n "$2"; then
32
# https://llvm.org/svn/llvm-project/{cfe,llvm,compiler-rt,...}/tags/RELEASE_34/rc1/
33
# For example: sh 4.0/debian/orig-tar.sh RELEASE_401 rc3 4.0.1
34 35 36
    BRANCH=$1
    TAG=$2
    RCRELEASE="true"
37 38 39 40
    if test -z "$3"; then
        echo "Please provide the exact version. Used for the tarball name  Ex: 4.0.1"
    fi
    EXACT_VERSION=$3
41 42
fi

43 44 45
get_svn_url() {
    MODULE=$1
    BRANCH=$2
46 47 48
    TAG=$3
    if test -n "$TAG"; then
            SVN_URL="$SVN_BASE_URL/$MODULE/tags/$BRANCH/$TAG"
49
    else
50 51 52 53 54
        if test -n "$BRANCH"; then
            SVN_URL="$SVN_BASE_URL/$MODULE/branches/$BRANCH"
        else
            SVN_URL="$SVN_BASE_URL/$MODULE/trunk/"
        fi
55 56 57 58
    fi
    echo $SVN_URL
}

59
get_higher_revision() {
60
    PROJECTS="llvm cfe compiler-rt polly lld lldb clang-tools-extra"
61 62
    REVISION_MAX=0
    for f in $PROJECTS; do
63
        REVISION=$(LANG=C svn info $(get_svn_url $f $BRANCH $TAG)|grep "^Last Changed Rev:"|awk '{print $4}')
64 65 66 67 68 69 70
        if test $REVISION -gt $REVISION_MAX; then
            REVISION_MAX=$REVISION
        fi
    done
    echo $REVISION_MAX
}

71 72 73 74 75 76 77 78 79 80 81
SVN_ARCHIVES=svn-archives

checkout_sources() {
    PROJECT=$1
    URL=$2
    TARGET=$3
    BRANCH=$4
    if test -n "$BRANCH"; then
        REVISION=$5
    fi
    echo "$PROJECT / $URL / $BRANCH / $TARGET / $REVISION"
82

83 84
    cd $SVN_ARCHIVES/
    DEST=$PROJECT-$BRANCH
85 86 87
    if test -n "$TAG"; then
	DEST=$DEST-$TAG
    fi
88 89 90
    if test -d $DEST; then
        cd $DEST
        if test -n "$BRANCH"; then
91
            svn cleanup
92 93
            svn up
        else
94
            svn cleanup
95 96 97 98 99 100 101
            svn up -r $REVISION
        fi
        cd ..
    else
        if test -n "$BRANCH"; then
            svn co $URL $DEST
        else
102
            svn co -r $REVISION $URL $DEST
103 104 105 106 107 108
        fi
    fi
    rm -rf ../$TARGET
    rsync -r --exclude=.svn $DEST/ ../$TARGET
    cd ..
}
109

110
if test -n "$BRANCH"; then
111
    REVISION=$(get_higher_revision)
112 113 114 115 116 117 118 119
    # Do not use the revision when exporting branch. We consider that all the
    # branch are sync
    SVN_CMD="svn export"
else
    REVISION=$(LANG=C svn info $(get_svn_url llvm)|grep "^Revision:"|awk '{print $2}')
    SVN_CMD="svn export -r $REVISION"
fi

120
if test -n "$RCRELEASE"; then
121
    if test "$TAG" = "final"; then
122
	    VERSION=$EXACT_VERSION
123
    else
124
        VERSION=$EXACT_VERSION"~+"$TAG
125
    fi
126
    FULL_VERSION="llvm-toolchain-"$MAJOR_VERSION"_"$VERSION
127
else
Sylvestre Ledru's avatar
Sylvestre Ledru committed
128
    VERSION=$CURRENT_VERSION"~svn"$REVISION
Sylvestre Ledru's avatar
Sylvestre Ledru committed
129
    if echo $BRANCH|grep -q release_; then
130 131 132 133
	FULL_VERSION="llvm-toolchain-"$MAJOR_VERSION"_"$VERSION
    else
	FULL_VERSION="llvm-toolchain-snapshot_"$VERSION
    fi
134
fi
135

136 137
mkdir -p $SVN_ARCHIVES

138
# LLVM
139
LLVM_TARGET=$FULL_VERSION
140
checkout_sources llvm $(get_svn_url llvm $BRANCH $TAG) $LLVM_TARGET "$BRANCH" $REVISION
Sylvestre Ledru's avatar
Sylvestre Ledru committed
141
tar jcf $FULL_VERSION.orig.tar.bz2 $LLVM_TARGET
142 143
rm -rf $LLVM_TARGET

144

145
# Clang
146
CLANG_TARGET=clang_$VERSION
147
checkout_sources clang $(get_svn_url cfe $BRANCH $TAG) $CLANG_TARGET "$BRANCH" $REVISION
Sylvestre Ledru's avatar
Sylvestre Ledru committed
148
tar jcf $FULL_VERSION.orig-clang.tar.bz2 $CLANG_TARGET
149 150
rm -rf $CLANG_TARGET

151 152

# Clang extra
153
CLANG_TARGET=clang-tools-extra_$VERSION
154
checkout_sources clang-tools-extra $(get_svn_url clang-tools-extra $BRANCH $TAG) $CLANG_TARGET "$BRANCH" $REVISION
Sylvestre Ledru's avatar
Sylvestre Ledru committed
155
tar jcf $FULL_VERSION.orig-clang-tools-extra.tar.bz2 $CLANG_TARGET
156 157
rm -rf $CLANG_TARGET

158
# Compiler-rt
159
COMPILER_RT_TARGET=compiler-rt_$VERSION
160 161
checkout_sources compiler-rt $(get_svn_url compiler-rt $BRANCH $TAG) $COMPILER_RT_TARGET "$BRANCH" $REVISION
#$SVN_CMD $(get_svn_url compiler-rt $BRANCH $TAG) $COMPILER_RT_TARGET
Sylvestre Ledru's avatar
Sylvestre Ledru committed
162
tar jcf $FULL_VERSION.orig-compiler-rt.tar.bz2 $COMPILER_RT_TARGET
163 164 165
rm -rf $COMPILER_RT_TARGET

# Polly
166
POLLY_TARGET=polly_$VERSION
167 168
checkout_sources polly $(get_svn_url polly $BRANCH $TAG) $POLLY_TARGET "$BRANCH" $REVISION
#$SVN_CMD $(get_svn_url polly $BRANCH $TAG) $POLLY_TARGET
Sylvestre Ledru's avatar
Sylvestre Ledru committed
169
rm -rf $POLLY_TARGET/www $POLLY_TARGET/autoconf/config.sub $POLLY_TARGET/autoconf/config.guess
Sylvestre Ledru's avatar
Sylvestre Ledru committed
170
tar jcf $FULL_VERSION.orig-polly.tar.bz2 $POLLY_TARGET
171 172
rm -rf $POLLY_TARGET

173 174
# LLD
LLD_TARGET=lld_$VERSION
175 176
checkout_sources lld $(get_svn_url lld $BRANCH $TAG) $LLD_TARGET "$BRANCH" $REVISION
#$SVN_CMD $(get_svn_url lld $BRANCH $TAG) $LLD_TARGET
177
rm -rf $LLD_TARGET/www/
Sylvestre Ledru's avatar
Sylvestre Ledru committed
178
tar jcf $FULL_VERSION.orig-lld.tar.bz2 $LLD_TARGET
179 180
rm -rf $LLD_TARGET

181
# LLDB
182
LLDB_TARGET=lldb_$VERSION
183 184
checkout_sources lldb $(get_svn_url lldb $BRANCH $TAG) $LLDB_TARGET "$BRANCH" $REVISION
#$SVN_CMD $(get_svn_url lldb $BRANCH $TAG) $LLDB_TARGET
185
rm -rf $LLDB_TARGET/www/
Sylvestre Ledru's avatar
Sylvestre Ledru committed
186
tar jcf $FULL_VERSION.orig-lldb.tar.bz2 $LLDB_TARGET
187
rm -rf $LLDB_TARGET
188

189 190 191 192 193 194 195
# OPENMP
OPENMP_TARGET=openmp_$VERSION
checkout_sources openmp $(get_svn_url openmp $BRANCH $TAG) $OPENMP_TARGET "$BRANCH" $REVISION
rm -rf $OPENMP_TARGET/www/
tar jcf $FULL_VERSION.orig-openmp.tar.bz2 $OPENMP_TARGET
rm -rf $OPENMP_TARGET

196 197 198 199 200 201 202 203 204 205 206 207 208 209
# LIBCXX
LIBCXX_TARGET=libcxx_$VERSION
checkout_sources libcxx $(get_svn_url libcxx $BRANCH $TAG) $LIBCXX_TARGET "$BRANCH" $REVISION
rm -rf $LIBCXX_TARGET/www/
tar jcf $FULL_VERSION.orig-libcxx.tar.bz2 $LIBCXX_TARGET
rm -rf $LIBCXX_TARGET

# LIBCXXABI
LIBCXXABI_TARGET=libcxxabi_$VERSION
checkout_sources libcxxabi $(get_svn_url libcxxabi $BRANCH $TAG) $LIBCXXABI_TARGET "$BRANCH" $REVISION
rm -rf $LIBCXXABI_TARGET/www/
tar jcf $FULL_VERSION.orig-libcxxabi.tar.bz2 $LIBCXXABI_TARGET
rm -rf $LIBCXXABI_TARGET

210

211 212 213 214 215
PATH_DEBIAN="$(pwd)/$(dirname $0)/../"
echo "going into $PATH_DEBIAN"
export DEBFULLNAME="Sylvestre Ledru"
export DEBEMAIL="sylvestre@debian.org"
cd $PATH_DEBIAN
216 217 218 219

if test -z "$DISTRIBUTION"; then
    DISTRIBUTION="experimental"
fi
220

221
if test -n "$RCRELEASE" -o -n "$BRANCH"; then
222 223 224 225
    EXTRA_DCH_FLAGS="--force-bad-version --allow-lower-version"
fi

dch $EXTRA_DCH_FLAGS --distribution $DISTRIBUTION --newversion 1:$VERSION-1~exp1 "New snapshot release"
226 227

exit 0