# SliTaz package receipt.

PACKED_SIZE="192.0K"
UNPACKED_SIZE="608.0K"
PACKAGE="ntfs-3g"
VERSION="2022.10.3"
CATEGORY="system-tools"
TAGS="windows"
SHORT_DESC="Read and write NTFS driver for FUSE."
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL2"
WEB_SITE="https://github.com/tuxera/ntfs-3g/"

SOURCE="ntfs-3g_ntfsprogs"
TARBALL="$SOURCE-$VERSION.tgz"
WGET_URL="https://github.com/tuxera/ntfs-3g/archive/refs/tags/$VERSION.tar.gz"

DEPENDS="attr fuse"
BUILD_DEPENDS="attr-dev fuse-dev libtool util-linux-uuid-dev libgcrypt-dev autoconf"

CONFIG_FILES="/etc/filesystems"

# What is the latest version available today?
current_version()
{
	wget -O - https://github.com/tuxera/ntfs-3g/releases 2>/dev/null | \
	sed '/tag\//!d;s|.*tag/v*||;s|".*||;q'
}

# Rules to configure and make the package.
compile_rules()
{
	mkdir -p $DESTDIR/lib
	./autogen.sh
	./configure			\
		--prefix=/usr		\
		--disable-static	\
		--with-fuse=internal	\
		--mandir=/usr/share/man	\
		$CONFIGURE_ARGS &&
	make &&
	make install DESTDIR=$DESTDIR
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/etc
	cp -a $install/.	$fs/.
	rm -rf			$fs/usr/bin/ntfs[a-z]*
	rm -rf			$fs/sbin/mkfs.ntfs
	rm -rf			$fs/usr/s*
	rm -rf			$fs/usr/share
	rm -rf			$fs/usr/lib/pkgconfig
	rm -rf			$fs/usr/lib/*.a
	rm -rf			$fs/usr/include
	touch			$fs/etc/filesystems
	#this link allows udisks2 to use ntfs-3g
	cd $fs/sbin
	ln -s mount.ntfs-3g mount.ntfs
}

# Pre remove and post install commands for Tazpkg.
pre_remove()
{
	sed -i '/^$PACKAGE$/d'	"$1/etc/filesystems"
}

post_install()
{
	grep -qs ^$PACKAGE$ "$1/etc/filesystems" || \
		echo "$PACKAGE" >> "$1/etc/filesystems"
}
