# Maintainer: amedela
# File Explorer from git. Inside a checkout of the repo it builds that checkout (your changes included);
# on its own (e.g. copied elsewhere) it clones GitHub. FE_SRC=<dir> builds another checkout.
#   git clone https://github.com/AlexMedela/file-explorer && cd file-explorer/packaging/arch && makepkg -si
pkgname=file-explorer-git
pkgver=r0
pkgrel=1
pkgdesc="File Explorer - Just another file explorer: fast, keyboard-first, GPU-rendered (C, SDL3)"
arch=('x86_64' 'aarch64')
url="https://github.com/AlexMedela/file-explorer"
license=('MIT')
depends=('sdl3' 'freetype2' 'fontconfig' 'libarchive' 'glibc' 'libvterm' 'fuse3' 'openssl'
         'libdecor')  # title bar on GNOME Wayland (no server-side decorations there)
makedepends=('git' 'gcc' 'pkgconf')
optdepends=('gtk3: GTK look for the libdecor title bar (GNOME)'
            'polkit: retry as administrator (needs an authentication agent running)'
            'xdg-utils: open files with their default app'
            'dbus: "Show in folder" from browsers and other apps (Options > Integration)'
            'xdg-desktop-portal-termfilechooser: be the file chooser of other apps (Options > Integration)'
            'ffmpegthumbnailer: video previews'
            'evince: PDF previews (thumbnailer)'
            'glycin: previews for HEIF, JXL, SVG and more (thumbnailers)'
            'udisks2: mount and eject drives from the sidebar'
            'gvfs: network locations (smb://, sftp://, ...)'
            'gvfs-smb: Windows shares'
            'gvfs-mtp: phones the built-in connector leaves to GVfs (MTP)'
            'gvfs-gphoto2: cameras the built-in connector leaves to GVfs (PTP)'
            'rclone: cloud storage (Google Drive, OneDrive, S3...) in the sidebar'
            'noto-fonts-emoji: colour emoji in file names')
provides=('file-explorer')
conflicts=('file-explorer')
_src="$url.git"
if [ -n "$FE_SRC" ]; then _src="file://$FE_SRC"
elif [ -d "$startdir/../../.git" ]; then _src="file://$(cd "$startdir/../.." && pwd)"; fi
source=("file-explorer::git+$_src#branch=main")
sha256sums=('SKIP')

pkgver() {
  cd file-explorer
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd file-explorer
  CFLAGS_PKG="$CFLAGS" LDFLAGS_PKG="$LDFLAGS" ./build.sh package
}

package() {
  cd file-explorer
  DESTDIR="$pkgdir" PREFIX=/usr ./install.sh
}
