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 if grep -q "Poor man" $FSTAB
48 else root
="`awk <$FSTAB '{ if($2=="/") { print $1 } }'`"
51 # The real root device may be the RAM disk.
52 realroot
=`printroot -r`
54 # If it's an initial fstab, pretend root is real root
55 if [ "$root" = "/dev/ROOT" -o -z "$root" ]
61 # We need the root device.
63 if [ $realroot = $root ]
67 umount
$root 2>/dev
/null
68 mount
$root /mnt ||
exit
75 version
=`sh ../sys/conf/osrelease.sh`
77 # Retrieve the git revision; this only succeeds
78 # if git is available, it's a git checkout, *and*
79 # there are no uncommitted changes.
80 if git
diff --quiet 2>/dev
/null
81 then gitrev
="-`git describe --always`"
84 revision
=`cat revision 2>/dev/null`
94 revision
=`expr $revision + 1`
98 target
="${version}${rrevision}${gitrev}"
100 rotate_oldest
"$DESTDIR/boot/minix"
102 # rotate system processes. We assume latest ones are in
103 # /boot/modules/.temp and we maintain /boot/modules/ by ourselves.
104 [ -d $DESTDIR/boot
/minix
/.temp
] ||
exit 1
105 rm -rf $DESTDIR/boot
/minix
/"$target"/
106 mv $DESTDIR/boot
/minix
/.temp
$DESTDIR/boot
/minix
/"$target"
107 rm -f $DESTDIR/boot
/minix_latest
108 ln -s minix
/"$target" $DESTDIR/boot
/minix_latest
110 # Save the revision number.
111 test "$revision" != "$oldrev" && echo $revision >revision
113 test $realroot != $root && umount
$root