# SliTaz package receipt.

PACKED_SIZE="444.0K"
UNPACKED_SIZE="1.5M"
PACKAGE="e2fsprogs"
VERSION="1.45.5"
CATEGORY="base-system"
SHORT_DESC="Filesystem utilities for use with ext2, ext3 and ext4 (without fsck*)."
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL2"
WEB_SITE="https://e2fsprogs.sourceforge.net/"

TARBALL="$PACKAGE-$VERSION.tar.gz"
WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"

DEPENDS="libcomerr util-linux-blkid util-linux-uuid"
BUILD_DEPENDS="coreutils-operations texinfo util-linux-blkid-dev 
	util-linux-uuid-dev"

HOST_ARCH="i486 arm"

# Handle cross compilation.
case "$ARCH" in
	arm) BUILD_DEPENDS="" ;;
esac

# What is the latest version available today?
current_version()
{
	wget -O - https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git 2>/dev/null | \
	sed '1,/Download/d;/h=v/!d;s|.*h=v||;s|.>.*||;q'
}

# Rules to configure and make the package.
compile_rules()
{
	# Do not use 64-bit feature by default on ext4 because syslinux and grub4dos-linux 
	# bootloaders used by the slitaz-installer(tazinst) will fail to boot. 
	# Add "auto_64-bit_support = 1" to enable 64-bit if the number of blocks for the file system 
	# require the feature to be enabled.
	zcat $stuff/e2fsprogs.no.64bit.by.default.diff.gz | patch -p1 || exit 1

	sed -i 's|\$ac_MKDIR_P&|mkdir -p\&|' configure

	mkdir ../build &&
	cd ../build &&
	$src/configure			\
		--prefix=/usr		\
		--with-root-prefix=""	\
		--enable-elf-shlibs	\
		--sysconfdir=/etc	\
		$CONFIGURE_ARGS
	make &&
	make install &&
	make install-libs
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/lib

	cp -a $install/sbin	$fs
	cp -a $install/lib	$fs
	cp -a $install/etc	$fs
	cp -a $install/usr/bin	$fs/usr
	cp -a $install/usr/sbin	$fs/usr
	( cd $fs ; for i in lib/*.so.?; do ln -s /$i usr/$i ; done )
	cat $stuff/*.files-list | while read file
	  do
		rm -f ${fs}$file
	  done

	# Remove fsck provided by Busybox.
	rm $fs/sbin/fsck*
}

# Overlap busybox
pre_install()
{
	rm -f $root/sbin/findfs
	rm -f $root/sbin/tune2fs
}

post_remove()
{
	ln -s /bin/busybox $root/sbin/findfs
	ln -s /bin/busybox $root/sbin/tune2fs
}
