# Copyright 2026 Errant Solutions
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit go-module

DESCRIPTION="High-performance FUSE filesystem for S3/B2-compatible object storage (maintained goofys fork)"
HOMEPAGE="https://github.com/yandex-cloud/geesefs"
# Vendored deps: `go mod vendor` of the tagged source, generated by packaging/geesefs/make-vendor.sh in
# ctg-infrastructure and published to the Forgejo generic registry (go.sum has ~300 entries, vendor/ pins 85 modules).
SRC_URI="
	https://github.com/yandex-cloud/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://git.canutethegreat.com/api/packages/CanuteTheGreat/generic/${PN}-vendor/${PV}/${P}-vendor.tar.xz
"

# geesefs itself: Apache-2.0. Vendored modules (checked per LICENSE file): Apache-2.0, BSD, BSD-2, MIT.
LICENSE="Apache-2.0 BSD BSD-2 MIT"
SLOT="0"
KEYWORDS="~amd64 ~arm64"
RESTRICT="mirror test"

RDEPEND="sys-fs/fuse:0"

src_unpack() {
	default
	mv "${WORKDIR}"/vendor "${S}"/ || die
}

src_compile() {
	CGO_ENABLED=0 ego build -mod=vendor -trimpath -ldflags "-s -w -X main.Version=${PV}" -o geesefs .
}

src_install() {
	dobin geesefs
	dosym geesefs /usr/bin/mount.geesefs
	dodoc README.md
}