# Template file for 'initramfs-tools'
pkgname=initramfs-tools
version=0.99.3.debian0.95.1
build_style=custom-install
short_desc="Tools for generating an initramfs"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=b31983b27630b3ef99f68bd8382851a7963542c944b625bdbfd2f2ff301a02d3
long_desc="
 This package contains tools to create and boot an initramfs for packaged 2.6
 Linux kernel. The initramfs is a gzipped cpio archive. At boot time, the
 kernel unpacks that archive into RAM, mounts and uses it as initial root
 file system. The mounting of the real root file system occurs in early user
 space. Having the root on EVMS, MD, LVM2, LUKS or NFS is also supported.
 Any boot loader with initrd support is able to load an initramfs archive."

noextract=yes
noarch=yes
keep_empty_dirs=yes
triggers="initramfs-tools"
conf_files="
/etc/$pkgname/initramfs.conf
/etc/$pkgname/update-initramfs.conf
/etc/$pkgname/modules"

Add_dependency full glibc
Add_dependency full cpio
Add_dependency full util-linux-ng
Add_dependency full gawk
Add_dependency full findutils
Add_dependency full sed
Add_dependency full grep
Add_dependency full gzip
Add_dependency full bzip2
Add_dependency full xz
Add_dependency full udev
Add_dependency full module-init-tools
Add_dependency full busybox-initramfs
Add_dependency full klibc-resume

do_install()
{
	local etcdir=$DESTDIR/etc/$pkgname

	# Required dirs
	install -d $etcdir/hooks
	install -d $etcdir/conf.d
	install -d $etcdir/scripts/init-bottom
	install -d $etcdir/scripts/init-premount
	install -d $etcdir/scripts/init-top
	install -d $etcdir/scripts/local-bottom
	install -d $etcdir/scripts/local-premount
	install -d $etcdir/scripts/local-top
	install -d $DESTDIR/usr/share/$pkgname
	install -d $DESTDIR/usr/share/$pkgname/conf.d
	install -d $DESTDIR/usr/share/$pkgname/hooks
	install -d $DESTDIR/usr/share/$pkgname/hooksconf.d
	install -d $DESTDIR/usr/share/$pkgname/modules.d
	install -d $DESTDIR/usr/share/$pkgname/scripts
	install -d $DESTDIR/usr/share/$pkgname/scripts/init-premount
	install -d $DESTDIR/usr/share/$pkgname/scripts/init-top
	install -d $DESTDIR/usr/share/$pkgname/scripts/local-premount
	install -d $DESTDIR/usr/share/$pkgname/scripts/local-top
	install -d $DESTDIR/usr/share/doc/$pkgname
	install -d $DESTDIR/usr/share/doc/$pkgname/examples
	install -d $DESTDIR/usr/share/man/man5
	install -d $DESTDIR/usr/share/man/man8
	install -d $DESTDIR/usr/sbin
	install -d $DESTDIR/var/lib/$pkgname

	# /etc config files
	install -m 644 $FILESDIR/conf/initramfs.conf $etcdir
	install -m 644 $FILESDIR/conf/update-initramfs.conf $etcdir

	# Data
	install -m 755 $FILESDIR/init $DESTDIR/usr/share/$pkgname
	for f in functions local nfs; do
		install -m 644 $FILESDIR/scripts/$f \
			$DESTDIR/usr/share/$pkgname/scripts
	done
	install -m 755 $FILESDIR/scripts/init-premount/* \
		$DESTDIR/usr/share/$pkgname/scripts/init-premount
	install -m 755 $FILESDIR/scripts/init-top/* \
		$DESTDIR/usr/share/$pkgname/scripts/init-top
	install -m 755 $FILESDIR/scripts/local-premount/* \
		$DESTDIR/usr/share/$pkgname/scripts/local-premount
	install -m 755 $FILESDIR/hooks/* $DESTDIR/usr/share/$pkgname/hooks
	install -m 644 $FILESDIR/hook-functions $DESTDIR/usr/share/$pkgname
	install -m 644 $FILESDIR/conf/modules $etcdir

	# Examples
	install -m 644 $FILESDIR/docs/* $DESTDIR/usr/share/doc/$pkgname/examples
	
	# Manpages
	install -m 644 $FILESDIR/*.5 $DESTDIR/usr/share/man/man5
	install -m 644 $FILESDIR/*.8 $DESTDIR/usr/share/man/man8

	# Scripts
	install -m 755 $FILESDIR/mkinitramfs $DESTDIR/usr/sbin
	install -m 755 $FILESDIR/update-initramfs $DESTDIR/usr/sbin
	sed -i -e "s|@VERSION@|${version}|g" $DESTDIR/usr/sbin/update-initramfs
}
