Skip to content

Instantly share code, notes, and snippets.

@hackaugusto
Created June 29, 2012 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackaugusto/3018291 to your computer and use it in GitHub Desktop.
Save hackaugusto/3018291 to your computer and use it in GitHub Desktop.
PKGBUILD for depot_tools
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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment