#!/bin/bash
#
# I'm getting more efficient/lazy now.
# This is only run when I've tested stuff and just make a few tweaks 
# to the packages, and want to be sure the packages are 
# all up to date -- I tend to lose track of what packages I put where,
# so this is just the script to rebuild everything once again
# prior to a complete reinstallation of the dev boxes.
# 
# Build:
#  * Versatile Kernel;
#  * Linux Kernel source package;
#  * Linux Kernel modules all-in-one package
#
#./versatile && \

# Wipe existing versatile & kirkwood kernels and kernel module packages:
# but not the (temporary) OpenRD since we're building that separately!
rm -fv ~/tgzstash/a/kernel*{versatile,kirkwood}*
# Wipe the firmware package too (although the build script takes care 
# of this since it uses "slackmp", but let's do it anyway for good measure
# and cleanliness:
rm -fv ~/tgzstash/a/kernel-firmware*

dbuild          || exit 1 # Build Versatile kernel
dbuild kirkwood || exit 1 # Build Kirkwood kernel
./kernel-sourcepackage.SlackBuild || exit 1

# Support packages:
cd ../a/kernel-modules/ && ./arm/build || exit 1
cd ../kernel-firmware/  && ./arm/build || exit 1

# and then 
# you wanna .. update the bootware for the RiscPC, so
# you've also updated the KERNELVERSION variable in 'grub.brew'..
#cd ~/ac/source/bootware/riscos/
# ~/armedslack/dbuild
# We don't support the RiscPC anymore.
# Sept 2008.

# And finally, let's plop the new zImage for the Versatile board
# onto my dev box, so I can pull it off and boot qemu into the installer
# and run an installation test.  Of course, the RiscPC requires more effort
# which is why I don't do it as often as I ought to.
# cp -favv ~/tmp/build-kernel_versatile/linux-*/arch/arm/boot/zImage /mnt/prisroot/tmp/zImage-versatile

# And now build the Kernel headers.
# I don't usually do this but on this occasion I want to rebuild
# glibc afterwards:
#
#cd ~/ac/source/d/kernel-headers
#./arm/build
#ui ~/tgzstash/d/kernel-headers*.t?z 

# Rebuild glibc against the new Kernel.
# glibc has been setup in advance with the new version numbers and
# package build number.
#cd ~/ac/source/l/glibc
#dbuild

# And FINALLY, if we've updated to a newer Kernel, we probably need
# to refresh the Kernel modules in the installer:
cd ~/ac/source/installer
~/armedslack/dbuild
# Copy the new kernels & installers into prisere's tftpboot:
./populate_tftpboot_onprisere

# Temporary:
# Now build the OpenRD client's kernel & installer
#cd ~/armedslack/armedslack-devtools/openrd-client/sources/
#./bwl
