summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c69e0657f717244758bed0e0ce9947cafb7a4a39 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Maintainer: Yurii Kolesnykov <root@yurikoles.com>
# Co-Maintainer: Felix Golatofski <contact@xdfr.de>
# Based on thunderbird-beta-bin: Det <nimetonmaili g-mail>
# Based on [extra]'s thunderbird: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Based on tor-browser: grufo <madmurphy333 AT gmail DOT com>
#
# Before running makepkg, you must do this (as normal user):
#
#     gpg --auto-key-locate nodefault,wkd --locate-keys release@mozilla.com
#

pkgname=thunderbird-localized-beta-bin
pkgver=90.0b3
pkgrel=2
pkgdesc='Standalone mail and news reader from mozilla.org — localized beta version'
arch=('i686' 'x86_64')
url="https://www.mozilla.org/thunderbird"
license=('GPL' 'LGPL' 'MPL')
depends=(gtk3 mozilla-common libxt startup-notification mime-types dbus-glib alsa-lib
         nss hunspell sqlite ttf-font icu)
optdepends=('hunspell: Spell checking'
            'hyphen: Hyphenation'
            'libcanberra: Sound support')
provides=("thunderbird=$pkgver" "thunderbird-beta=$pkgver")
conflicts=("thunderbird-beta" "thunderbird-beta-bin")
install=$pkgname.install

_arch32='linux-i686'
_arch64='linux-x86_64'
_urlbase="https://ftp.mozilla.org/pub/thunderbird/releases/${pkgver}"
_archstr=$([[ "${CARCH}" == 'x86_64' ]] && echo -n "${_arch64}" || echo -n "${_arch32}")

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

  if [[ -n "${THUNDERBIRD_PKGLANG}" ]]; then
    echo -n "${THUNDERBIRD_PKGLANG}"
    return 0
  fi

  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}/${_archstr}/${_fulllocale}/thunderbird-${pkgver}.tar.bz2"; then
    echo -n "${_fulllocale}"
  elif curl --output /dev/null --silent --head --fail "${_urlbase}/${_archstr}/${_shortlocale}/thunderbird-${pkgver}.tar.bz2"; then
    echo -n "${_shortlocale}"
  else
    echo -n 'en-US'
  fi

}

_language="$(_localemoz)"

validpgpkeys=('14F26682D0916CDD81E37B6D61B7B526D98F0353')

# Syntax: _dist_checksum 'linux-i686'/'linux-x86_64'
_dist_checksum() {
  curl --silent --fail "${_urlbase}/SHA256SUMS" | grep "${1}\/${_language}\/thunderbird-${pkgver}.tar.bz2" | cut -d ' ' -f1
}

source_i686=("${_urlbase}/${_arch32}/${_language}/thunderbird-${pkgver}.tar.bz2"{,.asc})
source_x86_64=("${_urlbase}/${_arch64}/${_language}/thunderbird-${pkgver}.tar.bz2"{,.asc})
source=("${pkgname}.desktop")

### IMPORTANT #################################################################
# No need for `makepkg -g`: the following sha256sums¸don't need to be updated #
# with each release, everything is done automatically! Leave them like this!  #
###############################################################################
sha256sums=('4890cc98cc21f3f2dbf4134627217b11167c73954a549fbe7ca0bbc8ca79b2d4')
sha256sums_i686=($(_dist_checksum "${_arch32}")
                 'SKIP')
sha256sums_x86_64=($(_dist_checksum "${_arch64}")
                   'SKIP')

prepare() {

  # 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 "${THUNDERBIRD_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_}THUNDERBIRD_PKGLANG${_COL_DEFAULT_}\` environment variable before running makepkg.\n"
    echo '     For instance:'
    echo -e "\n        ${_COL_LIGHTGREY_}THUNDERBIRD_PKGLANG='en-US' makepkg${_COL_DEFAULT_}\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() {
  # Create directories
  msg2 "Creating directory structure..."
  install -d "$pkgdir"/usr/bin
  install -d "$pkgdir"/usr/share/applications
  install -d "$pkgdir"/opt

  msg2 "Moving stuff in place..."
  # Install
  cp -r thunderbird/ "$pkgdir"/opt/thunderbird-beta

  # Launchers
  ln -s /opt/thunderbird-beta/thunderbird "$pkgdir"/usr/bin/thunderbird-beta
  # breaks application as of 68.0b1
  # ln -sf thunderbird "$pkgdir"/opt/thunderbird-beta/thunderbird-bin

  _vendorjs="$pkgdir/opt/thunderbird-beta/defaults/preferences/vendor.js"
  install -Dm644 /dev/stdin "$_vendorjs" <<END
// Use LANG environment variable to choose locale
pref("intl.locale.requested", "");

// Use system-provided dictionaries
pref("spellchecker.dictionary_path", "/usr/share/hunspell");

// Disable default mailer checking.
pref("mail.shell.checkDefaultMail", false);

// Don't disable our bundled extensions in the application directory
pref("extensions.autoDisableScopes", 11);
pref("extensions.shownSelectionUI", true);
END

  _distini="$pkgdir/opt/thunderbird-beta/distribution/distribution.ini"
  install -Dm644 /dev/stdin "$_distini" <<END
[Global]
id=archlinux
version=1.0
about=Mozilla Thunderbird for Arch Linux

[Preferences]
app.distributor=archlinux
app.distributor.channel=$pkgname
END

  for i in 16 22 24 32 48 64 128 256; do
    install -d "$pkgdir"/usr/share/icons/hicolor/${i}x${i}/apps/
    ln -s /opt/thunderbird-beta/chrome/icons/default/default$i.png \
          "$pkgdir"/usr/share/icons/hicolor/${i}x${i}/apps/thunderbird-beta.png
  done
  
  install -Dm644 $srcdir/$pkgname.desktop \
    "$pkgdir/usr/share/applications"

  # Use system-provided dictionaries
  ln -Ts /usr/share/hunspell "$pkgdir"/opt/thunderbird-beta/dictionaries
  ln -Ts /usr/share/hyphen "$pkgdir"/opt/thunderbird-beta/hyphenation

  # Install a wrapper to avoid confusion about binary path
  install -Dm755 /dev/stdin "$pkgdir/usr/bin/$pkgname" <<END
#!/bin/sh
exec /opt/thunderbird-beta/thunderbird "\$@"
END

  # Use system certificates
  ln -sf /usr/lib/libnssckbi.so "$pkgdir"/opt/thunderbird-beta/libnssckbi.so
}