| 1 |
#!/bin/bash -e
|
| 2 |
# powerpc initrd inbuilder script.
|
| 3 |
# Sven Luther, MArch 2004
|
| 4 |
# This is free software under the GNU General Public License.
|
| 5 |
|
| 6 |
# May also be set in Makefile
|
| 7 |
arch=${architecture:-$(dpkg --print-architecture)}
|
| 8 |
|
| 9 |
# Print a usage message and exit if the argument count is wrong.
|
| 10 |
if [ $# != 6 ]; then
|
| 11 |
echo "Usage: $0 vmlinux System.map initrd.gz builddir destdir kvers" 1>&2
|
| 12 |
cat 1>&2 << EOF
|
| 13 |
|
| 14 |
vmlinux: the plain uncompressed powerpc/elf Linux kernel.
|
| 15 |
System.map: uncompressed System.map.
|
| 16 |
initrd.gz: a compressed disk image to load in ramdisk and mount as root.
|
| 17 |
builddir: temporary directory where the kernel-build tree is unpacked to.
|
| 18 |
destdir: destination directory for the kernel images with builtin initrd.
|
| 19 |
kvers: version of the kernel to build
|
| 20 |
EOF
|
| 21 |
|
| 22 |
exit -1
|
| 23 |
fi
|
| 24 |
|
| 25 |
# Set this to the location of the kernel
|
| 26 |
kernel=$1
|
| 27 |
|
| 28 |
# Set this to the path of the compressed System.map
|
| 29 |
sysmap=$2
|
| 30 |
|
| 31 |
# Set this to the path of the compressed initrd
|
| 32 |
initrd=$3
|
| 33 |
|
| 34 |
# Set this to the path of the temporary build directory
|
| 35 |
builddir=$4
|
| 36 |
|
| 37 |
# Set this to the path of the destination directory
|
| 38 |
destdir=$5
|
| 39 |
|
| 40 |
# Set this to the kernel version used.
|
| 41 |
kvers=$6
|
| 42 |
|
| 43 |
# Make sure the files are available, $sysmap can be /dev/null
|
| 44 |
for file in "$kernel" "$initrd"; do
|
| 45 |
if [ ! -f $file ]; then
|
| 46 |
echo "error: could not find $file"
|
| 47 |
exit 1
|
| 48 |
fi
|
| 49 |
done
|
| 50 |
|
| 51 |
# Make sure the directories are available
|
| 52 |
for file in "$builddir" "$destdir"; do
|
| 53 |
if [ ! -d $file ]; then
|
| 54 |
echo "error: $file inexistand or not a directory"
|
| 55 |
exit 1
|
| 56 |
fi
|
| 57 |
done
|
| 58 |
|
| 59 |
# Unpack the kernel source tree, if not present.
|
| 60 |
tar -C $builddir -xjf /usr/src/kernel-build-$kvers.tar.bz2
|
| 61 |
|
| 62 |
# Copy kernel, System.map and initrd to the build tree.
|
| 63 |
cp $kernel $builddir/kernel-build-$kvers
|
| 64 |
cp $sysmap $builddir/kernel-build-$kvers
|
| 65 |
cp $initrd $builddir/kernel-build-$kvers/arch/ppc/boot/images/ramdisk.image.gz
|
| 66 |
|
| 67 |
# Cleanup.
|
| 68 |
for i in `find $builddir/kernel-build-$kvers -name \*.o`; do touch $i; done
|
| 69 |
rm -f $builddir/kernel-build-$kvers/arch/ppc/boot/chrp/image.o
|
| 70 |
rm -f `find $builddir/kernel-build-$kvers -name .depend`
|
| 71 |
|
| 72 |
# Actual build of the kernels with builtin initrd.
|
| 73 |
make -C $builddir/kernel-build-$kvers/arch/ppc/boot \
|
| 74 |
TOPDIR=$builddir/kernel-build-$kvers OBJCOPY=objcopy \
|
| 75 |
CONFIG_ALL_PPC=y CONFIG_VGA_CONSOLE=y \
|
| 76 |
CONFIG_SERIAL_CONSOLE=y zImage.initrd
|
| 77 |
|
| 78 |
# Copying build directories to destdir.
|
| 79 |
for subarch in chrp chrp-rs6k prep; do
|
| 80 |
cp $builddir/kernel-build-$kvers/arch/ppc/boot/images/zImage.initrd.$subarch \
|
| 81 |
$destdir/vmlinuz-$subarch.initrd
|
| 82 |
done
|
| 83 |
|
| 84 |
exit 0
|