]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # Usage: | |
3 | # ./get-source.sh | |
4 | # Author: Elan Ruusamäe <glen@pld-linux.org> | |
5 | # | |
6 | # To see release notes, see this page: | |
7 | # https://developers.google.com/speed/docs/mod_pagespeed/release_notes | |
8 | # Bulding from source notes: | |
9 | # https://developers.google.com/speed/pagespeed/module/build_mod_pagespeed_from_source | |
10 | ||
11 | package=modpagespeed | |
12 | repo_url=https://github.com/pagespeed/mod_pagespeed.git | |
13 | # leave empty to use latest tag, or "trunk" for trunk | |
14 | # specific version, "latest-stable" or "master" (bleeding edge version) | |
15 | version=latest-stable | |
16 | spec=apache-mod_pagespeed.spec | |
17 | # depth to clone, do not use this as ./build/lastchange.sh uses 'git rev-list --all --count' to count revision | |
18 | depth= | |
19 | force=0 | |
20 | ||
21 | # abort on errors | |
22 | set -e | |
23 | # work in package dir | |
24 | dir=$(readlink -f $(dirname "$0")) | |
25 | cd "$dir" | |
26 | ||
27 | if [[ "$1" = *force ]]; then | |
28 | force=1 | |
29 | shift | |
30 | fi | |
31 | ||
32 | if [ "$1" ]; then | |
33 | version=$1 | |
34 | fi | |
35 | ||
36 | export GIT_DIR=$package/src/.git | |
37 | ||
38 | # refs to fetch: master and latest-stable | |
39 | refs="refs/heads/master:refs/remotes/origin/master refs/heads/latest-stable:refs/remotes/origin/latest-stable" | |
40 | ||
41 | if [ ! -d $GIT_DIR ]; then | |
42 | install -d $GIT_DIR | |
43 | # git init --bare | |
44 | git init | |
45 | git remote add origin $repo_url | |
46 | git fetch ${depth:+--depth $depth} origin $refs | |
47 | else | |
48 | git fetch origin $refs | |
49 | fi | |
50 | unset GIT_DIR | |
51 | ||
52 | cd $package/src | |
53 | git checkout $version | |
54 | ||
55 | version=$(git describe --tags) | |
56 | echo "Version: $version" | |
57 | ||
58 | release_dir=$package-$version | |
59 | tarball=$dir/$release_dir.tar.xz | |
60 | ||
61 | if [ -f $tarball -a $force != 1 ]; then | |
62 | echo "Tarball $tarball already exists" | |
63 | exit 0 | |
64 | fi | |
65 | ||
66 | # gclient needs python 2.6 | |
67 | if python -c "import sys; sys.exit(sys.version[:3] > '2.6')"; then | |
68 | echo >&2 "Need python >= 2.6 for gclient" | |
69 | exit 1 | |
70 | fi | |
71 | ||
72 | gclient=$(which gclient 2>/dev/null) | |
73 | if [ -z "$gclient" ]; then | |
74 | # http://www.chromium.org/developers/how-tos/install-depot-tools | |
75 | test -d depot_tools || { | |
76 | # could also checkout: | |
77 | # svn co http://src.chromium.org/svn/trunk/tools/depot_tools | |
78 | wget -c https://src.chromium.org/svn/trunk/tools/depot_tools.zip | |
79 | unzip -qq depot_tools.zip | |
80 | chmod a+x depot_tools/gclient depot_tools/update_depot_tools | |
81 | } | |
82 | gclient=$dir/depot_tools/gclient | |
83 | fi | |
84 | ||
85 | gclientfile=$dir/gclient.conf | |
86 | cd $dir/$package | |
87 | ||
88 | if [ ! -f $gclientfile ]; then | |
89 | # create initial config that can be later modified | |
90 | $gclient config $repo_url --gclientfile=$gclientfile --unmanaged --name=src | |
91 | fi | |
92 | ||
93 | cp -p $gclientfile .gclient | |
94 | ||
95 | # emulate gclient config, preserving our deps | |
96 | sed -i -re '/"url"/ s,"http[^"]+","'$repo_url'",' .gclient | |
97 | ||
98 | $gclient sync --nohooks -v | |
99 | ||
100 | rm -rf $release_dir | |
101 | cp -al src $release_dir | |
102 | cd $release_dir | |
103 | ||
104 | sh -x $dir/clean-source.sh | |
105 | ||
106 | # Populate the LASTCHANGE file template as we will not include VCS info in tarball | |
107 | ./build/lastchange.sh . -o LASTCHANGE.in | |
108 | ||
109 | cd .. | |
110 | ||
111 | XZ_OPT=-e9 \ | |
112 | tar -caf $tarball --exclude-vcs $release_dir | |
113 | ||
114 | rm -rf $release_dir | |
115 | ||
116 | cd .. | |
117 | ||
118 | ../md5 $spec | |
119 | ../dropin $tarball & |