NAME="thunderbird"
DESC="Stand-alone mail/news client based on the Mozilla codebase"
VERSION="115.8.1"
FILES=(
  "https://archive.mozilla.org/pub/thunderbird/releases/$VERSION/source/thunderbird-$VERSION.source.tar.xz"
  "thunderbird.desktop"
  "mozconfig"
)
HASHES=(
  "80d75ae91b7cbd60bcbaf134fc3f11290bd542a8a7ff965eaa4a0d95bb0d4d51"
  "7daebf05da5f2a9a9d23728b85af87a12c0ea4c22ad920af4f3f4f04275bf196"
  "75606d4cb36a856bdaea3e30026425dd09b98bd4a0ed5275b5cfdce3fb52203e"
)
DEPENDS=(
  "dbus-glib" "gtk3" "startup-notification"
  "libevent" "libvpx" "nspr" "nss" "pciutils"
  "wireless-tools"
)

PACKAGE() {
  tar xf $NAME-$VERSION.source.tar.xz
  cd $NAME-${VERSION%b*}

  cp "$ROOTDIR/mozconfig" .
  sed -e '/<exception>/i#include <cstdint>' \
    -i comm/third_party/rnp/src/libsexp/include/sexp/sexp-error.h
  export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none
  export MOZBUILD_STATE_PATH=./mozbuild
  ./mach configure
  ./mach build

  MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none DESTDIR="$ROOTDIR" ./mach install
  unset MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE MOZBUILD_STATE_PATH
  
  mkdir -pv "$ROOTDIR/usr/share/"{applications,pixmaps}
  cp "$ROOTDIR/thunderbird.desktop" "$ROOTDIR/usr/share/applications/thunderbird.desktop" 
  ln -sfv /usr/lib/thunderbird/chrome/icons/default/default256.png \
        "$ROOTDIR/usr/share/pixmaps/thunderbird.png"

  cd .. && rm -r $NAME-${VERSION%b*}
}
