summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 49b4454a2a897ab2888aa8f367f93fd20a2855fa (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
# 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>
# Contributor: Yen Chi Hsuan <yan12125@gmail.com>

pkgname=depot-tools-git
pkgver=r4249.57a86929
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"
	'repo_fix.sh' 'fixshebangs.py')
license=('Custom')
depends=('git' 'ninja' 'python2')
optdepends=(
	'google-cloud-sdk: for gsutil and download_from_google_storage'
	'subversion: for repositories using svn'
)
provides=('depot_tools' 'gclient')
conflicts=('gclient-svn' 'depot_tools-svn')
options=('!strip')
install="depot_tools.install"
sha512sums=('SKIP'
            'bde33ffcad42a4d554d5490b6562981ef4b9f3abebadbed909749ee05ba391da4b5acb31b901e785b6f019b4ed3f9c740ab92623dd6a87e67b4b599a0010374b'
            '33d772f68deddefce985d2820d3ef60fa730a1f3bc404cef3c8b1b517369501b9c3a07bc7b1b3df4d0589b45cbe4850f935699676c3e10c437bceffb37eb8214')

scripts_to_fix_exec=(
	apply_issue
	cit
	clang-format
	commit_queue
	depot-tools-auth
	download_from_google_storage
	fetch
	gclient
	git-runhooks
	gn
	roll-dep-svn
	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 scripts for python2 usage..."
	"${srcdir}/fixshebangs.py"

	# Fix gclient.py
	sed -i -r -e 's/from third_party import colorama/import colorama/' \
			  -e 's/from third_party.colorama import Fore/from colorama import Fore/' \
		gclient.py

	# Fixing scripts which use "exec python"
	for script in "${scripts_to_fix_exec[@]}"
	do
		sed -r -i -e 's/exec python/exec python2/' "${script}"
	done
}

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

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

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

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

	# Move manual pages to /usr/share/man
	install -dm755 "${pkgdir}/usr/share/man"
	mv "${pkgdir}/opt/depot_tools/man"/man[0-8] "${pkgdir}/usr/share/man/"

	# Ditto for HTML pages and README files, to /usr/share/doc
	install -dm755 "${pkgdir}/usr/share/doc/${pkgname}"
	mv "${pkgdir}/opt/depot_tools/man/html" "${pkgdir}/usr/share/doc/${pkgname}"
	mv "${pkgdir}/opt/depot_tools"/README*  "${pkgdir}/usr/share/doc/${pkgname}"

	# Remove stray files
	rm -r "${pkgdir}/opt/depot_tools/man"

	# We depend on the "ninja" package, so the wrapper script which chooses a
	# prebuilt version of it or makes a local build is not needed at all, so
	# those are removed and a wrapper script which runs the system-installed
	# /usr/bin/ninja is created instead.
	rm "${pkgdir}/opt/depot_tools"/ninja*
	cat > "${pkgdir}/opt/depot_tools/ninja" <<-EOF
	#! /bin/sh
	exec /usr/bin/ninja
	EOF
	chmod 755 "${pkgdir}/opt/depot_tools/ninja"

	# gsutil v4.19 is included in google-cloud-sdk, and I guess 4.19 is compatible with 4.13 and 4.15
	# download_from_google_storage.py expects version 4.15 and gsutil.py expects 4.13
	GSUTIL_PATH="${pkgdir}/opt/depot_tools/external_bin/gsutil"
	install -d "${GSUTIL_PATH}/gsutil_4.13"
	ln -s /opt/google-cloud-sdk/platform/gsutil "${GSUTIL_PATH}/gsutil_4.13/gsutil"
	ln -s "gsutil_4.13" "${GSUTIL_PATH}/gsutil_4.15"

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