]>
Commit | Line | Data |
---|---|---|
757b3ba5 ER |
1 | #!/bin/sh |
2 | # Usage: | |
3 | # ./get-source.sh | |
4 | # Author: Elan Ruusamäe <glen@pld-linux.org> | |
4623c72a ER |
5 | # |
6 | # To see release notes, see this page: | |
7 | # https://developers.google.com/speed/docs/mod_pagespeed/release_notes | |
451521e8 ER |
8 | # Bulding from source notes: |
9 | # https://developers.google.com/speed/pagespeed/module/build_mod_pagespeed_from_source | |
757b3ba5 | 10 | |
5bdfa704 | 11 | package=modpagespeed |
451521e8 | 12 | repo_url=https://github.com/pagespeed/mod_pagespeed.git |
40de8a4b | 13 | # leave empty to use latest tag, or "trunk" for trunk |
451521e8 ER |
14 | # specific version, "latest-stable" or "master" (bleeding edge version) |
15 | version=latest-stable | |
757b3ba5 | 16 | spec=apache-mod_pagespeed.spec |
451521e8 ER |
17 | # depth to clone, do not use this as ./build/lastchange.sh uses 'git rev-list --all --count' to count revision |
18 | depth= | |
17e08f85 | 19 | force=0 |
757b3ba5 ER |
20 | |
21 | # abort on errors | |
22 | set -e | |
757b3ba5 | 23 | # work in package dir |
81c4dc24 | 24 | dir=$(readlink -f $(dirname "$0")) |
757b3ba5 ER |
25 | cd "$dir" |
26 | ||
17e08f85 ER |
27 | if [[ "$1" = *force ]]; then |
28 | force=1 | |
29 | shift | |
30 | fi | |
31 | ||
40de8a4b ER |
32 | if [ "$1" ]; then |
33 | version=$1 | |
34 | fi | |
35 | ||
451521e8 ER |
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" | |
40de8a4b | 40 | |
451521e8 ER |
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 | |
40de8a4b | 47 | else |
451521e8 | 48 | git fetch origin $refs |
757b3ba5 | 49 | fi |
451521e8 ER |
50 | unset GIT_DIR |
51 | ||
52 | cd $package/src | |
53 | git checkout $version | |
54 | ||
55 | version=$(git describe --tags) | |
56 | echo "Version: $version" | |
757b3ba5 | 57 | |
5bdfa704 | 58 | release_dir=$package-$version |
451521e8 | 59 | tarball=$dir/$release_dir.tar.xz |
5bdfa704 | 60 | |
17e08f85 | 61 | if [ -f $tarball -a $force != 1 ]; then |
a8c42333 ER |
62 | echo "Tarball $tarball already exists" |
63 | exit 0 | |
64 | fi | |
65 | ||
ef0f87bf ER |
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 | ||
fbe26cab ER |
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 | } | |
451521e8 | 82 | gclient=$dir/depot_tools/gclient |
fbe26cab | 83 | fi |
757b3ba5 | 84 | |
451521e8 ER |
85 | gclientfile=$dir/gclient.conf |
86 | cd $dir/$package | |
757b3ba5 | 87 | |
fbe26cab | 88 | if [ ! -f $gclientfile ]; then |
7c93b354 | 89 | # create initial config that can be later modified |
451521e8 | 90 | $gclient config $repo_url --gclientfile=$gclientfile --unmanaged --name=src |
17e08f85 ER |
91 | fi |
92 | ||
fbe26cab | 93 | cp -p $gclientfile .gclient |
7c93b354 | 94 | |
17e08f85 | 95 | # emulate gclient config, preserving our deps |
451521e8 | 96 | sed -i -re '/"url"/ s,"http[^"]+","'$repo_url'",' .gclient |
17e08f85 | 97 | |
fbe26cab | 98 | $gclient sync --nohooks -v |
757b3ba5 | 99 | |
83901331 ER |
100 | rm -rf $release_dir |
101 | cp -al src $release_dir | |
102 | cd $release_dir | |
92bbc644 | 103 | |
81c4dc24 | 104 | sh -x $dir/clean-source.sh |
5eafce75 | 105 | |
757b3ba5 | 106 | # Populate the LASTCHANGE file template as we will not include VCS info in tarball |
92bbc644 ER |
107 | ./build/lastchange.sh . -o LASTCHANGE.in |
108 | ||
83901331 | 109 | cd .. |
757b3ba5 | 110 | |
563e8b85 | 111 | XZ_OPT=-e9 \ |
83901331 ER |
112 | tar -caf $tarball --exclude-vcs $release_dir |
113 | ||
114 | rm -rf $release_dir | |
115 | ||
116 | cd .. | |
5bdfa704 | 117 | |
757b3ba5 ER |
118 | ../md5 $spec |
119 | ../dropin $tarball & |