summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: acc07a5c07869212fc8daece4d7e0df101c3d621 (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
# Maintainer: grufo <madmurphy333 AT gmail DOT com>
# Contributor: TrialnError <autumn-wind AT web DOT de>
# Contributor: Yardena Cohen <yardenack AT gmail DOT com>
# Contributor: Max Roder <maxroder AT web DOT de>
# Contributor: Sebastian Jug <seb AT stianj DOT ug>

#
# Before running makepkg, you must do this:
#
# gpg --keyserver hkp://pgp.mit.edu:11371 --recv-keys D1483FA6C3C07136
#

pkgname='tor-browser'
pkgver='7.0.2'
pkgrel='3'
pkgdesc='Tor Browser Bundle: Anonymous browsing using firefox and tor (language-agnostic PKGBUILD)'
url='https://www.torproject.org/projects/torbrowser.html'
arch=('i686' 'x86_64')
_idstr32='linux32'
_idstr64='linux64'
license=('GPL')
depends=('gtk2' 'mozilla-common' 'libxt' 'startup-notification' 'mime-types'
	'dbus-glib' 'alsa-lib' 'desktop-file-utils' 'hicolor-icon-theme'
	'libvpx' 'icu' 'libevent' 'nss' 'hunspell' 'sqlite')
optdepends=('zenity: simple dialog boxes'
	'kdialog: KDE dialog boxes'
	'gst-plugins-good: h.264 video'
	'gst-libav: h.264 video'
	'libpulse: PulseAudio audio driver'
	'libnotify: Gnome dialog boxes')
install="${pkgname}.install"

_archstr=$([ $CARCH = 'x86_64' ] && echo "${_idstr64}" || echo "${_idstr32}")

_localetor() {

	#
	# Checking if a `tor-browser` package exists for current locale; a different language can be
	# chosen by giving a `TORBROWSER_PKGLANG` environment variable to `makepkg`, for instance:
	#
	#	TORBROWSER_PKGLANG='en-US' makepkg
	#

	if [ -z "${TORBROWSER_PKGLANG}" ]; then

		local _urlbase="https://dist.torproject.org/torbrowser/${pkgver}/${pkgname}-${_archstr}-${pkgver}"
		local _fulllocale="$(locale | grep LANG | cut -d= -f2 | cut -d. -f1 | sed s/_/\-/)"
		local _shortlocale="$(locale | grep LANG | cut -d= -f2 | cut -d_ -f1)"

		if curl --output /dev/null --silent --head --fail "${_urlbase}_${_fulllocale}.tar.xz"; then
			echo -n "${_fulllocale}"
		elif curl --output /dev/null --silent --head --fail "${_urlbase}_${_shortlocale}.tar.xz"; then
			echo -n "${_shortlocale}"
		else
			echo 'en-US'
		fi

	else

		echo "${TORBROWSER_PKGLANG}"

	fi

}

validpgpkeys=('EF6E286DDA85EA2A4BA7DE684E2C6E8793298290')

_language="$(_localetor)"

source_i686=("https://dist.torproject.org/torbrowser/${pkgver}/${pkgname}-${_idstr32}-${pkgver}_${_language}.tar.xz"{,.asc})
source_x86_64=("https://dist.torproject.org/torbrowser/${pkgver}/${pkgname}-${_idstr64}-${pkgver}_${_language}.tar.xz"{,.asc})
source=("${pkgname}.desktop"
	"${pkgname}.install"
	"${pkgname}.png"
	"${pkgname}.sh")

md5sums=('914bc94601657ac143f21acd8ed75747'
         'd7aa692701859b7ab6cd55f48e44e5e7'
         '494afbfa60fb4ce21840244cc3f7208c'
         '45aad9b5bb9697724f824e0eec52e406')
md5sums_i686=('SKIP'
	'SKIP')
md5sums_x86_64=('SKIP'
	'SKIP')

noextract=("${pkgname}-${_idstr64}-${pkgver}_${_language}.tar.xz"
	"${pkgname}-${_idstr32}-${pkgver}_${_language}.tar.xz")

package() {

	cd "${srcdir}"

	msg "Packaging ${pkgname} (language: ${_language})..."

	if [ -z "${TORBROWSER_PKGLANG}" ]; then
		msg ''
		msg "Note: if you want to package ${pkgname} in a different language, please"
		msg 'set a `TORBROWSER_PKGLANG` environment variable before running `makepkg`.'
		msg ''
		msg 'For instance:'
		msg ''
		msg "   TORBROWSER_PKGLANG='en-US' makepkg"
		msg ''
	fi

	sed -i "s/__REPL_LANGUAGE__/${_language}/g"	"${pkgname}.desktop"

	sed -i "s/__REPL_NAME__/${pkgname}/g"		"${pkgname}.sh"
	sed -i "s/__REPL_VERSION__/${pkgver}/g"		"${pkgname}.sh"
	sed -i "s/__REPL_RELEASE__/${pkgrel}/g"		"${pkgname}.sh"
	sed -i "s/__REPL_LANGUAGE__/${_language}/g"	"${pkgname}.sh"
	sed -i "s/__REPL_ARCH__/${_archstr}/g"		"${pkgname}.sh"

	install -Dm 644 "${pkgname}.desktop"	"${pkgdir}/usr/share/applications/${pkgname}.desktop"
	install -Dm 644 "${pkgname}.png"	"${pkgdir}/usr/share/pixmaps/${pkgname}.png"
	install -Dm 755 "${pkgname}.sh"		"${pkgdir}/usr/bin/${pkgname}"

	install -Dm 644 "${pkgname}-${_archstr}-${pkgver}_${_language}.tar.xz" "${pkgdir}/opt/${pkgname}/${pkgname}-${_archstr}-${pkgver}_${_language}.tar.xz"

}