Dash:
[t2.git] / architecture / x86 / boot / makeimages.sh
blob9f450ade9c82b175d2823eae5020aecef9b8d729
1 #!/bin/sh
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 #
5 # T2 SDE: target/bootdisk/arch/x86/makeimages.sh
6 # Copyright (C) 2004 - 2005 The T2 SDE Project
7 #
8 # More information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
16 if [ "$1" = -reroot ] ; then
17 echo "Old PATH: $PATH"
18 PATH="../../sbin:../../bin:../../../sbin:../usr/bin:$PATH"
19 echo "New PATH: $PATH"
20 echo "Old LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
21 export LD_LIBRARY_PATH="../../lib:../../usr/lib:$LD_LIBRARY_PATH"
22 LD_LIBRARY_PATH=${LD_LIBRARY_PATH%:}
23 echo "New LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
24 shift
27 if [ "$1" = -combo ] ; then
28 combo=1
29 elif [ "$#" != 0 ] ; then
30 echo "usage: $0 [-reroot] [-combo]"
31 exit 1
34 tmpfile=`mktemp -p $PWD`
35 tmpdir=$tmpfile.dir
36 mkdir $tmpdir || exit 1
37 rc=0
39 tmpdev=""
40 for x in /dev/loop/* ; do
41 if losetup $x $tmpfile 2> /dev/null ; then
42 tmpdev=$x ; break
44 done
45 if [ -z "$tmpdev" ] ; then
46 echo "No free loopback device found!"
47 rm -f $tmpfile ; rmdir $tmpdir
48 exit 1
50 echo "Using $tmpdev."
52 for image in initrd boot_144 boot_288
54 case ${image} in
55 initrd)
56 echo "Creating ${image}.gz ..."
57 size=4096 ;;
58 boot_144)
59 echo "Creating ${image}.img ..."
60 size=1440 ;;
61 boot_288)
62 echo "Creating ${image}.img ..."
63 size=2880 ;;
64 esac
66 dd if=/dev/zero of=$tmpfile bs=1024 count=$size &> /dev/null
67 losetup -d $tmpdev ; losetup $tmpdev $tmpfile || rc=1
68 mke2fs -q $tmpdev &> /dev/null ; mount $tmpdev $tmpdir || rc=1
70 case ${image} in
71 initrd)
72 cp -a initrd/* $tmpdir || rc=1
75 boot_144|boot_288)
76 cp -a boot/{vmlinuz,lilo-help.txt} $tmpdir || rc=1
77 if [ -f /boot/boot-text.b ]; then
78 cp /boot/boot-text.b $tmpdir/boot.b || rc=1
80 liloconf=lilo-conf-${image#boot_}
81 if [ $image = boot_288 -o "$combo" = 1 ] ; then
82 cp initrd.gz $tmpdir || rc=1
83 [ $image = boot_144 ] && liloconf=lilo-conf-1x2
85 sed -e "s,/mnt/,$tmpdir/,g" \
86 -e "s,/dev/floppy/0,$tmpdev,;" \
87 < boot/$liloconf > $tmpdir/lilo.conf || rc=1
88 lilo -C $tmpdir/lilo.conf > /dev/null || rc=1
90 esac
92 umount $tmpdir
94 case ${image} in
95 initrd) gzip -9 < $tmpfile > $image.gz || rc=1 ;;
96 *) cp $tmpfile $image.img || rc=1 ;;
97 esac
98 done
100 losetup -d $tmpdev
101 rm -f $tmpfile
102 rmdir $tmpdir
104 exit $rc