NAME="alacritty"
DESC="Cross-platform, OpenGL terminal emulator"
VERSION="0.13.1"
FILES=("https://github.com/alacritty/alacritty/archive/refs/tags/v0.13.1.tar.gz")
HASHES=("38a42e23e1e6faaa9e300347df3f7b58b6182908a701517aac6e296fbdf37451")
DEPENDS=(
  "freetype" "fontconfig" "libxi" "ncurses"
  "libxi" "libxcursor" "libxkbcommon" "libxrandr"
)

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

  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
  CARGO_INCREMENTAL=0 cargo build --release --locked --offline
  desktop-file-install -m 644 --dir "$ROOTDIR/usr/share/applications/" "extra/linux/Alacritty.desktop"
  install -D -m755 "target/release/alacritty" "$ROOTDIR/usr/bin/alacritty"
  install -D -m644 "extra/linux/org.alacritty.Alacritty.appdata.xml" "$ROOTDIR/usr/share/appdata/org.alacritty.Alacritty.appdata.xml"
  install -D -m644 "extra/completions/alacritty.bash" "$ROOTDIR/usr/share/bash-completion/completions/alacritty"
  install -D -m644 "extra/completions/_alacritty" "$ROOTDIR/usr/share/zsh/site-functions/_alacritty"
  install -D -m644 "extra/logo/alacritty-term.svg" "$ROOTDIR/usr/share/pixmaps/Alacritty.svg"

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