# SliTaz package receipt.

PACKED_SIZE="160.0K"
UNPACKED_SIZE="596.0K"
PACKAGE="nano"
VERSION="6.2"
CATEGORY="utilities"
TAGS="text-editor"
SHORT_DESC="Nano Text Editor."
MAINTAINER="pankso@slitaz.org"
LICENSE="GPL3"
#WEB_SITE="https://www.nano-editor.org/"
WEB_SITE="https://git.savannah.gnu.org/cgit/nano.git"

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

SUGGESTED="gpm nano-doc nano-lang"
DEPENDS="ncursesw zlib"
BUILD_DEPENDS="groff ncursesw-dev patch zlib-dev"
SPLIT="nano-doc nano-lang"

HOST_ARCH="i486 arm"

# Handle cross compilation
case "$ARCH" in
	arm*) BUILD_DEPENDS="ncursesw-dev zlib-dev" ;;
esac

# What is the latest version available today?
current_version()
{
	wget -O - https://ftp.gnu.org/gnu/$PACKAGE/ 2>/dev/null | \
	sed "/latest/d;/$PACKAGE-[0-9]/!d;/tar/!d;s|.*$PACKAGE-\\(.*\\).tar.*|\\1|" | sort -Vr | sed q
}

# Rules to configure and make the package.
compile_rules()
{
	# no longer supported in 4.2
	#	--disable-wrapping-as-root 

	./configure			\
		--sysconfdir=/etc	\
		--localstatedir=/var	\
		--enable-utf8		\
		--disable-libmagic	\
		$CONFIGURE_ARGS		\
		$ARCH_ARGS &&
	make &&
	make install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	cp -a $install/*	$fs
	rm -r			$fs/usr/share/doc
	rm -r			$fs/usr/share/locale
	rm -r			$fs/usr/share/man

	# Configuration file.
	mkdir -p $fs/etc
	cp $src/doc/sample.nanorc	$fs/etc/nanorc

	cd $fs
	patch --input=$stuff/patches/etc_nanorc-$VERSION		\
		etc/nanorc
	patch --input=$stuff/patches/usr_share_nano_sh.nanorc-$VERSION	\
		usr/share/nano/sh.nanorc

	# Shrink (delete comment lines and empty lines)
	for i in $fs/usr/share/nano/*.nanorc
	  do
		sed -i '/^#/d;/^$/d' $i
	  done
}
