summaryrefslogtreecommitdiffstats
path: root/scripts/mk-images.ppc
blob: aa421ef0bce127cc38a56a3a7d3c7ea415cca829 (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
173
174
175
176
177
178
179
180
#
# mk-images.ppc
#
# Copyright (C) 2007  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/>.
#

makeBootImages() {
    echo "Building boot images for kernel $kernelvers"
    FAKEARCH=""

    if [ "$KERNELARCH" = "ppc64" ]; then
	mkdir -p $TOPDESTPATH/ppc/ppc64
	echo "Building $KERNELARCH initrd"
	makeinitrd --initrdto $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz \
	    --initrdsize 8192 \
	    --loaderbin loader \
	    --modules "$INITRDMODS spufs viocd gpio_mdio"

	cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc64/vmlinuz
        sed -e "s/%BITS%/64/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
	    $BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc64/yaboot.conf

    cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = ppc/ppc64/vmlinuz
initrd = ppc/ppc64/ramdisk.image.gz
__EOT__

	if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
		mkdir -p $TOPDESTPATH/images/netboot
		pushd $TOPDESTPATH/ppc/ppc64
		cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc64/zImage.lds
		$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc64/vmlinuz no no $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc64.img
		rmdir $TOPDESTPATH/images/netboot || :
		rm -f $TOPDESTPATH/ppc/ppc64/zImage.lds
		popd
        echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
	elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
		mkdir -p $TOPDESTPATH/images/netboot
		$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc64.img	\
					  -i $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz	\
					  -D $IMGPATH/usr/lib/kernel-wrapper		\
					     $TOPDESTPATH/ppc/ppc64/vmlinuz
		rmdir $TOPDESTPATH/images/netboot || :
		echo "zimage = images/netboot/ppc64.img" >> $TOPDESTPATH/.treeinfo
	fi
	if [ -x $IMGPATH/usr/sbin/addRamDisk ]; then
		mkdir -p $TOPDESTPATH/images/iSeries
		$IMGPATH/usr/sbin/addRamDisk $TOPDESTPATH/ppc/ppc64/ramdisk.image.gz	\
					     $TOPDESTPATH/ppc/ppc64/vmlinuz		\
					     $TOPDESTPATH/images/iSeries/boot.img
		rmdir $TOPDESTPATH/images/iSeries || :
	fi

    echo >> $TOPDESTPATH/.treeinfo


    elif [ "$KERNELARCH" = "ppc" ]; then
	FAKEARCH="ppc"
	mkdir -p $TOPDESTPATH/ppc/ppc32
	mkdir -p $TOPDESTPATH/ppc/mac

        echo "Building ppc initrd"
        makeinitrd --initrdto $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz \
            --initrdsize 8192 \
            --loaderbin loader \
            --modules "$INITRDMODS"

        cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/ppc32/vmlinuz
        sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
	    $BOOTDISKDIR/yaboot.conf.in > $TOPDESTPATH/ppc/ppc32/yaboot.conf

    cat << __EOT__ >> $TOPDESTPATH/.treeinfo
[images-$KERNELARCH]
kernel = ppc/ppc32/vmlinuz
initrd = ppc/ppc32/ramdisk.image.gz
__EOT__
	if [ -x $IMGPATH/usr/bin/mkzimage -a -r $IMGPATH/usr/share/ppc64-utils/zImage.stub ]; then
		mkdir -p $TOPDESTPATH/images/netboot
		pushd $TOPDESTPATH/ppc/ppc32
		cp $IMGPATH/usr/share/ppc64-utils/zImage.lds $TOPDESTPATH/ppc/ppc32/zImage.lds
		$IMGPATH/usr/bin/mkzimage $TOPDESTPATH/ppc/ppc32/vmlinuz no no $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz $IMGPATH/usr/share/ppc64-utils/zImage.stub $TOPDESTPATH/images/netboot/ppc32.img
		rmdir $TOPDESTPATH/images/netboot || :
		rm -f $TOPDESTPATH/ppc/ppc32/zImage.lds
		popd
        echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
	elif [ -x $IMGPATH/usr/sbin/wrapper -a -r $IMGPATH/usr/lib/kernel-wrapper/wrapper.a ]; then
		$IMGPATH/usr/sbin/wrapper -o $TOPDESTPATH/images/netboot/ppc32.img	\
					  -i $TOPDESTPATH/ppc/ppc32/ramdisk.image.gz	\
					  -D $IMGPATH/usr/lib/kernel-wrapper		\
					     $TOPDESTPATH/ppc/ppc32/vmlinuz
		rmdir $TOPDESTPATH/images/netboot || :
		popd
		echo "zimage = images/netboot/ppc32.img" >> $TOPDESTPATH/.treeinfo
	fi
    echo >> $TOPDESTPATH/.treeinfo

    else
        echo "Unknown kernel arch: $KERNELARCH"
    fi
}

doPostImages() {
    mkdir -p $TOPDESTPATH/etc
    mkdir -p $TOPDESTPATH/ppc/chrp
	
    # Create ofboot.b and bootinfo.txt files, and yaboot binaries for Mac and CHRP
    cp $BOOTDISKDIR/bootinfo.txt $TOPDESTPATH/ppc/bootinfo.txt
    cp $IMGPATH/usr/lib/anaconda-runtime/boot/efika.forth $TOPDESTPATH/ppc/efika.forth

    if [ -d $TOPDESTPATH/ppc/mac ]; then
	cp $BOOTDISKDIR/ofboot.b $TOPDESTPATH/ppc/mac/ofboot.b
	cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/mac/yaboot
    fi

    if [ -d $TOPDESTPATH/ppc/chrp ]; then
	cp $IMGPATH/usr/lib/yaboot/yaboot $TOPDESTPATH/ppc/chrp/yaboot
	$IMGPATH/usr/lib/yaboot/addnote $TOPDESTPATH/ppc/chrp/yaboot
    fi

    # IBM firmware can't handle boot scripts properly, so for biarch installs
    # we use a yaboot.conf which asks the user to select 32-bit or 64-bit kernel. 
    if [ -r $TOPDESTPATH/ppc/ppc32/yaboot.conf -a -r $TOPDESTPATH/ppc/ppc64/yaboot.conf ]; then
        # Both kernels exist. Copy the biarch yaboot.conf into place.
        sed -e "s/%BITS%/32/" -e "s/%PRODUCT%/$PRODUCT/" -e "s/%VERSION%/$VERSION/" \
	    $BOOTDISKDIR/yaboot.conf.3264 > $TOPDESTPATH/etc/yaboot.conf
    else
	# Copy the one that exists, assuming one does exist
	cp $TOPDESTPATH/ppc/ppc??/yaboot.conf $TOPDESTPATH/etc
    fi

    if [ -z "$BOOTISO" ]; then
	return
    fi

    # Copy it all into the isopath for the boot CD
    mkdir -p $TOPDESTPATH/isopath
    cp -r $TOPDESTPATH/{ppc,etc} $TOPDESTPATH/isopath

    # We want the ppc32 prep image in the boot.iso too.
    if [ -d $TOPDESTPATH/images/netboot ]; then
	mkdir -p $TOPDESTPATH/isopath/images
	cp -r $TOPDESTPATH/images/netboot $TOPDESTPATH/isopath/images
	rm -f $TOPDESTPATH/isopath/images/ppc64.img
    fi

    rm -rf $TOPDESTPATH/isopath/ppc/iSeries

    if [ -r $TOPDESTPATH/isopath/images/netboot/ppc32.img ]; then
	PREPBOOT="-prep-boot images/netboot/ppc32.img"
    fi

    if [ -d $TOPDESTPATH/isopath/ppc/mac ]; then
	MACBOOT="-hfs-volid $VERSION -hfs-bless $TOPDESTPATH/isopath/ppc/mac"
    fi

    # Create the boot.iso
    mkisofs -o $TOPDESTPATH/images/$BOOTISO -chrp-boot -U $PREPBOOT \
	-part -hfs -T -r -l -J -A "$PRODUCT $VERSION" -sysid PPC \
	-V "PBOOT" -volset "$VERSION" -volset-size 1 -volset-seqno 1 \
	$MACBOOT \
	-map $BOOTDISKDIR/mapping -magic $BOOTDISKDIR/magic \
	-no-desktop -allow-multidot -graft-points $TOPDESTPATH/isopath \
	images/stage2.img=$TOPDESTPATH/images/stage2.img
    implantisomd5 $TOPDESTPATH/images/$BOOTISO
    rm -rf $TOPDESTPATH/isopath
}