summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6e85fe7052ed036f1d2e1baf6b54055578691b1f (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
# Maintainer: Adrian Perez <aperez@igalia.com>
# Contributor: rway <rway07@gmail.com>
# Contributor: wabi <aschrafl@jetnet.ch>
# Contributor: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Andreas Schrafl <aschrafl@gmail.com>
# Contributor: piojo <aur@zwell.net>
# Contributor: hack.augusto <hack.augusto@gmail.com>

pkgname=depot-tools-git
pkgver=r2484.c15fe57
pkgrel=1
pkgdesc='Build tools for working with Chromium development, include gclient'
arch=('any')
url='http://dev.chromium.org/developers/how-tos/install-depot-tools'
source=("${pkgname}::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git"
	'depot_tools.sh' 'repo_fix.sh')
license=('Custom')
depends=('python2' 'python2-colorama' 'python2-pylint')
makedepends=('git' 'scons' 'setconf')
provides=('depot_tools' 'gclient')
conflicts=('gclient-svn' 'depot_tools-svn')
options=('!strip')
md5sums=('SKIP'
         '39d5d3e78fa7456a1d8dd5ac10a1c8bb'
         'fb0c546a078c312aa64c1f2a31599557')
install="depot_tools.install"

scripts_to_fix=(
	apply_issue
	drover
	gcl
	git-cl
	git-gs
	git-try
	hammer
	weekly
	wtf
	update_depot_tools
	fetch
	download_from_google_storage
	gn
	clang-format
	git-runhooks
	roll-dep
)

pkgver () {
	cd "${pkgname}"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare () {
	cd "${pkgname}"

	# This tools work with python2, but ArchLinux default is python3. Fix it.
	# pylint is in extra, ninja is an executable and it does not need any change.
	# gclient.py require a fix for work correctly with python2-colorama
	# Another way is make default python2, but I don't think is a good idea!
	# Fixing python scripts.
	msg "Patching script for python2 usage..."
	for script in *.py
	do
		sed -i -r -e 's/#!(.*)python.*/#!\1python2/' "${script}"
	done

	# Fixing gclient.py
	sed -i -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/' \
		gclient.py
	sed -i -e 's/exec python/exec python2/' \
		gclient

	# Fixing repo
	sed -r -i -e 's/"exec" python/"exec" python2/' repo

	# Fixing scripts in root folder
	for script in "${scripts_to_fix[@]}"
	do
		sed -r -i -e 's/exec python/exec python2/' \
			        -e 's/#!(.*)python.*/#!\1python2/' \
			"${script}"
	done

	# Fixing scripts in other folders
	# Is it safe remove those folders?? I don't now, further tests required. For now fix it and include all tools.
	sed -r -i -e 's/python/python2/' git-cl-upload-hook

	for script in {git_utils/git-tree-prune,support/chromite_wrapper,tests/sample_pre_commit_hook,third_party/pylint/epylint.py}
	do
		sed -r -i -e 's/env python/env python2/' "${script}"
	done

	for folder in {testing_support,tests,third_party}
	do
		cd "${folder}"
		for script in *.py
		do
			sed -r -i -e 's/env python/env python2/' "${script}"
		done
		cd ..
	done
}

package()
{
	# Creating directories
	install -d "${pkgdir}/opt"

	cp -r "${srcdir}/${pkgname}" "${pkgdir}/opt/"

	# Export PATH
	install -Dm755 "${srcdir}/depot_tools.sh" "${pkgdir}/etc/profile.d/depot_tools.sh"

	# Install repo_fix.sh script
	install -Dm 755 "${srcdir}/repo_fix.sh" "${pkgdir}/opt/${pkgname}"

	# Install License
	install -Dm644 "${pkgdir}/opt/${pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

	rm -rf "${pkgdir}/opt/${pkgname}/.git"
}