qubes-installer-qubes-os/anaconda/scripts/upd-initrd

44 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#
# Updates an installer initrd with a new loader binary
# Usage: upd-initrd <initrd> <binary> <outfile>
#
# Copyright (C) 2005 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): Jeremy Katz <katzj@redhat.com>
#
if [ $# -ne 3 ]; then
echo "Usage: $0 <initrd> <binary> <outfile>"
exit 1
fi
INITRD=`readlink -f $1`
BIN=`readlink -f $2`
if [ -f $3 ]; then
OUT=`readlink -f $3`
else
OUT=`readlink -f .`/$3
fi
tmpdir=$(mktemp -d)
pushd $tmpdir
zcat $INITRD |cpio -id
strip -s -o sbin/$(basename $BIN) $BIN
(find . |cpio -c -o |gzip -9) > $OUT
popd
rm -rf $tmpdir