minix/releasetools/release.functions
Jean-Baptiste Boric 2b03b192f0 x86 iso: overhaul creation of installation CD
The CD now boots directly from the ISO 9660 filesystem instead of using
MBR partitioning with Minix file systems. This saves some space on the
CD and reduces memory requirements by some unknown amount as the root
ramdisk is completely eliminated.

The setup is also modified to be more NetBSD-like (unpacking sets
tarballs instead of blindly copying the CD contents). This allows
massive space savings because only the base system used for installation
is stored uncompressed and more modularity (to be exploited at a later
time). The sets themselves are to be refined, but are enough for now.

Those two steps are melded together because copying the CD contents with
isofs as the root filesystem results in some failed tests in
minix-posix, probably due to some obscure corner-case bugs in isofs.

Having a read-only root filesystem outputs some error messages because
it isn't properly supported. Ramdisks on /var and /tmp are used to
mitigate this, but the clean solution would involve union mounts,
something Minix 3 doesn't support for the time being.

Change-Id: Ib4700d9f10c5b4b297e0994b5338847951fc79b4
2015-05-16 13:21:25 +02:00

199 lines
5.8 KiB
Plaintext

make_hdimage()
{
dd if=$TMPDISKUSR of=usrimage bs=$BS count=$USRBLOCKS
rootsize=`stat -f %z rootimage`
usrsize=`stat -f %z usrimage`
rootsects=`expr $rootsize / 512`
usrsects=`expr $usrsize / 512`
# installboot -m needs at least 1KB
dd < /dev/zero >tmpimage count=2
partition -fm tmpimage 2 81:$rootsects* 0:0 81:$usrsects
installboot_nbsd -m tmpimage /usr/mdec/mbr
dd < tmpimage > subpart count=1
primsects=`expr 1 + $rootsects + $usrsects`
cyl=`expr '(' $primsects ')' / $secs + 1`
padsects=`expr $cyl \* $secs - 1 - $primsects`
{ dd < /dev/zero count=1
cat subpart
cat rootimage
cat usrimage
dd < /dev/zero count=$padsects
} > hdimage
partition -m hdimage 81:`expr $primsects + $padsects`*
installboot_nbsd -m hdimage /usr/mdec/mbr
}
retrieve()
{
dir=$1
list=`pwd`/$2
URLS=""
echo "Retrieving packages form $PACKAGEURL"
(
cd $dir || exit 1
SUMMARY=pkg_summary
rm -f pkg_summary* || true
fetch $PACKAGEURL/$SUMMARY.bz2
bzip2 -d $SUMMARY.bz2
cat $list | while read name
do pkgname="`fgrep PKGNAME=${name} $SUMMARY | sed 's/PKGNAME=//g'`"
if [ `echo $pkgname | wc -w` -ne 1 ]
then echo " *** Could not resolve $name (not found or too many matches: $pkgname) ***"
echo Matches:
echo $pkgname
exit 1
else echo Getting $pkgname
fetch -r ${PACKAGEURL}/${pkgname}.tgz
fi
echo -n "."
done
)
echo done
}
cd_root_changes()
{
cat >$WORK_DIR/boot.cfg <<END_BOOT_CFG
banner=Welcome to the MINIX 3 installation CD
banner================================================================================
banner=
menu=Regular MINIX 3:multiboot /boot/minix/.temp/kernel bootcd=1 cdproberoot=1 rootdevname=ram disable=inet
menu=Regular MINIX 3 (with AHCI):multiboot /boot/minix/.temp/kernel bootcd=1 cdproberoot=1 rootdevname=ram disable=inet ahci=yes
menu=Edit menu option:edit
menu=Drop to boot prompt:prompt
clear=1
timeout=10
default=1
load=/boot/minix/.temp/mod01_ds
load=/boot/minix/.temp/mod02_rs
load=/boot/minix/.temp/mod03_pm
load=/boot/minix/.temp/mod04_sched
load=/boot/minix/.temp/mod05_vfs
load=/boot/minix/.temp/mod06_memory
load=/boot/minix/.temp/mod07_tty
load=/boot/minix/.temp/mod08_mfs
load=/boot/minix/.temp/mod09_vm
load=/boot/minix/.temp/mod10_pfs
load=/boot/minix/.temp/mod11_init
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
# This space intentionally left blank - leave to appease bootloader!
END_BOOT_CFG
}
copy_local_packages()
{
if [ -d $PACKAGEDIR -a -f $PACKAGELIST -a $PACKAGES -ne 0 ]
then
index=pkg_summary
indexpath=$PACKAGEDIR/.index
if [ ! -d $indexpath ]
then mkdir $indexpath
fi
if [ ! -d $indexpath ]
then echo "Couldn't create $indexpath."
exit 1
fi
echo "" >$PACKAGEDIR/All/$index
echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE"
for pkgprefix in `cat $PACKAGELIST`
do realfn="`echo $PACKAGEDIR/All/${pkgprefix}*.tgz`"
if [ -f "$realfn" ]
then
# Copy package and create package's index
(
p="`basename $realfn`"
cd $PACKAGEDIR/All
cp $p $RELEASEPACKAGE/
indexname=$indexpath/$p.$index
pkg_info -X $p >$indexname
if [ ! -f $indexname ]
then echo Missing $indexname.
exit 1
fi
if [ "`wc -l <$indexname`" -lt 3 ]
then $indexname is too short.
rm $indexname
exit 1
fi
cat $indexname >>$PACKAGEDIR/All/$index
)
else
echo "Can't find $pkgprefix Missing."
fi
done
bzip2 -f $PACKAGEDIR/All/$index
cp $PACKAGEDIR/All/$index.bz2 $RELEASEPACKAGE/
fi
}
fitfs()
{
path="$1"
ramdisk="$2"
extra_inodes="$3"
extra_zones="$4"
mbsdefault="$5"
# Determine number of inodes
inodes=`find $path | egrep -v ^$path/usr | wc -l`
inodes="`expr $inodes + $extra_inodes`"
# Determine number of data zones
zonekbs=`du -ks $path | cut -d' ' -f1`
zonekbsignore=0
[ ! -d $path/usr ] || zonekbsignore=`du -ks $path/usr | cut -d" " -f1`
zones="`expr \( $zonekbs - $zonekbsignore \) / \( $BS / 1024 \) + $extra_zones`"
# Determine file system size
BSBITS="`expr $BS \* 8`"
imap_blocks="`expr \( $inodes + $BSBITS - 1 \) / $BSBITS`"
inode_blocks="`expr \( $inodes \* 64 + $BS - 1 \) / $BS`"
zmap_blocks="`expr \( $zones + $BSBITS - 1 \) / $BSBITS`"
blocks="`expr 1 + 1 + $imap_blocks + $zmap_blocks + $inode_blocks + $zones`"
kbs="`expr $blocks \* \( $BS / 1024 \)`"
# Apply default if higher
if [ -n "$mbsdefault" ]
then
kbsdefault="`expr $mbsdefault \* 1024`"
if [ "$kbs" -lt "$kbsdefault" ]
then kbs=$kbsdefault
else echo "warning: ${mbsdefault}mb is too small, using ${kbs}kb"
fi
fi
# Create a filesystem on the target ramdisk
ramdisk $kbs $ramdisk
mkfs.mfs -B $BS -i $inodes $ramdisk
}