#!/bin/sh
set -e

prereqs() {
	local o="/scripts/init-bottom/overlayroot"  p=""
	for p in "$DESTDIR/" ""; do
		[ -e "$p$o" ] && echo "overlayroot" && return 0
	done
}

[ "$1" = "prereqs" ] && { prereqs; exit; }

. /usr/share/initramfs-tools/hook-functions

needs="tar xz" #gzip gunzip"
for need in $needs; do fp=$(which $need) && copy_exec "$fp" /bin; done

## The busybox versions of gzip and gunzip are sufficient, so use them rather
## than the full programs via copy_exec.  However, because of odd behavior in
## initramfs-tools, if we put symlinks in /bin, then
## initramfs-tools/hooks/busybox will remove them.  So instead, use /sbin
bbox="gzip gunzip"
[ -d "$DESTDIR/sbin" ] || mkdir -p "$DESTDIR/sbin"
for need in $bbox; do ln -sf ../bin/busybox "$DESTDIR/sbin/$need"; done

# vi: ts=4 noexpandtab
