#!/bin/sh
# Updates an installer initrd with a new loader binary 
# Usage: upd-initrd <initrd> <binary> <outfile>
#
# CAVEATS: Must use absolute paths to files, not relative
#
# Jeremy Katz <katzj@redhat.com>
# Copyright 2005   Red Hat, Inc.

if [ $# -ne 3 ]; then
    echo "Usage: $0 <initrd> <binary> <outfile>"
    exit 1
fi

INITRD=$1
BIN=$2
OUT=$3

tmpdir=$(mktemp -d)
pushd $tmpdir
zcat $INITRD |cpio -id
strip -s -o sbin/loader $BIN
(find . |cpio -c -o |gzip -9) > $OUT
popd
rm -rf $tmpdir
