#!/bin/bash
#
# 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 kernels and kernel module packages:
rm -fv ~/tgzstash/a/kernel*{versatile,kirkwood,armv7}*

# 04-Dec-2012: We we-pack x86's firmware package (which is built from a separate
#              git repo).
#
# 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*

# Wipe the old installer images:
rm -fv ~/ac/isolinux/*initrd*

dbuild           || exit 1 # Build Versatile kernel
dbuild armv7     || exit 1 # Build generic ARMv7 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
dbuild
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

# Manual visual check for size & date stamp:
ls -lah ~/ac/isolinux | grep -i init
