]> git.pld-linux.org Git - packages/apache-mod_pagespeed.git/blame - get-source.sh
update get-source script to use git
[packages/apache-mod_pagespeed.git] / get-source.sh
CommitLineData
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 11package=modpagespeed
451521e8 12repo_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)
15version=latest-stable
757b3ba5 16spec=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
18depth=
17e08f85 19force=0
757b3ba5
ER
20
21# abort on errors
22set -e
757b3ba5 23# work in package dir
81c4dc24 24dir=$(readlink -f $(dirname "$0"))
757b3ba5
ER
25cd "$dir"
26
17e08f85
ER
27if [[ "$1" = *force ]]; then
28 force=1
29 shift
30fi
31
40de8a4b
ER
32if [ "$1" ]; then
33 version=$1
34fi
35
451521e8
ER
36export GIT_DIR=$package/src/.git
37
38# refs to fetch: master and latest-stable
39refs="refs/heads/master:refs/remotes/origin/master refs/heads/latest-stable:refs/remotes/origin/latest-stable"
40de8a4b 40
451521e8
ER
41if [ ! -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 47else
451521e8 48 git fetch origin $refs
757b3ba5 49fi
451521e8
ER
50unset GIT_DIR
51
52cd $package/src
53git checkout $version
54
55version=$(git describe --tags)
56echo "Version: $version"
757b3ba5 57
5bdfa704 58release_dir=$package-$version
451521e8 59tarball=$dir/$release_dir.tar.xz
5bdfa704 60
17e08f85 61if [ -f $tarball -a $force != 1 ]; then
a8c42333
ER
62 echo "Tarball $tarball already exists"
63 exit 0
64fi
65
ef0f87bf
ER
66# gclient needs python 2.6
67if python -c "import sys; sys.exit(sys.version[:3] > '2.6')"; then
68 echo >&2 "Need python >= 2.6 for gclient"
69 exit 1
70fi
71
fbe26cab
ER
72gclient=$(which gclient 2>/dev/null)
73if [ -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 83fi
757b3ba5 84
451521e8
ER
85gclientfile=$dir/gclient.conf
86cd $dir/$package
757b3ba5 87
fbe26cab 88if [ ! -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
91fi
92
fbe26cab 93cp -p $gclientfile .gclient
7c93b354 94
17e08f85 95# emulate gclient config, preserving our deps
451521e8 96sed -i -re '/"url"/ s,"http[^"]+","'$repo_url'",' .gclient
17e08f85 97
fbe26cab 98$gclient sync --nohooks -v
757b3ba5 99
92bbc644
ER
100cd src
101
81c4dc24 102sh -x $dir/clean-source.sh
5eafce75 103
757b3ba5 104# Populate the LASTCHANGE file template as we will not include VCS info in tarball
92bbc644
ER
105./build/lastchange.sh . -o LASTCHANGE.in
106
107cd ../..
757b3ba5 108
563e8b85
ER
109XZ_OPT=-e9 \
110tar --transform="s:^$package/src:$release_dir:" \
111 -caf $tarball --exclude-vcs $package/src
5bdfa704 112
757b3ba5
ER
113../md5 $spec
114../dropin $tarball &
This page took 0.973845 seconds and 4 git commands to generate.