summaryrefslogtreecommitdiffstats
path: root/scripts/mk-images.ppc
blob: 7d338baeeb5de3876b4ba839e7e57335b7975460 (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
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"

	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

	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
	fi


    elif [ "$KERNELARCH" = "ppc64iseries" ]; then
	mkdir -p $TOPDESTPATH/ppc/iSeries
	mkdir -p $TOPDESTPATH/images/iSeries

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

	cp $KERNELROOT/boot/vmlinuz-* $TOPDESTPATH/ppc/iSeries/vmlinux
	cp $KERNELROOT/boot/System.map-* $TOPDESTPATH/ppc/iSeries/System.map

	$IMGPATH/usr/sbin/addSystemMap $TOPDESTPATH/ppc/iSeries/System.map $TOPDESTPATH/ppc/iSeries/vmlinux $TOPDESTPATH/ppc/iSeries/vmlinux.sm
	$IMGPATH/usr/sbin/addRamDisk $TOPDESTPATH/ppc/iSeries/ramdisk.image.gz $TOPDESTPATH/ppc/iSeries/System.map $TOPDESTPATH/ppc/iSeries/vmlinux.sm $TOPDESTPATH/images/iSeries/boot.img
	rm -f $TOPDESTPATH/ppc/iSeries/vmlinux.sm

    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

	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/ppc64/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/ppc64/zImage.lds
		popd
	fi

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

doPostImages() {
    # Create boot.iso here instead of above, so we can include it all
    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

    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

    # 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/boot.iso -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 $TOPDESTPATH/isopath
    rm -rf $TOPDESTPATH/isopath
}