~ubuntu-branches/ubuntu/quantal/silo/quantal

« back to all changes in this revision

Viewing changes to tilo/tilo.sh

  • Committer: Bazaar Package Importer
  • Author(s): Fabio M. Di Nitto
  • Date: 2007-10-25 09:28:08 UTC
  • mfrom: (15.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071025092808-1yhj12t7s4zqsfu5
Tags: 1.4.13a+git20070930-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Build with -fno-stack-protector.
  - Change silo.postinst to automatically update the boot block without
    invoking siloconfig and keep asking questions on upgrades.
  - Convert silo.conf to use /dev/disk/by-uuid.
  - Ubuntu maintainer foobar.
  - Fix debian/rules call to dh_installdocs.
  - Drop the requirement of gcc-4.1 and start using default gcc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# TILO - Trivial Image LOader
 
3
#
 
4
# by Jan Vondrak (C) 1998
 
5
#
 
6
# This is just a simple wrapper for maketilo...
 
7
 
 
8
usage () {
 
9
        echo "Usage: tilo [ -o output ] <kernel images> <root image>"
 
10
}
 
11
 
 
12
set -e
 
13
 
 
14
sun4u=
 
15
sun4c=
 
16
rootimg=
 
17
tilo_args=
 
18
output=
 
19
to_remove=
 
20
 
 
21
trap "rm -f $to_remove" 0 1 2 3 7 10 13 15
 
22
 
 
23
do_image () {
 
24
        [ $# = 1 -a -n "$1" ] || exit
 
25
        KERNEL=$1
 
26
        tag=
 
27
        sun4u_init=`nm $KERNEL | awk '/t sun4u_init$/{print$1}'`
 
28
        [ "$?" = 0 ] || exit 2
 
29
        if [ -n "$sun4u_init" ]; then
 
30
                if [ -n "$sun4u" ]; then
 
31
                        echo "Multiple sun4u kernels"
 
32
                        exit 1
 
33
                fi
 
34
                sun4u=$KERNEL
 
35
                tag=sun4u
 
36
        else
 
37
                if [ -n "$sun4c" ]; then
 
38
                        echo "Multiple sun4cdm kernels"
 
39
                        exit 1
 
40
                fi
 
41
                sun4c=$KERNEL
 
42
                tag=sun4cdm
 
43
        fi
 
44
        echo "Converting $KERNEL ($tag) to a.out:"
 
45
        elftoaout $KERNEL -o $KERNEL.out
 
46
        tail --bytes +33 $KERNEL.out > $KERNEL.raw
 
47
        rm $KERNEL.out
 
48
        echo Compressing $KERNEL.raw:
 
49
        gzip -c9v $KERNEL.raw > $KERNEL.gz
 
50
        to_remove="$to_remove $KERNEL.gz"
 
51
        PSIZE=`ls -l $KERNEL.gz | awk '{print$5}'`
 
52
        SIZE=`ls -l $KERNEL.raw | awk '{print$5}'`
 
53
        ROOTA=`nm $KERNEL | awk '/A _end$/{print$1}'`
 
54
        rm $KERNEL.raw
 
55
        echo "Sizes ($tag):"
 
56
        echo "  raw size     = $SIZE"
 
57
        echo "  packed size  = $PSIZE"
 
58
        echo "  root address = $ROOTA"
 
59
        if [ -n "$sun4u" ]; then
 
60
                tilo_args="$tilo_args sun4u=$KERNEL.gz size4u=$SIZE root4u=$ROOTA"
 
61
        else
 
62
                tilo_args="$tilo_args sun4c=$KERNEL.gz size4c=$SIZE root4c=$ROOTA"
 
63
        fi
 
64
}
 
65
 
 
66
do_root () {
 
67
        [ $# = 1 -a -n "$1" ] || exit
 
68
        if [ -n "$rootimg" ]; then
 
69
                echo "Multiple root images?"
 
70
                exit 1
 
71
        fi
 
72
        rootimg=$1
 
73
        if file $rootimg | grep -q "gzip compressed data"; then
 
74
                : # Nothing
 
75
        else
 
76
                echo Compressing $rootimg:
 
77
                gzip -c9v $rootimg > $rootimg.gz
 
78
                to_remove="$to_remove $rootimg.gz"
 
79
                rootimg=$rootimg.gz
 
80
        fi
 
81
        ROOT_SIZE=`ls -l $rootimg | awk '{print$5}'`
 
82
        echo Root image packed size = $ROOT_SIZE
 
83
        tilo_args="$tilo_args root=$rootimg"
 
84
}
 
85
 
 
86
while [ $# != 0 ]; do
 
87
        case "$1" in
 
88
                -h) usage; exit ;;
 
89
                -o) shift; output="$1" ;;
 
90
                -*) echo $"$0: Unrecognised option: $1" >&2
 
91
                    usage >&2; exit 1 ;;
 
92
                *)
 
93
                        if [ ! -f "$1" ]; then
 
94
                                echo "$1 does not exist"
 
95
                                exit 1
 
96
                        fi
 
97
                        if file $1 | grep -q "MSB executable"; then
 
98
                                do_image $1 || exit 1
 
99
                        else
 
100
                                # Suspect it is a root.bin
 
101
                                do_root $1 || exit 1
 
102
                        fi
 
103
                        ;;
 
104
        esac
 
105
        shift
 
106
done
 
107
 
 
108
test -z "$output" && output=tftpboot.img
 
109
 
 
110
if [ -z "$sun4u" -a -z "$sun4c" ]; then
 
111
        echo "No images provided"
 
112
        exit 1
 
113
fi
 
114
 
 
115
`echo $0 | sed 's/tilo$/maketilo/'` $tilo_args out=$output
 
116
 
 
117
rm -f $to_remove
 
118
 
 
119
TILO_SIZE=`ls -l $output | awk '{print$5}'`
 
120
echo TILO size = $TILO_SIZE