export MOZ_NOSPAM=1
export MOZBUILD_STATE_PATH="$SRCDIR"/mozbuild
export GDK_BACKEND=x11
export MACH_NO_TERMINAL_FOOTER=1

abinfo "Building Thunderbird ..."
"$SRCDIR"/mach build

abinfo "Installing Thunderbird ..."
DESTDIR="$PKGDIR" "$SRCDIR"/mach install

abinfo "Installing icons ..."
for i in 16 22 24 32 48 64 128 256; do
    install -Dvm644 comm/mail/branding/thunderbird/default${i}.png \
      "$PKGDIR"/usr/share/icons/hicolor/${i}x${i}/apps/thunderbird.png
done

abinfo "Installing symbolic icon for GNOME ..."
install -Dvm644 comm/mail/branding/thunderbird/TB-symbolic.svg \
    "$PKGDIR"/usr/share/icons/hicolor/symbolic/apps/thunderbird-symbolic.svg

abinfo "Installing langauge packs ..."
mkdir -pv "$PKGDIR"/usr/lib/thunderbird/extensions/
(
    cd "$SRCDIR"/../
    for i in *.xpi; do
        cp -v $i \
            "$PKGDIR"/usr/lib/thunderbird/extensions/langpack-${i/.xpi/}@thunderbird.mozilla.org.xpi
    done
)

abinfo "Using system dictionaries ..."
rm -rfv "$PKGDIR"/usr/lib/thunderbird/{dictionaries,hyphenation}
ln -sv /usr/share/hunspell \
    "$PKGDIR/usr/lib/thunderbird/dictionaries"
ln -sv /usr/share/hyphen \
    "$PKGDIR/usr/lib/thunderbird/hyphenation"
