public
Created

PKGBUILD for depot_tools

  • Download Gist
PKGBUILD
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
pkgname=depot_tools-svn
pkgver=144877
pkgrel=1
pkgdesc="Build tools, includes gclient"
arch=('any')
url="http://dev.chromium.org/developers/how-tos/install-depot-tools"
license=('Custom')
depends=('python2' 'python2-colorama')
makedepends=('subversion' 'scons' 'setconf')
provides=('depot' 'depot_tools' 'gclient')
conflicts=('depot' 'gclient-svn')
options=('!strip')
_svntrunk="http://src.chromium.org/svn/trunk/tools"
_svnmod=depot_tools
_pyversion="2.7"
#install='install'
 
build() {
cd "$srcdir"
TEMP="/tmp/$(basename $0).$$.tmp"
dest="$pkgdir/usr/lib/python$_pyversion/$pkgname"
 
# The MD5-sums for these keep changing, that's why they are fetched manually
wget http://src.chromium.org/viewvc/chrome/trunk/tools/depot_tools/hammer -O hammer
wget http://src.chromium.org/viewvc/chrome/trunk/tools/depot_tools/LICENSE -O LICENSE
 
if [ -d "$_svnmod/.svn" ]; then
(cd "$_svnmod" && svn up -r "$pkgver")
else
svn co "$_svntrunk/$_svnmod" --config-dir ./ -r "$pkgver" "$_svnmod"
fi
 
msg "SVN checkout done or server timeout"
cd "$_svnmod"
 
# fix python
for script in *.py
do
sed -r 's/#!(.*)python.*/#!\1python2/' $script > $TEMP
install -Dm755 $TEMP "$dest/$script" || return 1
done;
 
script=gclient.py
sed -r -e 's/#!(.*)python.*/#!\1python2/' \
-e 's/from third_party import colorama/import colorama/' \
-e 's/from third_party.colorama import Fore/from colorama import Fore/' \
$script > $TEMP
install -Dm755 $TEMP "$dest/$script" || return 1
 
mkdir $dest/python_hack
cat <<-'HEREDOC_PYTHONHACK' > $TEMP
#!/usr/bin/env sh
exec python2 $@
HEREDOC_PYTHONHACK
 
install -Dm755 $TEMP $dest/python_hack/python
 
cat <<-'HEREDOC_GCLIENTHACK' > $TEMP
#!/usr/bin/env sh
 
base_dir=$(dirname "$0")
oldpath=$PATH
export PATH=$base_dir/python_hack:$PATH
 
"$base_dir"/update_depot_tools
PYTHONDONTWRITEBYTECODE=1 exec python2 "$base_dir/gclient.py" "$@"
 
export PATH=$oldpath
HEREDOC_GCLIENTHACK
 
install -Dm755 $TEMP $dest/gclient
 
script=repo
sed -r 's/"exec" python/"exec" python2/' $script > $TEMP
install -Dm755 $TEMP "$dest/$script" || return 1
 
# install scripts
for script in {drover,gcl,git-cl,git-gs,git-try,hammer,ninja,ninja-linux64,pylint,weekly,wtf,update_depot_tools}
do
sed -r -e 's/exec python/exec python2/' \
-e 's/#!(.*)python.*/#!\1python2/' \
$script > $TEMP
install -Dm755 $TEMP "$dest/$script" || return 1
done;
 
mkdir "$dest/third_party"
mkdir "$dest/third_party/repo"
install -Dm644 third_party/__init__.py "$dest/third_party/__init__.py" || return 1
install -Dm644 third_party/upload.py "$dest/third_party/upload.py" || return 1
install -Dm644 third_party/repo/__init__.py "$dest/third_party/repo/__init__.py" || return 1
install -Dm644 third_party/repo/progress.py "$dest/third_party/repo/progress.py" || return 1
 
cp -r git_utils $dest
 
mkdir "$pkgdir/usr/bin"
for script in {gclient,repo,drover,gcl,git-cl,git-gs,git-try,hammer,ninja,ninja-linux64,pylint,weekly,wtf,update_depot_tools}
do
echo "#!/bin/sh" > $TEMP
echo "exec /usr/lib/python$_pyversion/$pkgname/$script \$@" >> $TEMP
install -Dm755 $TEMP "$pkgdir/usr/bin/${script%%.py}"
done;
 
rm $TEMP
cd "$srcdir"
 
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" || return 1
}
 
# vim:set sts=2 ts=2 sw=2 et:

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.