NAME="librewolf"
DESC="LibreWolf is a custom and independent version of Firefox, with the primary goals of privacy, security and user freedom"
VERSION="118.0.1-1"
FILES=(
  "https://gitlab.com/api/v4/projects/32320088/packages/generic/librewolf-source/$VERSION/librewolf-$VERSION.source.tar.gz"
  "librewolf.desktop"
  "mozconfig"
)
HASHES=(
  "d972169a6b9d2e1df6a74fcf6d2e048c29e85bec3fba98cbe272e0d508fb2392"
  "d1d4fb76689405df792bdb1130be471f3ed6090c4fed634dfc1365c1495fb637"
  "80b09c546c037994d6b022e0a9075c3c165d6790a0ee35fdb67ac6dc8fc2bc84"
)
DEPENDS=(
  "dbus" "dbus-glib" "gtk3" "ffmpeg" "pulseaudio"
  "nss" "libevent" "libvpx" "libwebp" "icu"
  "liboauth" "pciutils" "wireless-tools"
  "startup-notification" "libnotify"
)

PACKAGE() {
  tar xf $NAME-$VERSION.source.tar.gz
  cd $NAME-$VERSION

  cp "$ROOTDIR/mozconfig" .
  export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none
  export MOZBUILD_STATE_PATH=${PWD}/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"
  mkdir -pv "$ROOTDIR/usr/share/pixmaps"

  cp "$ROOTDIR/librewolf.desktop" "$ROOTDIR/usr/share/applications/librewolf.desktop"
  ln -sfv /usr/lib/librewolf/browser/chrome/icons/default/default128.png \
        "$ROOTDIR/usr/share/pixmaps/librewolf.png"

  cd .. && rm -r $NAME-$VERSION
}
