summaryrefslogtreecommitdiff
path: root/libre-testing/icedove/PKGBUILD
blob: 323e4d9c60816480fff1da3f1f65bc07ffbd5148 (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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# Maintainer (arch): Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Alexander Baldeck <alexander@archlinux.org>
# Contributor: Dale Blount <dale@archlinux.org>
# Contributor: Anders Bostrom <anders.bostrom@home.se>
# Maintainer: Andreas Grapentin <andreas@grapentin.org>
# Contributor: André Silva <emulatorman@hyperbola.info>
# Contributor: Márcio Silva <coadde@hyperbola.info>
# Contributor: Luke R. <g4jc@openmailbox.org>
# Contributor: Isaac David <isacdaavid@isacdaavid.info>
# Contributor: bill-auger <bill-auger@programmer.net>


# parabola changes and rationale:
#  - rebranded to icedove
#  - added makedepends for branding: quilt imagemagick
#  - disabled geo-location


_pkgname=thunderbird
pkgname=icedove
pkgver=102.3.3
pkgrel=1
pkgrel+=.parabola1
_brandingver=78.9
_brandingrel=1
pkgdesc='Standalone mail and news reader, based on Mozilla Thunderbird'
url=https://wiki.parabola.nu/Icedove
arch=(x86_64)
arch+=(armv7h i686)
license=(MPL GPL LGPL)
depends=(
  glibc gtk3 libgdk-3.so libgtk-3.so mime-types dbus libdbus-1.so dbus-glib
  alsa-lib nss hunspell sqlite ttf-font libvpx libvpx.so zlib bzip2 libbz2.so
  botan libwebp libwebp.so libwebpdemux.so libevent libjpeg-turbo libffi
  libffi.so nspr gcc-libs libx11 libxrender libxfixes libxext libxcomposite
  libxdamage pango libpango-1.0.so cairo gdk-pixbuf2 icu libicui18n.so
  libicuuc.so freetype2 libfreetype.so fontconfig libfontconfig.so glib2
  libglib-2.0.so pixman libpixman-1.so gnupg
)
makedepends=(
  unzip zip diffutils python python-setuptools yasm nasm mesa imake libpulse
  xorg-server-xvfb autoconf2.13 rust clang llvm cbindgen nodejs lld
  gawk perl findutils libotr wasi-compiler-rt wasi-libc wasi-libc++ wasi-libc++abi
)
makedepends+=(quilt imagemagick)
replaces=(${_pkgname})
options=(!emptydirs !makeflags)
source=(https://ftp.mozilla.org/pub/mozilla.org/thunderbird/releases/$pkgver/source/thunderbird-$pkgver.source.tar.xz{,.asc}
        $pkgname.desktop
        vendor-prefs.js
        distribution.ini
        mozconfig.cfg
        metainfo.patch
        cbindgen-0.24.patch
        rustc_version-0.4.0.patch)
source+=(https://repo.parabola.nu/other/icedove/${pkgname}_$_brandingver-$_brandingrel.branding.tar.xz{,.sig})
sha512sums=('37027f251513885d1432ee8cbe0fb2b4cb3c95b0ce88bd35f207cd7a4552d6700a63d13e0542712f796d46be6cfc165d6d1c224b30a445be7f5058fc396655fe'
            'SKIP'
            'a3c9815491d9bed0440c60f35867a5b8a2a1343521f288035fcc46e651a11b926c75a9eca2d262b43d510a7a7119709b53637f1b00ddbbee8e5b0a4b33d7b8fd'
            'e21d30a8b79724eda3488ac2bf9dfeb0c7f6bf39e59c37f17574b529d33043765eb54408a55fcbf6f3afa7a58ca99124992d443cdff23ac5c9bdbff33c75f60f'
            '31d46f91d9612d30d8553a19d0d309d743467e58b568a4aeea3caf6bd805ba00656561c84a1511c59bce1cf24ba323bfad2cd26a19985f1bf7dfb6d282642972'
            '65e92b10b802d757b415ae946475971da9943409dd76827fe95a93f9dceac2841e75af7ca4ca914a45f747c6fb642aaeea39fa7a2eb91973970a8643be1239a4'
            '7e43b1f25827ddae615ad43fc1e11c6ba439d6c2049477dfe60e00188a70c0a76160c59a97cc01d1fd99c476f261c7cecb57628b5be48874be7cf991c22db290'
            '3526402ccae1f0428f2e45bae8d0b2cb909ac2698bc3508b692b827839ccb21203ce414206039776f6ce946fc53e636290b7870e9886284d5e9d1e8ad050aac9'
            '36d9662fc94cbf7dcf371adc13a9cda679bc75df961d86de019d3c8ebb0be3062d5ef762d175fab58696db74758100a65de45d7832e0e2bd4e15c901f72d8349')
sha512sums+=('78fee952c9bc826a0a7ec262d442150177bf887349641279dafae803b9832a0dd9b8d0722cc084459077a5310eb4f6de6a8d7ffaff6741afe1359f292a373f34'
             'SKIP')
validpgpkeys=(
  14F26682D0916CDD81E37B6D61B7B526D98F0353 # Mozilla Software Releases <release@mozilla.com>
  4360FE2109C49763186F8E21EBE41E90F6F12F6D # Mozilla Software Releases <release@mozilla.com>
)
validpgpkeys+=(BFA8008A8265677063B11BF47171986E4B745536  # Andreas Grapentin
               3954A7AB837D0EA9CFA9798925DB7D9B5A8D4B40) # bill-auger

# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
# Note: These are for Arch Linux use ONLY. For your own distribution, please
# get your own set of keys. Feel free to contact foutrelis@archlinux.org for
# more information.
#_google_api_key=AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM # anti-feature

# Mozilla API keys (see https://location.services.mozilla.com/api)
# Note: These are for Arch Linux use ONLY. For your own distribution, please
# get your own set of keys. Feel free to contact heftig@archlinux.org for
# more information.
#_mozilla_api_key=16674381-f021-49de-8622-3021c5942aff # anti-feature

prepare() {
  cd $_pkgname-$pkgver

  echo "${noextract[@]}"

  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    [[ $src = *.patch ]] || continue

    echo "Applying patch $src..."
    patch -Np1 < "../$src"
  done

#  printf "%s" "$_google_api_key" >google-api-key   # anti-feature
#  printf "%s" "$_mozilla_api_key" >mozilla-api-key # anti-feature
  cp ../mozconfig.cfg .mozconfig
  sed "s|@PWD@|${PWD@Q}|g" -i .mozconfig

  case "${CARCH}" in
  armv*)
    patch -Np1 -i "${srcdir}"/arm-wasm-vfp.patch

    sed -i '/--enable-linker=gold/d' .mozconfig
    sed -i '/--enable-hardening/d' .mozconfig
    sed -i '/--enable-optimize/d' .mozconfig

    export MOZ_DEBUG_FLAGS=" "
    export CFLAGS+=" -g0"
    export CXXFLAGS+=" -g0"
    export LDFLAGS+=" -Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
    export RUSTFLAGS="-Cdebuginfo=0"

    cat >> .mozconfig <<END
ac_add_options --disable-webrtc
ac_add_options --disable-elf-hack
ac_add_options --enable-optimize="-g0 -O2"
END
    ;;
  i686)
    sed -i 's/--enable-linker=gold/--enable-linker=bfd/' .mozconfig
    LDFLAGS+=" -Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
    export LDFLAGS
    ;;
  esac

  # perform re-branding
  local branding_indir="${srcdir}"/${pkgname}-${_brandingver}
  local branding_outdir=comm/mail/branding/${pkgname}
  rm -rf -- ${branding_outdir}
  cp -aT -- "${branding_indir}"/${pkgname}-branding ${branding_outdir}

  export QUILT_PATCHES="${branding_indir}"/patches
  export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
  export QUILT_DIFF_ARGS='--no-timestamps'
  quilt push -av

  # generate icons
  for i in 16 22 24 32; do
    rsvg-convert -w ${i} -h ${i} "${branding_indir}"/app-icons/${pkgname}_small.svg \
      -o "${branding_outdir}/default${i}.png"
  done
  for i in 48 64 128 256; do
    rsvg-convert -w ${i} -h ${i} "${branding_indir}"/app-icons/${pkgname}_big.svg \
      -o "${branding_outdir}/default${i}.png"
  done
  cp "${branding_indir}"/logo/icedove_icon.svg ${branding_outdir}/
  cp -av "${branding_indir}"/preview.png comm/mail/themes/linux/mail/preview.png

  # Patch search-engines config
  local search_engines_sed_cmd='s|https://duckduckgo.com/|https://html.duckduckgo.com/html/|'
  local engines_cfg_dir=comm/mail/components/search/extensions
  sed -i "${search_engines_sed_cmd}" ${engines_cfg_dir}/ddg/manifest.json

  # Delete unused search engine configs
  find ${engines_cfg_dir} -mindepth 1 -maxdepth 1 \
                          -not -name ddg          \
                          -not -name wikipedia    \
                          -exec rm -rf {} \;

  # Patch and remove anything that's left
  sed -i '\|Phishing Protection|d
          \|UrlClassifier|d
          \|URLClassifier|d
          \|url-classifier|d
         ' comm/mail/installer/package-manifest.in
  # TODO: this could be moved into the branding package - it already processes all-thunderbird.js
  sed -i '\|extensions[.]getAddons[.]get[.]url| s|https://services[.]addons[.]mozilla[.]org.\+["][)][;]|https://directory.fsf.org/wiki/Icedove");|g;
          \|extensions[.]getAddons[.]search[.]browseURL| s|https://addons[.]mozilla[.]org.\+["][)][;]|https://directory.fsf.org/wiki/Icedove");|g;
          \|extensions[.]getAddons[.]search[.]url| s|https://services[.]addons[.]mozilla[.]org.\+["][)][;]|https://directory.fsf.org/wiki/Icedove");|g;
          \|extensions[.]webservice[.]discoverURL| s|https://services[.]addons[.]mozilla[.]org.\+["][)][;]|https://directory.fsf.org/wiki/Icedove");|g;
         ' comm/mail/app/profile/all-thunderbird.js
}

build() {
  cd $_pkgname-$pkgver
  if [[ -n "${SOURCE_DATE_EPOCH}" ]]; then
    export MOZ_BUILD_DATE=$(date --date "@${SOURCE_DATE_EPOCH}" "+%Y%m%d%H%M%S")
  fi

  #FIXME:
  # clang-{9,10,11} -> error: unknown argument: '-fvar-tracking-assignments'
  #CFLAGS="${CFLAGS/-fvar-tracking-assignments/}"
  #CXXFLAGS="${CXXFLAGS/-fvar-tracking-assignments/}"

  case "${CARCH}" in
    armv*)
      export LDFLAGS+=" -Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
      sed -i "s/\(cargo_rustc_flags += -C lto\)/#\1/" config/rules.mk
      sed -i "s/debug_info = '2'/debug_info = '1'/" build/moz.configure/toolchain.configure
      export MOZ_MAKE_FLAGS=-j1
      ;;
    i686)
      sed -i "s/\(cargo_rustc_flags += -C lto\)/#\1/" config/rules.mk
      sed -i "s/debug_info = '2'/debug_info = '1'/" build/moz.configure/toolchain.configure
      export MOZ_MAKE_FLAGS=-j1
      ;;
  esac

  export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none
  export MOZBUILD_STATE_PATH="${srcdir}/mozbuild"
  ./mach configure
  ./mach build
  ./mach buildsymbols
}

package() {
  optdepends=(
    'libotr: OTR support for active one-to-one chats'
    'libnotify: Notification integration'
  )

  export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none
  export MOZBUILD_STATE_PATH="${srcdir}/mozbuild"

  cd $_pkgname-$pkgver
  DESTDIR="$pkgdir" ./mach install

  install -Dm 644 ../vendor-prefs.js -t "$pkgdir/usr/lib/$pkgname/defaults/pref"
  install -Dm 644 ../distribution.ini -t "$pkgdir/usr/lib/$pkgname/distribution"
  install -Dm 644 ../$pkgname.desktop -t "$pkgdir/usr/share/applications"

  for i in 16 22 24 32 48 64 128 256; do
    install -Dm644 comm/mail/branding/$pkgname/default${i}.png \
      "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png"
  done
  install -Dm644 comm/mail/branding/$pkgname/${pkgname}_icon.svg \
    "$pkgdir/usr/share/icons/hicolor/symbolic/apps/$pkgname-symbolic.svg"

  # Use system-provided dictionaries
  ln -Ts /usr/share/hunspell "$pkgdir/usr/lib/$pkgname/dictionaries"
  ln -Ts /usr/share/hyphen "$pkgdir/usr/lib/$pkgname/hyphenation"

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

  # Replace duplicate binary with wrapper
  # https://bugzilla.mozilla.org/show_bug.cgi?id=658850
  ln -srf "$pkgdir/usr/bin/$pkgname" \
    "$pkgdir/usr/lib/$pkgname/$pkgname-bin"
}