PFS= pfs
.endif
KERNEL= kernel
+# PROGRAMS are in the order they should be loaded by boot
PROGRAMS= \
../servers/ds/ds \
../servers/rs/rs \
image: includes services
${PAD_KERNEL_TEXT}
mkimage $(PROGRAMS)
- cp ${KERNEL} ${PROGRAMS} /boot
- strip -s ${KERNEL:T:S/^/\/boot\//} ${PROGRAMS:T:S/^/\/boot\//}
+ strip -s ${KERNEL} ${PROGRAMS}
.else
image: includes services
${PAD_KERNEL_TEXT}
.if ${OBJECT_FMT} == "ELF"
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
hdboot: image
- exec sh mkboot $@
+ exec sh mkboot $@ image
@sync
.endif
# mkboot 2.0 - make boot floppy, make root device bootable, etc.
# 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
mdec=/usr/mdec # bootstraps
# Check arguments.
case "$#:$1" in
-1:bootable | 1:hdboot | [12]:fdboot )
+1:bootable | 2:hdboot | [12]:fdboot )
action=$1 dev=$2 size=$3
;;
-*) echo "Usage: $0 [bootable | hdboot | fdboot [device]]" >&2
- exit 1
+*) usage
esac
+if [ "$1" = "hdboot" ]
+then
+ if [ "$2" != "image" -a "$2" != "minix" ]
+ then usage
+ fi
+ hdboot_t="$2"
+fi
+
# Get the device table.
FSTAB=/etc/fstab
touch $FSTAB
;;
hdboot)
# 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
- # /boot/image is not yet a directory! Fix it.
+ # /boot/$hdboot_t is not yet a directory! Fix it.
su root -c \
- "exec mv $rootdir/boot/image /M"
- install -d $rootdir/boot/image
+ "exec mv $rootdir/boot/$hdboot_t /M"
+ install -d $rootdir/boot/$hdboot_t
su root -c \
- "exec mv $rootdir/M $rootdir/boot/image/`uname -r`"
+ "exec mv $rootdir/M $rootdir/boot/$hdboot_t/`uname -r`"
fi
sh tell_config OS_RELEASE . OS_VERSION >/tmp/mkb.$$
target="${version}${rrevision}${gitrev}"
- set -- `ls -t $rootdir/boot/image`
+ rotate_oldest "$rootdir/boot/$hdboot_t"
- case $# in
- 0|1|2|3)
- # Not much there, do not remove a thing.
- ;;
- *)
- # Remove the third-newest image in /boot/image, but
- # only if there's an older one (which is kept).
- echo "rm $root:/boot/image/$3"
- rm -f "$rootdir/boot/image/$3"
- esac
-
- # Install the new image.
- echo "install image $root:/boot/image/$target"
- install -o root -m 600 image $rootdir/boot/image/$target || exit
+ # rotate system processes. We assume latest ones are in
+ # /boot/modules/.temp and we maintain /boot/modules/ by ourselves.
+ if [ "$hdboot_t" = "minix" ]
+ then
+ [ -d /boot/minix/.temp ] || exit 1
+ mv /boot/minix/.temp /boot/minix/"$target"
+ rm -f /boot/minix_latest
+ ln -s /boot/minix/"$target" /boot/minix_latest
+ else
+ # 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
- # 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
+ # Tell bootloader which image is newest
+ ln -f $rootdir/boot/$hdboot_t/$target $rootdir/boot/${hdboot_t}_latest
fi
- ln -f $image_latest $rootdir/boot/image_latest
# Save the revision number.
test "$revision" != "$oldrev" && echo $revision >revision