summaryrefslogtreecommitdiffstats
path: root/scripts/mk-images.sparc
blob: 9525f59e674b9a0f7a93d7222e6a2866ae43aba8 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#
# mk-images.sparc
#
# Copyright (C) 2008 Tom "spot" Callaway <tcallawa@redhat.com>
#
# 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/>.
#

# modules that are needed.  this is the generic "needed for every arch" stuff
TFTPCOMMONMODS="nfs sunrpc lockd cramfs loop squashfs ipv6"
TFTPUSBMODS="ohci-hcd uhci-hcd ehci-hcd hid mousedev usb-storage"
TFTPFSMODS="ext2 ext3 ext4dev lock_nolock cifs"
INITRDMODS="$USBMODS $FIREWIREMODS $IDEMODS $SCSIMODS $FSMODS $LVMMODS $RAIDMODS $CRYPTOMODS $COMMONMODS $PCMCIASOCKMODS =scsi =net"
TFTPINITRDMODS="$TFTPCOMMONMODS $TFTPUSBMODS $IDEMODS $SCSIMODS $TFTPFSMODS $LVMMODS $CRYPTOMODS"
SPARCCOMMONMODS="openpromfs sermouse"
SPARCSCSIMODS="qlogicpti esp sym53c8xx qlogicisp mptbase mptscsih mptfc mptsas qla2xxx pata_cmd64x pata_ali"
SPARCNETMODS="cassini e1000 e1000e sunbmac sungem sunhme sunlance sunqe sunvnet tg3 tulip"
SPARCMODS="$SPARCCOMMONMODS $SPARCSCSIMODS $SPARCNETMODS"

TILO=$IMGPATH/usr/bin/tilo
SILO=$IMGPATH/usr/sbin/silo

# This is a disgusting hack. Unfortunately, it's the only way we can get files out of the tftpinitrd without worse hacks.

makeproductfile() {
    root=$1

    rm -f $root/.buildstamp
    echo $IMAGEUUID > $root/.buildstamp
    echo $PRODUCT >> $root/.buildstamp
    echo $VERSION >> $root/.buildstamp
    if [ -n "$BUGURL" ]; then
        echo $BUGURL >> $root/.buildstamp
    fi
    if [ "$AMITFTP" = "1" ]; then
	rm -rf $root/modules/*/kernel/drivers/isdn/i4l/isdn.ko*
	rm -rf $root/modules/*/kernel/drivers/isdn/isdnloop/isdnloop.ko*
	rm -rf $root/modules/*/kernel/drivers/media/common/ir-common.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/bt8xx/bttv.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/btcx-risc.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/v4l1-compat.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/videodev.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/videobuf-core.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/compat_ioctl32.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/videobuf-dma-sg.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/v4l2-common.ko*
	rm -rf $root/modules/*/kernel/drivers/media/video/tveeprom.ko*
	rm -rf $root/modules/*/kernel/drivers/media/common/ir-common.ko*
	rm -rf $root/modules/*/kernel/drivers/media/dvb/bt8xx/bt878.ko*
	rm -rf $root/modules/*/kernel/drivers/media/dvb/bt8xx/dst.ko*
	rm -rf $root/modules/*/kernel/drivers/media/dvb/dvb-core/dvb-core.ko*
	rm -rf $root/firmware/ql2100_fw.bin
	rm -rf $root/firmware/ql2300_fw.bin
	rm -rf $root/firmware/ql2322_fw.bin
	rm -rf $root/firmware/ql2400_fw.bin
	rm -rf $root/firmware/ql2400_fw.bin_mid
    fi	
}


maketftp() {
    while [ x$(echo $1 | cut -c1-2) = x"--" ]; do
       if [ $1 = "--kernel" ]; then
           TFTPKERNEL=$2
           shift; shift
           continue
       elif [ $1 = "--initrdfrom" ]; then
           TFTPINITRD=$2
           shift; shift
           continue
       elif [ $1 = "--imagename" ]; then
           TFTPIMAGE=$2
           shift; shift
           continue
       elif [ $1 = "--systemmap" ]; then
           TFTPSYSMAP=$2
           shift; shift
           continue
       fi
       echo "bad argument $1 passed to maketftp"
       exit 1
    done

    echo "Making a $KERNELARCH tftp image: $TFTPIMAGE"

    elftoaout $TFTPKERNEL -o $TFTPIMAGE
    if [ "$KERNELARCH" = "sparc" ]; then
       piggyback $TFTPIMAGE $TFTPSYSMAP $TFTPINITRD
    elif [ "$KERNELARCH" = "sparc64" ]; then
       piggyback64 $TFTPIMAGE $TFTPSYSMAP $TFTPINITRD
    fi
}

prepareBootTree() {
	echo "sparc: prepareBootTree() is called"
	(cd $BOOTDISKDIR; find . -maxdepth 1 ! -type d | cpio --quiet -p $MBD_BOOTTREE)

	cp $MBD_FSIMAGE $MBD_BOOTTREE/initrd.img
	cp $KERNELROOT/boot/vmlinuz-* $MBD_BOOTTREE/vmlinuz
	cp $KERNELROOT/boot/System.map-* $MBD_BOOTTREE/System.map

}

makeBootImages() {
    echo "Building boot images for kernel $kernelvers.$KERNELARCH"

    echo "Building initrd.img"
    
    export AMITFTP=0

    makeinitrd --initrdto $TOPDESTPATH/images/initrd.img \
	--initrdsize 8192 \
	--loaderbin loader \
	--modules "$INITRDMODS $SPARCMODS"
    [ $? = 0 ] || exit 1
    echo "Building special tftpinitrd.img"

    export AMITFTP=1

    makeinitrd --initrdto $TOPDESTPATH/images/tftpinitrd.img \
	--initrdsize 8192 \
	--loaderbin loader \
	--modules "$TFTPINITRDMODS $SPARCMODS"
    [ $? = 0 ] || exit 1
    if [ -f $IMGPATH/usr/lib/anaconda-runtime/boot/second.b ]; then
	echo "Building boot dir for silo"
	MBD_BOOTTREE=$TOPDESTPATH/boot
	MBD_FSIMAGE=$TOPDESTPATH/images/initrd.img
	mkdir $MBD_BOOTTREE
	cp $IMGPATH/usr/lib/anaconda-runtime/boot/*.b $MBD_BOOTTREE/
	
	prepareBootTree

	maketftp --kernel $MBD_BOOTTREE/vmlinuz \
		 --imagename $TOPDESTPATH/images/tftp.img \
		 --initrdfrom $TOPDESTPATH/images/tftpinitrd.img \
		 --systemmap $MBD_BOOTTREE/System.map
        echo "Deleting $TOPDESTPATH/images/tftpinitrd.img , we only want this for the tftp image creation"
        # rm -rf $TOPDESTPATH/images/tftpinitrd.img
    else
	echo "I can't find SILO in $IMGPATH/usr/lib/anaconda-runtime/boot ?!?"
	exit 1
    fi

}

doPostImages() {
	if [ -n "$BOOTISO" ]; then
		echo "Making $BOOTISO"
		mkisofs -R -J -T \
			-G /boot/isofs.b \
			-B ... \
			-s /boot/silo.conf \
			-r -V "PBOOT" -A "$PRODUCT $VERSION" \
			-x Fedora \
			-x repodata \
			-sparc-label "$PRODUCT $VERSION Boot Disc" \
			-o $TOPDESTPATH/images/$BOOTISO -graft-points \
			boot=$TOPDESTPATH/boot images/stage2.img=$TOPDESTPATH/images/stage2.img
	fi
}