summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d9ef6b4413049ba18c2f457214360b8681753088 (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Maintainer: Mike Tigas <mike at tig dot as>
# Ex-Maintainer: Yurii Kolesnykov <root@yurikoles.com>
# Ex-Maintainer: end222 <pabloorduna98 at gmail dot com>
# Ex-Maintainer: Jean Lucas <jean at 4ray dot co>
# Contributor: sekret, mail=$(echo c2VrcmV0QHBvc3Rlby5zZQo= | base64 -d)

pkgname=tor-browser-dev
pkgver=9.0a2
pkgrel=1
pkgdesc="Tor Browser Bundle (alpha version; locale-aware international PKGBUILD)"
arch=('i686' 'x86_64')
_idstr32='linux32'
_idstr64='linux64'
url="https://www.torproject.org/download/alpha/"
license=('GPL')
depends=('gtk3' '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')

_archstr=$([[ "${CARCH}" == 'x86_64' ]] && echo -n "${_idstr64}" || echo -n "${_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 [[ -n "${TORBROWSER_PKGLANG}" ]]; then
    echo -n "${TORBROWSER_PKGLANG}"
    return 0
  fi

  local _urlbase="https://dist.torproject.org/torbrowser/${pkgver}/tor-browser-${_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 -n 'en-US'
  fi

}

_language="$(_localetor)"

source_i686=("https://dist.torproject.org/torbrowser/${pkgver}/tor-browser-${_idstr32}-${pkgver}_${_language}.tar.xz"{,.asc})
source_x86_64=("https://dist.torproject.org/torbrowser/${pkgver}/tor-browser-${_idstr64}-${pkgver}_${_language}.tar.xz"{,.asc})
source+=(${pkgname}.desktop
         ${pkgname}.png
         ${pkgname}.sh)
sha256sums=('13d2e1fe85a9a08e9f66116f3c2d6f1e5d37e07d2ad8b08ae4f01890e864a722'
            '13267084e2b6dd1dbbb93f685d61da4cb48184a76a1c06a42ecc575855e24c57'
            'ce19dd89a8ecd9289136f97f0122b7301bdda9bcf0208f4277817e23ea9a95d8')
sha256sums_i686=('SKIP'
                 'SKIP')
sha256sums_x86_64=('SKIP'
                   'SKIP')
# skip checksumming the tor-provided release package, since we dynamically
# select the package for the user locale. we'll just rely on GPG sig.
#pub   rsa4096 2014-12-15 [C] [expires: 2020-08-24]
#     EF6E286DDA85EA2A4BA7DE684E2C6E8793298290
#uid           Tor Browser Developers (signing key) <torbrowser@torproject.org>
validpgpkeys=('EF6E286DDA85EA2A4BA7DE684E2C6E8793298290')
noextract=("tor-browser-${_idstr32}-${pkgver}_${_language}.tar.xz"
     "tor-browser-${_idstr64}-${pkgver}_${_language}.tar.xz")



prepare() {
  # only using this for notifying user about TORBROWSER_PKGLANG and
  # sanity-checking our config

  # use colors only if we have them
  if [[ $(which tput > /dev/null 2>&1 && tput -T "${TERM}" colors || echo -n '0') -ge 8 ]] ; then
    local _COL_YELLOW_='\e[0;33m'
    local _COL_LIGHTGREY_='\e[0;37m'
    local _COL_BRED_='\e[1;31m'
    local _COL_BBLUE_='\e[1;34m'
    local _COL_BWHITE_='\e[1;37m'
    local _COL_DEFAULT_='\e[0m'
  fi

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

  if [[ -z "${TORBROWSER_PKGLANG}" ]]; then
    echo -e "\n  ${_COL_BBLUE_}->${_COL_DEFAULT_} ${_COL_BRED_}NOTE:${_COL_DEFAULT_} If you want to package ${_COL_BWHITE_}${pkgname}${_COL_DEFAULT_} in a different language, please"
    echo -e "     set a \`${_COL_YELLOW_}TORBROWSER_PKGLANG${_COL_DEFAULT_}\` environment variable before running makepkg.\n"
    echo '     For instance:'
    echo -e "\n        ${_COL_LIGHTGREY_}TORBROWSER_PKGLANG='en-US' makepkg${_COL_DEFAULT_}\n"
    echo -e '     Available locales can be found at:\n'
    echo -e '        https://www.torproject.org/download/alpha/\n'
  fi

  # we search and replace using sed with / as delimiter below so don't allow slashes in these vars.
  # makepkg already enforces that there're no slashes in ${pkgname}, so we don't check that again here.
  if [[ ${pkgver} = */* || ${_language} = */* || ${pkgdesc} = */* ]]; then
    error '${pkgver}, ${_language} and ${pkgdesc} for this package are not allowed to contain /' >&2
    return 1
  fi

}

package() {
  cd ${srcdir}

  sed -i \
    -e "s|REPL_NAME|${pkgname}|g" \
    -e "s|REPL_VERSION|${pkgver}|g" \
    -e "s|REPL_LANGUAGE|${_language}|g" \
    ${pkgname}.sh

  sed -i \
    -e "s|REPL_LANGUAGE|${_language}|g" \
    -e "s|REPL_COMMENT|${pkgdesc}|g" \
    -e "s|REPL_NAME|${pkgname}|g" \
    ${pkgname}.desktop

  install -Dm 0644 ${pkgname}.desktop \
    ${pkgdir}/usr/share/applications/${pkgname}.desktop
  install -Dm 0644 ${pkgname}.png \
    ${pkgdir}/usr/share/pixmaps/${pkgname}.png
  install -Dm 0755 ${pkgname}.sh ${pkgdir}/usr/bin/${pkgname}

  install -Dm 0644 tor-browser-${_archstr}-${pkgver}_${_language}.tar.xz \
    ${pkgdir}/opt/${pkgname}/tor-browser-${_archstr}-${pkgver}_${_language}.tar.xz
}