summaryrefslogtreecommitdiffstats
path: root/scripts/upd-initrd
blob: 66006d8ce1493e7049c7a2203b18a4f818183890 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/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