]>
Commit | Line | Data |
---|---|---|
8ccf6322 ER |
1 | #!/bin/sh |
2 | # Usage: | |
3 | # ./get-source.sh | |
4 | # Author: Elan Ruusamäe <glen@pld-linux.org> | |
5 | # | |
6 | # https://code.google.com/p/page-speed/wiki/HowToBuildNativeLibraries | |
7 | ||
8 | package=libpagespeed | |
9 | baseurl=http://page-speed.googlecode.com/svn/lib | |
10 | # leave empty to use latest tag, or "trunk" for trunk | |
11 | version= | |
12 | spec=$package.spec | |
13 | force=0 | |
14 | ||
15 | # abort on errors | |
16 | set -e | |
17 | # work in package dir | |
18 | dir=$(dirname "$0") | |
19 | cd "$dir" | |
20 | ||
21 | if [[ "$1" = *force ]]; then | |
22 | force=1 | |
23 | shift | |
24 | fi | |
25 | ||
26 | if [ "$1" ]; then | |
27 | version=$1 | |
28 | fi | |
29 | ||
30 | if [ -z "$version" ]; then | |
31 | echo "Looking for latest version..." | |
32 | version=$(svn ls $baseurl/tags/ | sort -V | tail -n1) | |
33 | version=${version%/} | |
34 | version=${version#lib-} | |
35 | ||
36 | if [ -z "$version" ]; then | |
37 | echo >&2 "Couldn't detect version from svn" | |
38 | exit 1 | |
39 | fi | |
40 | fi | |
41 | ||
42 | if [ "$version" = "trunk" ]; then | |
43 | echo "Using trunk" | |
44 | svnurl=$baseurl/trunk/src | |
45 | version=$(date +%Y%m%d) | |
46 | else | |
47 | echo "Version: $version" | |
48 | svnurl=$baseurl/tags/lib-$version/src | |
49 | fi | |
50 | ||
51 | release_dir=$package-$version | |
52 | tarball=$release_dir.tar.xz | |
53 | ||
54 | if [ -f $tarball -a $force != 1 ]; then | |
55 | echo "Tarball $tarball already exists" | |
56 | exit 0 | |
57 | fi | |
58 | ||
59 | # gclient needs python 2.6 | |
60 | if python -c "import sys; sys.exit(sys.version[:3] > '2.6')"; then | |
61 | echo >&2 "Need python >= 2.6 for gclient" | |
62 | exit 1 | |
63 | fi | |
64 | ||
8886ce2d ER |
65 | gclient=$(which gclient 2>/dev/null) |
66 | if [ -z "$gclient" ]; then | |
67 | # http://www.chromium.org/developers/how-tos/install-depot-tools | |
68 | test -d depot_tools || { | |
69 | # could also checkout: | |
70 | # svn co http://src.chromium.org/svn/trunk/tools/depot_tools | |
71 | wget -c https://src.chromium.org/svn/trunk/tools/depot_tools.zip | |
72 | unzip -qq depot_tools.zip | |
73 | chmod a+x depot_tools/gclient depot_tools/update_depot_tools | |
74 | } | |
75 | gclient=$topdir/depot_tools/gclient | |
76 | fi | |
8ccf6322 ER |
77 | |
78 | topdir=${PWD:-($pwd)} | |
8886ce2d | 79 | gclientfile=$topdir/gclient.conf |
8ccf6322 ER |
80 | install -d $package |
81 | cd $package | |
82 | ||
8886ce2d | 83 | if [ ! -f $gclientfile ]; then |
8ccf6322 | 84 | # create initial config that can be later modified |
8886ce2d | 85 | $gclient config $svnurl --gclientfile=$gclientfile |
8ccf6322 ER |
86 | fi |
87 | ||
8886ce2d | 88 | cp -p $gclientfile .gclient |
8ccf6322 ER |
89 | |
90 | # emulate gclient config, preserving our deps | |
91 | sed -i -re '/"url"/ s,"http[^"]+","'$svnurl'",' .gclient | |
92 | ||
8886ce2d | 93 | $gclient sync --nohooks -v |
8ccf6322 ER |
94 | |
95 | # Populate the LASTCHANGE file template as we will not include VCS info in tarball | |
96 | (cd src && svnversion > LASTCHANGE.in) | |
97 | cd .. | |
98 | ||
79081944 ER |
99 | XZ_OPT=-e9 \ |
100 | tar --transform="s:^$package/src:$release_dir:" \ | |
101 | -caf $tarball --exclude-vcs $package/src | |
8ccf6322 ER |
102 | |
103 | ../md5 $spec | |
104 | ../dropin $tarball & |