summaryrefslogtreecommitdiff
path: root/libre/icedove/PKGBUILD
blob: 3621e8f61373c69be14bc24d1df9a1384b608f65 (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
# Maintainer (Arch): Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor (Arch): Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor (Arch): Ionut Biru <ibiru@archlinux.org>
# Contributor (Arch): Alexander Baldeck <alexander@archlinux.org>
# Contributor (Arch): Dale Blount <dale@archlinux.org>
# Contributor (Arch): 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 mozilla-searchplugins imagemagick
#  - disabled tests, they break in an environment without network access.
#  - disabled geo-location


_pkgname=thunderbird
pkgname=icedove
epoch=1
pkgver=78.5.0
pkgrel=1
pkgrel+=.parabola1
_brandingver=78.5
_brandingrel=1
pkgdesc='Standalone mail and news reader based on Mozilla Thunderbird'
url=https://wiki.parabola.nu/${pkgname}
arch=(x86_64)
arch+=(i686 armv7h)
license=(MPL GPL LGPL)
depends=(
  glibc gtk3 libgdk-3.so mime-types dbus libdbus-1.so dbus-glib alsa-lib nss
  hunspell sqlite ttf-font libvpx libvpx.so zlib bzip2 botan libwebp libevent
  libjpeg-turbo libffi 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
  inetutils xorg-server-xvfb autoconf2.13 rust clang llvm gtk2 cbindgen nodejs
  gawk perl findutils
)
makedepends[15]='llvm10' # FIXME: DEBUG: | rustup: error while loading shared libraries: libLLVM-10.so: cannot open shared object file: No such file or directory
                         #        ERROR: Command `rustup which rustc` failed with exit status 127.
makedepends+=(quilt mozilla-searchplugins 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
        configure-fix-passing-system-bzip2-ldflags.patch
        thunderbird-78.4.3-gpgme-double-armored-fix.patch)
source+=(https://repo.parabola.nu/other/icedove/${pkgname}_$_brandingver-$_brandingrel.branding.tar.xz{,.sig}
         libre-searchengines.patch)
source_armv7h=(arm-wasm-vfp.patch)
sha512sums=('dae49dc0910dd017250643c920c79f03d3ef14bcbafde7fcdb3aaeba2b27a42ef6f88c8de8b961f8bb1c3d1a153bc8988ab43a39eb051d81839cf3b9e8373118'
            'SKIP'
            'a3c9815491d9bed0440c60f35867a5b8a2a1343521f288035fcc46e651a11b926c75a9eca2d262b43d510a7a7119709b53637f1b00ddbbee8e5b0a4b33d7b8fd'
            'e21d30a8b79724eda3488ac2bf9dfeb0c7f6bf39e59c37f17574b529d33043765eb54408a55fcbf6f3afa7a58ca99124992d443cdff23ac5c9bdbff33c75f60f'
            '31d46f91d9612d30d8553a19d0d309d743467e58b568a4aeea3caf6bd805ba00656561c84a1511c59bce1cf24ba323bfad2cd26a19985f1bf7dfb6d282642972'
            '636aad861322df5cc3cb9e7b0142a56981b9eeb010bacaa10148d3f74f43bc3c26580475ee5646556acb9980028cb3ffcc1a15788f8039ca0fe57e261457c113'
            'e3ed2708b8354015cb3d2c81048d1ce4932d1effbe2b40efa7cf9b45c1b923b9fd708645e2f8aa0136a485a3f7ce6b396b85721aaf535a4a764fd5005fb7e222'
            '92f4c5946f288b30728382830b99b91980ecd845d1606ab251bbdde5cf53387e966727a23f35a3bf7756ee77e72e478f3fb468668e8c412f552547eeb3408299')
sha512sums+=('3b757a7c5f1f4aa83405d0dc7bb69b72230e0e2c944f9b5aeff8e22cc8e6a053aeb16e3ca6f450bf5de763a1aba8028bf4f299bdfb6f203239605ea16c40b4ed'
             'SKIP'
             'be1bf98b65471aa36d1e4a55a24907ac99ddd401daee180dfe26302bad6928f6b4fe5dc6bbc7a96d884237bbd1f6205a4788a82b13fd7e929edbaf64200e0f52')
sha512sums_armv7h=('c25883c4860e511a99d9fbfba5b824145c0862729101721605725f609ca2a41848b741dd100eff390f57031dc5f14af3ea30133de30f75cb20197c420ae20972')
validpgpkeys=(14F26682D0916CDD81E37B6D61B7B526D98F0353) # Mozilla Software Releases <release@mozilla.com>
validpgpkeys+=(BFA8008A8265677063B11BF47171986E4B745536  # Andreas Grapentin
               3954A7AB837D0EA9CFA9798925DB7D9B5A8D4B40) # bill-auger


prepare() {
  cd $_pkgname-$pkgver

  echo "${noextract[@]}"

  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    [[ $src = *.patch ]] || continue
    [[ $src = libre-searchengines.patch ]] && continue # defer parabola patches
    [[ $src = arm-wasm-vfp.patch        ]] && continue # defer parabola patches

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

  cp ../mozconfig.cfg .mozconfig
  sed "s|@PWD@|${PWD@Q}|g" -i .mozconfig

  if [[ ${CARCH} = arm* ]]
  then
    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
  fi

  if [[ ${CARCH} = i686 ]]; then
    sed -i 's/--enable-linker=gold/--enable-linker=bfd/' .mozconfig
    LDFLAGS+=" -Wl,--no-keep-memory -Wl,--reduce-memory-overheads"
    export LDFLAGS
  fi

  # perform rebranding
  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
  echo "applying libre-searchengines.patch"
  patch -Np1 -i "${srcdir}"/libre-searchengines.patch
  # TODO: custom searchplugins ID per new format ("ddg" is standard)
  #         where: ID is comm/mail/components/search/extensions/<ID>/
  #         eg: "ddg", "duckduckgo-html", "duckduckgo-lite", "internet-archive", "parabola-labs", "parabola-packages", "parabola-wiki-en", "searx", "wikipedia", "yacy"|g'
  local remove_engines_sed_cmd='s|.*"google".*"wikipedia".*|          "ddg", "wikipedia"| ; s|.*"google".*"wikipedia\(-[^"]*\)".*|          "ddg", "wikipedia\1"|'
  local engines_cfg_dir=comm/mail/components/search/extensions
  local engines_cfg_file=${engines_cfg_dir}/list.json
  sed -i "${remove_engines_sed_cmd}" ${engines_cfg_file}

  # Sanity-check search-engines patching
  local removed_engines_regex='Bing|Google|Seznam|Twitter|Yahoo|Yandex|Яндекс|amazon|bing|google|ebay|twitter'
  local engines_err_msg="search-engines patch and/or sed command needs re-working"
  ! grep -E ${removed_engines_regex} ${engines_cfg_file} > /dev/null || ! echo "${engines_err_msg}"

  # Delete unused search engine configs
  find ${engines_cfg_dir} -mindepth 1 -maxdepth 1 \
                          -not -name ddg          \
                          -not -name wikipedia    \
                          -not -name list.json    \
                          -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
  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

  # Load our searchplugins
  # TODO: this 'searchplugins' directory no longer exists, as of v78
  #       so perhaps the replacement will not be used
  rm -rv comm/suite/locales/en-US/searchplugins || :
  cp -av /usr/lib/mozilla/searchplugins comm/suite/locales/en-US/
}

build() {
  cd $_pkgname-$pkgver

  # 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

  ./mach configure
  ./mach build
  ./mach buildsymbols
}

package() {
  optdepends=('libcanberra: sound support')

  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"
}