3 # mkboot 2.0 - make root device bootable, etc.
7 echo "Usage: $0 [bootable | hdboot]" >&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
34 1:bootable |
1:hdboot
)
35 action
=$1 dev
=$2 size
=$3
40 # Get the device table.
43 if grep -q "Poor man" $FSTAB
45 else 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 sh tell_config OS_RELEASE . OS_VERSION
>/tmp
/mkb.$$
73 version
=`sed 's/[" ]//g;/^$/d' </tmp/mkb.$$`
75 # Retrieve the git revision; this only succeeds
76 # if git is available, it's a git checkout, *and*
77 # there are no uncommitted changes.
78 if git
diff --quiet 2>/dev
/null
79 then gitrev
="-`git describe --always`"
82 revision
=`cat revision 2>/dev/null`
87 else rrevision
=r
$revision
97 revision
=`expr $revision + 1`
101 target
="${version}${rrevision}${gitrev}"
103 rotate_oldest
"$rootdir/boot/minix"
105 # rotate system processes. We assume latest ones are in
106 # /boot/modules/.temp and we maintain /boot/modules/ by ourselves.
107 [ -d /boot
/minix
/.temp
] ||
exit 1
108 rm -rf /boot
/minix
/"$target"/
109 mv /boot
/minix
/.temp
/boot
/minix
/"$target"
110 rm -f /boot
/minix_latest
111 ln -s minix
/"$target" /boot
/minix_latest
113 # Save the revision number.
114 test "$revision" != "$oldrev" && echo $revision >revision
116 test $realroot != $root && umount
$root