3 # mkboot 2.0 - make root device bootable, etc.
7 echo "Usage: $0 [bootable | hdboot] [DESTDIR]" >&2
13 set -- `ls -t "$base_dir"`
17 # Not much there, do not remove a thing.
20 # Remove the third-newest image in /boot/$hdboot_t, but
21 # only if there's an older one (which is kept).
22 echo "rm $root:$base_dir/$3"
28 mdec
=/usr
/mdec
# bootstraps
29 # If no DESTDIR specified, then act on / or on the current chroot
33 1:bootable |
1:hdboot
)
34 # LSC Broken, if $# == 1, then $2,$3 are not set...
37 2:bootable |
2:hdboot
)
43 # Get the device table.
46 root
="`awk <$FSTAB '{ if($2=="/") { print $1 } }'`"
48 # The real root device may be the RAM disk.
49 realroot
=`printroot -r`
51 # If it's an initial fstab, pretend root is real root
52 if [ "$root" = "/dev/ROOT" -o -z "$root" ]
58 # We need the root device.
60 if [ $realroot = $root ]
64 umount
$root 2>/dev
/null
65 mount
$root /mnt ||
exit
72 version
=`sh ../sys/conf/osrelease.sh`
74 # Retrieve the git revision; this only succeeds
75 # if git is available, it's a git checkout, *and*
76 # there are no uncommitted changes.
77 if git
diff --quiet 2>/dev
/null
78 then gitrev
="-`git describe --always`"
81 revision
=`cat revision 2>/dev/null`
91 revision
=`expr $revision + 1`
95 target
="${version}${rrevision}${gitrev}"
97 rotate_oldest
"$DESTDIR/boot/minix"
99 # rotate system processes. We assume latest ones are in
100 # /boot/modules/.temp and we maintain /boot/modules/ by ourselves.
101 [ -d $DESTDIR/boot
/minix
/.temp
] ||
exit 1
102 rm -rf $DESTDIR/boot
/minix
/"$target"/
103 mv $DESTDIR/boot
/minix
/.temp
$DESTDIR/boot
/minix
/"$target"
104 rm -f $DESTDIR/boot
/minix_latest
105 ln -s minix
/"$target" $DESTDIR/boot
/minix_latest
107 # Save the revision number.
108 test "$revision" != "$oldrev" && echo $revision >revision
110 test $realroot != $root && umount
$root