#!/bin/sh

# debian/post-install for kernel-patch-powerpc

# written by Jens Schmalzing <jensen@debian.org>

# This shell script is intended to be put into the debian subdirectory
# of a Linux kernel tree, where make-kpkg will find and execute it
# while building a kernel-image package.  The purpose of this script
# is to add glue (object code, libraries, utilities and so on) from
# the kernel tree to the kernel-image package.  Later, the mkvmlinuz
# utility, which is available as a separate Debian package, can use
# this glue to create a bootable compressed kernel from the
# uncompressed kernel in the kernel-image package and optionally a
# ramdisk.  This is especially important on PowerPC subarchitectures
# that don't have a boot loader, but also comes handy for rescue
# systems and the like.

KSRC=${PWD}
KLIB=${PWD}/${IMAGE_TOP}/usr/lib/kernel-image-${version}
INSTALL_DATA="install -m 644 -o root -g root"
INSTALL_EXEC="install -m 755 -o root -g root"

# get rid of the coff image (not strictly necessary, but cleaner)

rm -f ${IMAGE_TOP}/boot/vmlinux.coff-${version}

# add glue for creating bootable compressed kernel images

mkdir -p ${KLIB}/boot
cd ${KSRC}/arch/ppc/boot
${INSTALL_DATA} ld.script openfirmware/note ${KLIB}/boot

mkdir -p ${KLIB}/lib
cd ${KSRC}
${INSTALL_DATA} lib/lib.a ${KLIB}/lib
${INSTALL_DATA} arch/ppc/boot/lib/lib.a ${KLIB}/lib/ppc.a
${INSTALL_DATA} arch/ppc/boot/common/lib.a ${KLIB}/lib/common.a
${INSTALL_DATA} arch/ppc/boot/of1275/lib.a ${KLIB}/lib/of.a

mkdir -p ${KLIB}/obj/openfirmware
cd ${KSRC}/arch/ppc/boot/openfirmware
${INSTALL_DATA} *.o ${KLIB}/obj/openfirmware
rm -f ${KLIB}/obj/openfirmware/image*

mkdir -p ${KLIB}/obj/simple
cd ${KSRC}/arch/ppc/boot/simple
${INSTALL_DATA} *.o ${KLIB}/obj/simple
rm -f ${KLIB}/obj/simple/image*.o

mkdir -p ${KLIB}/utils
cd ${KSRC}/arch/ppc/boot/utils
${INSTALL_EXEC} addnote hack-coff mkbugboot mknote mkprep mktree ${KLIB}/utils
