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 trap 'e=$?; rm -f /tmp/mkb.$$; exit $e' 0 2
30 mdec
=/usr
/mdec
# bootstraps
31 # If no DESTDIR specified, then act on / or on the current chroot
35 1:bootable |
1:hdboot
)
36 # LSC Broken, if $# == 1, then $2,$3 are not set...
39 2:bootable |
2:hdboot
)
45 # Get the device table.
48 if grep -q "Poor man" $FSTAB
50 else root
="`awk <$FSTAB '{ if($2=="/") { print $1 } }'`"
53 # The real root device may be the RAM disk.
54 realroot
=`printroot -r`
56 # If it's an initial fstab, pretend root is real root
57 if [ "$root" = "/dev/ROOT" -o -z "$root" ]
63 # We need the root device.
65 if [ $realroot = $root ]
69 umount
$root 2>/dev
/null
70 mount
$root /mnt ||
exit
77 sh tell_config OS_RELEASE . OS_VERSION
>/tmp
/mkb.$$
78 version
=`sed 's/[" ]//g;/^$/d' </tmp/mkb.$$`
80 # Retrieve the git revision; this only succeeds
81 # if git is available, it's a git checkout, *and*
82 # there are no uncommitted changes.
83 if git
diff --quiet 2>/dev
/null
84 then gitrev
="-`git describe --always`"
87 revision
=`cat revision 2>/dev/null`
92 else rrevision
=r
$revision
102 revision
=`expr $revision + 1`
106 target
="${version}${rrevision}${gitrev}"
108 rotate_oldest
"$DESTDIR/boot/minix"
110 # rotate system processes. We assume latest ones are in
111 # /boot/modules/.temp and we maintain /boot/modules/ by ourselves.
112 [ -d $DESTDIR/boot
/minix
/.temp
] ||
exit 1
113 rm -rf $DESTDIR/boot
/minix
/"$target"/
114 mv $DESTDIR/boot
/minix
/.temp
$DESTDIR/boot
/minix
/"$target"
115 rm -f $DESTDIR/boot
/minix_latest
116 ln -s minix
/"$target" $DESTDIR/boot
/minix_latest
118 # Save the revision number.
119 test "$revision" != "$oldrev" && echo $revision >revision
121 test $realroot != $root && umount
$root