]> git.pld-linux.org Git - packages/apache-mod_pagespeed.git/blame_incremental - get-source.sh
get-source: do not trash original checkout dir with clean-source
[packages/apache-mod_pagespeed.git] / get-source.sh
... / ...
CommitLineData
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
11package=modpagespeed
12repo_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)
15version=latest-stable
16spec=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
18depth=
19force=0
20
21# abort on errors
22set -e
23# work in package dir
24dir=$(readlink -f $(dirname "$0"))
25cd "$dir"
26
27if [[ "$1" = *force ]]; then
28 force=1
29 shift
30fi
31
32if [ "$1" ]; then
33 version=$1
34fi
35
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"
40
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
47else
48 git fetch origin $refs
49fi
50unset GIT_DIR
51
52cd $package/src
53git checkout $version
54
55version=$(git describe --tags)
56echo "Version: $version"
57
58release_dir=$package-$version
59tarball=$dir/$release_dir.tar.xz
60
61if [ -f $tarball -a $force != 1 ]; then
62 echo "Tarball $tarball already exists"
63 exit 0
64fi
65
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
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 }
82 gclient=$dir/depot_tools/gclient
83fi
84
85gclientfile=$dir/gclient.conf
86cd $dir/$package
87
88if [ ! -f $gclientfile ]; then
89 # create initial config that can be later modified
90 $gclient config $repo_url --gclientfile=$gclientfile --unmanaged --name=src
91fi
92
93cp -p $gclientfile .gclient
94
95# emulate gclient config, preserving our deps
96sed -i -re '/"url"/ s,"http[^"]+","'$repo_url'",' .gclient
97
98$gclient sync --nohooks -v
99
100rm -rf $release_dir
101cp -al src $release_dir
102cd $release_dir
103
104sh -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
109cd ..
110
111XZ_OPT=-e9 \
112tar -caf $tarball --exclude-vcs $release_dir
113
114rm -rf $release_dir
115
116cd ..
117
118../md5 $spec
119../dropin $tarball &
This page took 0.049609 seconds and 4 git commands to generate.