#!/bin/sh
# Add additional files to the initrd cpio so that we can pass
# new keys to the Qubes startup routines.
# Usage:
#  wrap-cpio /boot/initrd.blah /tmp/root/ > /tmp/new.cpio

die() { echo >&2 "$@"; exit 1; }
warn() { echo >&2 "$@"; }

cpio_file="$1"
if [ -z "$cpio_file" ]; then
	die "Initial cpio must be specified"
fi

new_dir="$2"
if [ -z "$new_dir" ]; then
	die "Additional directory must be specified"
fi

( cd "$new_dir" ; find . | cpio -H newc -ov )
cat "$cpio_file"