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

TARBALL=coreutils-8.22.tar.xz
MD5SUM=8fb0ae2267aa6e728958adc38f8163a2
SRC_URL=http://distro.ibiblio.org/fatdog/source/710/clfs-packages-3.0.0.tar
BUNDLE=clfs-packages-3.0.0.tar

SLACKREQ=
SLACKDESC='coreutils: coreutils 8.22 (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-8.22-i18n-4.patch # LFS 7.5
	patch -Np1 -i $SRC_DIR/coreutils-8.22-uname-1.patch # CLFS 3.0.0
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/coreutils*
	
	FORCE_UNSAFE_CONFIGURE=1 CC="gcc ${BUILD64}" \
	   ./configure --prefix=/usr --libdir=/usr/lib64 \
		--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
	# mv -v /usr/bin/{head,sleep,nice} /bin &&
	
	pkg_build_slackdesc
}
