Rotate kernels/images/modules.

Kernels and system services are stored in a single directory in the
/boot/minix/ and rotated like /boot/images. /boot/minix_latest slink
is created automatically.
System serives are prefixed by "modNN_" to allow to easily load them
using "mod*" pattern.
This commit is contained in:
Evgeniy Ivanov 2012-01-30 16:27:23 +04:00 committed by Ben Gras
parent 60a2ce010a
commit 8979450631
3 changed files with 67 additions and 32 deletions

View file

@ -8,6 +8,7 @@
755 root operator /etc/system.conf.d 755 root operator /etc/system.conf.d
755 root operator /boot 755 root operator /boot
755 root operator /boot/image 755 root operator /boot/image
755 root operator /boot/minix
555 root operator /mnt 555 root operator /mnt
555 root operator /proc 555 root operator /proc
700 root operator /root 700 root operator /root

View file

@ -17,6 +17,7 @@ VFS= vfs
PFS= pfs PFS= pfs
.endif .endif
KERNEL= kernel KERNEL= kernel
# PROGRAMS are in the order they should be loaded by boot
PROGRAMS= \ PROGRAMS= \
../servers/ds/ds \ ../servers/ds/ds \
../servers/rs/rs \ ../servers/rs/rs \
@ -70,8 +71,7 @@ PAD_KERNEL_TEXT := padtext ../kernel/kernel kernel
image: includes services image: includes services
${PAD_KERNEL_TEXT} ${PAD_KERNEL_TEXT}
mkimage $(PROGRAMS) mkimage $(PROGRAMS)
cp ${KERNEL} ${PROGRAMS} /boot strip -s ${KERNEL} ${PROGRAMS}
strip -s ${KERNEL:T:S/^/\/boot\//} ${PROGRAMS:T:S/^/\/boot\//}
.else .else
image: includes services image: includes services
${PAD_KERNEL_TEXT} ${PAD_KERNEL_TEXT}
@ -113,9 +113,20 @@ bootable:
.if ${OBJECT_FMT} == "ELF" .if ${OBJECT_FMT} == "ELF"
hdboot: image hdboot: image
rm -rf /boot/minix/.temp/
mkdir -p /boot/minix/.temp
# mod_0 is used to make alphabetical order equal to the boot order
for i in ${PROGRAMS}; \
do \
let n=n+1 >/dev/null; \
[ "$$n" -ge 10 ] && prefix="mod" || prefix="mod0"; \
cp $$i /boot/minix/.temp/$${prefix}$${n}_`basename $$i`;\
done
cp kernel /boot/minix/.temp/
exec sh mkboot $@ minix
.else .else
hdboot: image hdboot: image
exec sh mkboot $@ exec sh mkboot $@ image
@sync @sync
.endif .endif

View file

@ -3,19 +3,48 @@
# mkboot 2.0 - make boot floppy, make root device bootable, etc. # mkboot 2.0 - make boot floppy, make root device bootable, etc.
# Author: Kees J. Bot # Author: Kees J. Bot
usage() {
echo "Usage: $0 [bootable | hdboot [minix or image] | fdboot [device]]" >&2
exit 1
}
rotate_oldest() {
base_dir="$1"
set -- `ls -t "$base_dir"`
case $# in
0|1|2|3)
# Not much there, do not remove a thing.
;;
*)
# Remove the third-newest $hdboot_t in /boot/$hdboot_t, but
# only if there's an older one (which is kept).
echo "rm $root:$base_dir/$3"
rm -rf "$base_dir/$3"
esac
}
trap 'e=$?; rm -f /tmp/mkb.$$; exit $e' 0 2 trap 'e=$?; rm -f /tmp/mkb.$$; exit $e' 0 2
mdec=/usr/mdec # bootstraps mdec=/usr/mdec # bootstraps
# Check arguments. # Check arguments.
case "$#:$1" in case "$#:$1" in
1:bootable | 1:hdboot | [12]:fdboot ) 1:bootable | 2:hdboot | [12]:fdboot )
action=$1 dev=$2 size=$3 action=$1 dev=$2 size=$3
;; ;;
*) echo "Usage: $0 [bootable | hdboot | fdboot [device]]" >&2 *) usage
exit 1
esac esac
if [ "$1" = "hdboot" ]
then
if [ "$2" != "image" -a "$2" != "minix" ]
then usage
fi
hdboot_t="$2"
fi
# Get the device table. # Get the device table.
FSTAB=/etc/fstab FSTAB=/etc/fstab
touch $FSTAB touch $FSTAB
@ -56,14 +85,14 @@ bootable)
;; ;;
hdboot) hdboot)
# Install a new image on the root device. # Install a new image on the root device.
if [ ! -d $rootdir/boot/image ] if [ -e $rootdir/boot/$hdboot_t -a ! -d $rootdir/boot/$hdboot_t ]
then then
# /boot/image is not yet a directory! Fix it. # /boot/$hdboot_t is not yet a directory! Fix it.
su root -c \ su root -c \
"exec mv $rootdir/boot/image /M" "exec mv $rootdir/boot/$hdboot_t /M"
install -d $rootdir/boot/image install -d $rootdir/boot/$hdboot_t
su root -c \ su root -c \
"exec mv $rootdir/M $rootdir/boot/image/`uname -r`" "exec mv $rootdir/M $rootdir/boot/$hdboot_t/`uname -r`"
fi fi
sh tell_config OS_RELEASE . OS_VERSION >/tmp/mkb.$$ sh tell_config OS_RELEASE . OS_VERSION >/tmp/mkb.$$
@ -97,30 +126,24 @@ hdboot)
target="${version}${rrevision}${gitrev}" target="${version}${rrevision}${gitrev}"
set -- `ls -t $rootdir/boot/image` rotate_oldest "$rootdir/boot/$hdboot_t"
case $# in # rotate system processes. We assume latest ones are in
0|1|2|3) # /boot/modules/.temp and we maintain /boot/modules/ by ourselves.
# Not much there, do not remove a thing. if [ "$hdboot_t" = "minix" ]
;; then
*) [ -d /boot/minix/.temp ] || exit 1
# Remove the third-newest image in /boot/image, but mv /boot/minix/.temp /boot/minix/"$target"
# only if there's an older one (which is kept). rm -f /boot/minix_latest
echo "rm $root:/boot/image/$3" ln -s /boot/minix/"$target" /boot/minix_latest
rm -f "$rootdir/boot/image/$3" else
esac # Install the new image.
echo "install $hdboot_t $root:/boot/$hdboot_t/$target"
install -o root -m 600 $hdboot_t $rootdir/boot/$hdboot_t/$target || exit 1
# Install the new image. # Tell bootloader which image is newest
echo "install image $root:/boot/image/$target" ln -f $rootdir/boot/$hdboot_t/$target $rootdir/boot/${hdboot_t}_latest
install -o root -m 600 image $rootdir/boot/image/$target || exit
# Tell GRUB which image is newest
image_latest="`ls -t $rootdir/boot/image | head -n 1`"
if [ -f "$rootdir/boot/image/$image_latest" ]
then image_latest="/boot/image/$image_latest"
else image_latest=/boot/image_big
fi fi
ln -f $image_latest $rootdir/boot/image_latest
# Save the revision number. # Save the revision number.
test "$revision" != "$oldrev" && echo $revision >revision test "$revision" != "$oldrev" && echo $revision >revision