]> git.pld-linux.org Git - packages/apache-mod_pagespeed.git/blob - get-source.sh
7ce1a4d99e0f67a97189e789b9c395f9b1365903
[packages/apache-mod_pagespeed.git] / get-source.sh
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
9 package=modpagespeed
10 baseurl=http://modpagespeed.googlecode.com/svn
11 # leave empty to use latest tag, or "trunk" for trunk
12 version=
13 spec=apache-mod_pagespeed.spec
14 force=0
15
16 # There are directories we want to strip, but that are unnecessarily required by the build-system
17 # So we drop everything but the gyp/gypi files
18 almost_strip_dirs() {
19         for dir in "$@"; do
20                 find $dir -depth -mindepth 1 '!' '(' -name '*.gyp' -o -name '*.gypi' ')' -print -delete || :
21         done
22 }
23
24 # abort on errors
25 set -e
26 # work in package dir
27 dir=$(dirname "$0")
28 cd "$dir"
29
30 if [[ "$1" = *force ]]; then
31         force=1
32         shift
33 fi
34
35 if [ "$1" ]; then
36         version=$1
37 fi
38
39 if [ -z "$version" ]; then
40         echo "Looking for latest version..."
41         version=$(svn ls $baseurl/tags/ | grep '^[0-9]' | sort -V | tail -n1)
42         version=${version%/}
43 fi
44
45 if [ "$version" = "trunk" ]; then
46         echo "Using trunk"
47         svnurl=$baseurl/trunk/src
48         version=$(date +%Y%m%d)
49 else
50         echo "Version: $version"
51         svnurl=$baseurl/tags/$version/src
52 fi
53
54 release_dir=$package-$version
55 tarball=$release_dir.tar.xz
56
57 if [ -f $tarball -a $force != 1 ]; then
58         echo "Tarball $tarball already exists"
59         exit 0
60 fi
61
62 # gclient needs python 2.6
63 if python -c "import sys; sys.exit(sys.version[:3] > '2.6')"; then
64         echo >&2 "Need python >= 2.6 for gclient"
65         exit 1
66 fi
67
68 gclient=$(which gclient 2>/dev/null)
69 if [ -z "$gclient" ]; then
70         # http://www.chromium.org/developers/how-tos/install-depot-tools
71         test -d depot_tools || {
72                 # could also checkout:
73                 # svn co http://src.chromium.org/svn/trunk/tools/depot_tools
74                 wget -c https://src.chromium.org/svn/trunk/tools/depot_tools.zip
75                 unzip -qq depot_tools.zip
76                 chmod a+x depot_tools/gclient depot_tools/update_depot_tools
77         }
78         gclient=$topdir/depot_tools/gclient
79 fi
80
81 topdir=${PWD:-($pwd)}
82 gclientfile=$topdir/gclient.conf
83 install -d $package
84 cd $package
85
86 if [ ! -f $gclientfile ]; then
87         # create initial config that can be later modified
88         $gclient config $svnurl --gclientfile=$gclientfile
89 fi
90
91 cp -p $gclientfile .gclient
92
93 # emulate gclient config, preserving our deps
94 sed -i -re '/"url"/ s,"http[^"]+","'$svnurl'",' .gclient
95
96 $gclient sync --nohooks -v
97
98 cd src
99
100 # clean sources, but preserve .gyp, .gypi
101 almost_strip_dirs \
102         third_party/apr/ \
103         third_party/httpd/ \
104         third_party/httpd24/ \
105         third_party/instaweb/ \
106         third_party/openssl/ \
107
108 # Populate the LASTCHANGE file template as we will not include VCS info in tarball
109 ./build/lastchange.sh . -o LASTCHANGE.in
110
111 cd ../..
112
113 XZ_OPT=-e9 \
114 tar --transform="s:^$package/src:$release_dir:" \
115         -caf $tarball --exclude-vcs $package/src
116
117 ../md5 $spec
118 ../dropin $tarball &
This page took 0.031938 seconds and 2 git commands to generate.