### this file is sourced not run
PKGVER=9.1
PKGBUILD=1

TARBALL=coreutils-$PKGVER.tar.xz
MD5SUM=8b1ca4e018a7dce9bb937faec6618671
BUNDLE=fatdog-base-11.3.tar
SRC_URL=http://distro.ibiblio.org/fatdog/source/900/$BUNDLE

SLACKREQ=
SLACKDESC="coreutils: coreutils $PKGVER (Core Unix system utilities)  
coreutils:  
coreutils: The Coreutils package contains utilities for showing and setting 
coreutils: the basic system characteristics.  
coreutils: 
coreutils: 
coreutils: 
coreutils: 
coreutils: 
coreutils: 
coreutils: 
"


### override download for LFS sources bundle
# $1-src-dir $2-tarball 
pkg_download() {
	echo downloading $BUNDLE for $TARBALL
	wget -P $1 $SRC_URL
	tar -xf $1/$BUNDLE --strip-components=1 -C $1 
	rm $1/$BUNDLE
}

### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/coreutils* &&
	
	#patch -Np1 -i $SRC_DIR/coreutils-9.1-i18n-1.patch && # LFS 8.2, LFS 11.3
	patch -Np1 -i ../pkg/coreutils-9.1-uname-1.patch && # CLFS 2017.07
	true
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/coreutils*
	
	FORCE_UNSAFE_CONFIGURE=1 CC="gcc ${BUILD64}" \
	   ./configure --prefix=/usr --libdir=/usr/$LIBDIR \
		--enable-no-install-program=kill,uptime \
		--enable-install-program=hostname &&
		  
    make $MAKEFLAGS && 
    make install && 

	# FHS
	mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date} /bin &&
	mv -v /usr/bin/{dd,df,echo,false,hostname,ln,ls,mkdir,mknod} /bin &&
	mv -v /usr/bin/{mv,pwd,rm,rmdir,stty,true,uname} /bin &&
	mv -v /usr/bin/chroot /usr/sbin &&
	mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8 &&
	sed -i s/\"1\"/\"8\"/1 /usr/share/man/man8/chroot.8 &&
	
	# LFS bootscripts requirement
	# mv -v /usr/bin/{head,sleep,nice} /bin &&
	
	pkg_build_slackdesc
}
