New image framework generation
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 x86 hard drive image creation is also rewritten in the same fashion. The setup is modified to be more NetBSD-like (unpacking sets tarballs instead of blindly copying the CD contents). Splitting MINIX into sets is done in another commit due to it being a nightmare to rebase. Since MINIX lacks union mounts for now, a bunch of ramdisks are generated at run-time to make parts of the filesystem writeable for the CD. This solution isn't ideal, but it's enough for an installation CD. Change-Id: Icbd9cca4dafebf7b42c345b107a17679a622d5cd
This commit is contained in:
parent
b5400f9ff4
commit
69eead77ff
20 changed files with 762 additions and 371 deletions
49
etc/rc
49
etc/rc
|
@ -1,5 +1,8 @@
|
|||
# /etc/rc - System startup script run by init before going multiuser.
|
||||
|
||||
# Are we booting from CD?
|
||||
bootcd="`/bin/sysenv bootcd`"
|
||||
|
||||
exec >/dev/log
|
||||
exec 2>/dev/log
|
||||
exec </dev/null
|
||||
|
@ -64,7 +67,7 @@ edit()
|
|||
if [ ! -x $binlocation ]
|
||||
then binlocation=/sbin/$service
|
||||
fi
|
||||
service $opt edit $binlocation -label $service "$@"
|
||||
service $opt edit $binlocation -label $service "$@"
|
||||
}
|
||||
|
||||
while getopts 'saf' opt
|
||||
|
@ -87,6 +90,11 @@ esac
|
|||
|
||||
case $action in
|
||||
autoboot|start)
|
||||
# If booting from CD, we want some directories to be ramdisks
|
||||
if [ ! -z "$bootcd" ]
|
||||
then
|
||||
. /etc/rc.cd
|
||||
fi
|
||||
|
||||
# National keyboard?
|
||||
test -f /etc/keymap && loadkeys /etc/keymap
|
||||
|
@ -106,7 +114,8 @@ autoboot|start)
|
|||
# Set timezone.
|
||||
export TZ=GMT0
|
||||
if [ -f "$RC_TZ" ]
|
||||
then . "$RC_TZ"
|
||||
then
|
||||
. "$RC_TZ"
|
||||
fi
|
||||
|
||||
# Start real time clock driver & set system time, otherwise default date.
|
||||
|
@ -114,11 +123,10 @@ autoboot|start)
|
|||
readclock -q || date 201301010000
|
||||
|
||||
# We are not shutting down.
|
||||
rm -f /etc/nologin
|
||||
|
||||
# Initialize files.
|
||||
>/var/run/utmp # /etc/utmp keeps track of logins
|
||||
>/var/run/utmpx # /etc/utmpx keeps track of logins
|
||||
if [ -f /etc/nologin ]
|
||||
then
|
||||
rm -f /etc/nologin
|
||||
fi
|
||||
|
||||
# Use MFS binary only from kernel image?
|
||||
if [ "`sysenv bin_img`" = 1 ]
|
||||
|
@ -126,25 +134,18 @@ autoboot|start)
|
|||
bin_img="-i "
|
||||
fi
|
||||
|
||||
# Are we booting from CD?
|
||||
bootcd="`/bin/sysenv bootcd`"
|
||||
|
||||
# If booting from CD, mounting is a special case.
|
||||
# We know what to do - only /usr is mounted and it's readonly.
|
||||
if [ "$bootcd" = 1 ]
|
||||
then usrdev="$cddev"p2
|
||||
echo "/usr on cd is $usrdev"
|
||||
mount -r $usrdev /usr
|
||||
else
|
||||
# If we're not booting from CD, fsck + mount using /etc/fstab.
|
||||
fsck -x / $fflag $fsckopts
|
||||
mount -a
|
||||
fi
|
||||
# fsck + mount using /etc/fstab.
|
||||
fsck -x / $fflag $fsckopts
|
||||
mount -a
|
||||
|
||||
# Unmount and free now defunct ramdisk
|
||||
umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
|
||||
ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
|
||||
|
||||
# Initialize files.
|
||||
>/var/run/utmp # /etc/utmp keeps track of logins
|
||||
>/var/run/utmpx # /etc/utmpx keeps track of logins
|
||||
|
||||
# Edit settings for boot system services
|
||||
if [ "`sysenv skip_boot_config`" != 1 ]
|
||||
then
|
||||
|
@ -197,18 +198,18 @@ down|stop)
|
|||
if [ -f /var/run/devmand.pid ]
|
||||
then
|
||||
kill -INT `cat /var/run/devmand.pid`
|
||||
# without this delay the following will
|
||||
# without this delay the following will
|
||||
# be printed in the console
|
||||
# RS: devman not running?
|
||||
sleep 1
|
||||
fi
|
||||
#
|
||||
# usbd needs to be stopped exactly
|
||||
# usbd needs to be stopped exactly
|
||||
# at this stage(before stopping devman
|
||||
# and after stopping the services
|
||||
# stated by devmand)
|
||||
if [ -x /usr/pkg/etc/rc.d/usbd ]
|
||||
then
|
||||
then
|
||||
/usr/pkg/etc/rc.d/usbd stop
|
||||
fi
|
||||
|
||||
|
|
27
etc/rc.cd
27
etc/rc.cd
|
@ -2,3 +2,30 @@
|
|||
|
||||
# CD boottime initializations.
|
||||
|
||||
echo -n "Creating ramdisks:"
|
||||
|
||||
# Set up a ramdisk to make a read-only part of the directory tree writable
|
||||
# $1 : ramdisk dev node to use
|
||||
# $2 : path to make writeable
|
||||
# $3 : ramdisk size in blocks
|
||||
create_ramdisk()
|
||||
{
|
||||
echo -n " $2"
|
||||
ramdisk $3 /dev/$1 > /dev/null
|
||||
mkfs.mfs /dev/$1 > /dev/null
|
||||
|
||||
# copy files
|
||||
mount /dev/$1 /mnt > /dev/null
|
||||
(cd $2 && pax -rw . /mnt)
|
||||
|
||||
umount /mnt > /dev/null
|
||||
mount /dev/$1 $2 > /dev/null
|
||||
}
|
||||
|
||||
# Create /var ramdisk
|
||||
create_ramdisk ram0 /var 256
|
||||
create_ramdisk ram1 /tmp 128
|
||||
create_ramdisk ram2 /usr/run 64
|
||||
create_ramdisk ram3 /root 512
|
||||
|
||||
echo
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# daily - daily cleanup of the system.
|
||||
|
||||
# Doesn't make sense when running from CD
|
||||
if [ -f /CD ]
|
||||
if [ ! -z $(sysenv bootcd) ]
|
||||
then exit
|
||||
fi
|
||||
|
||||
|
@ -50,8 +50,8 @@ cycle()
|
|||
fi
|
||||
}
|
||||
|
||||
cycle 100 wtmp
|
||||
cycle 100 log
|
||||
cycle 100 wtmp
|
||||
cycle 100 log
|
||||
cycle 20 ftplog
|
||||
cycle 200 aftplog
|
||||
|
||||
|
|
|
@ -178,6 +178,11 @@ start|autoboot)
|
|||
cat < $RANDOM_FILE >/dev/random
|
||||
# overwrite $RANDOM_FILE. We don't want to use this data again
|
||||
dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
|
||||
else
|
||||
# We couldn't find the old state to restart from, so use a binary
|
||||
# file and the current date instead, even if this is less than ideal.
|
||||
cat /bin/sh >> /dev/urandom
|
||||
date >> /dev/urandom
|
||||
fi
|
||||
|
||||
# start network driver instances for all configured ethernet devices
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* This file contains some code to guess where we have to load the
|
||||
/*
|
||||
* This file contains some code to guess where we have to load the
|
||||
* RAM image device from, if started from CD. (In this case it's hard
|
||||
* to tell where this is without diving into BIOS heuristics.)
|
||||
*
|
||||
|
@ -8,6 +9,7 @@
|
|||
* Changes:
|
||||
* Jul 14, 2005 Created (Ben Gras)
|
||||
* Feb 10, 2006 Changed into a standalone program (Philip Homburg)
|
||||
* May 25, 2015 Installation CD overhaul (Jean-Baptiste Boric)
|
||||
*/
|
||||
|
||||
#define CD_SECTOR 2048
|
||||
|
@ -22,119 +24,55 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mfs/const.h"
|
||||
|
||||
char pvd[CD_SECTOR];
|
||||
|
||||
/*===========================================================================*
|
||||
* cdprobe *
|
||||
*===========================================================================*/
|
||||
int main(void)
|
||||
{
|
||||
int controller, disk, r, fd, minor, found;
|
||||
const int probelist[AT_MINORS] = { 2, 3, 1, 0, 6, 7, 5, 4 };
|
||||
int controller, disk, r, fd;
|
||||
off_t pos;
|
||||
u16_t *magicp;
|
||||
char name1[]= "/dev/c0dX";
|
||||
char name2[]= "/dev/c0dXpY";
|
||||
int probelist[AT_MINORS] = { 2, 3, 1, 0, 6, 7, 5, 4 };
|
||||
char name[] = "/dev/c0dX";
|
||||
char pvd[CD_SECTOR];
|
||||
|
||||
found= 0;
|
||||
for(controller = 0; controller <= 1; controller++) {
|
||||
name1[6] = '0' + controller;
|
||||
name2[6] = '0' + controller;
|
||||
for(disk = 0; disk < AT_MINORS; disk++) {
|
||||
name1[8]= '0' + probelist[disk];
|
||||
name[6] = '0' + controller;
|
||||
for(disk = 0; disk < AT_MINORS; disk++) {
|
||||
name[8]= '0' + probelist[disk];
|
||||
|
||||
fprintf(stderr, "Trying %s \r", name1);
|
||||
fflush(stderr);
|
||||
fprintf(stderr, "Trying %s \r", name);
|
||||
fflush(stderr);
|
||||
|
||||
fd = open(name1, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (errno != ENXIO)
|
||||
{
|
||||
fd = open(name, O_RDONLY);
|
||||
if ((fd < 0) && (errno != ENXIO)) {
|
||||
fprintf(stderr, "open '%s' failed: %s\n",
|
||||
name1, strerror(errno));
|
||||
name, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
pos= lseek(fd, 16*CD_SECTOR, SEEK_SET);
|
||||
if (pos != 16*CD_SECTOR)
|
||||
{
|
||||
/* Strange, do we need to issue a warning? */
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
r = read(fd, pvd, sizeof(pvd));
|
||||
if (r != sizeof(pvd))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"error reading CD label from '%s': %s\n",
|
||||
name1, strerror(errno));
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
/* Check PVD ID. */
|
||||
if (pvd[0] != 1 || pvd[1] != 'C' || pvd[2] != 'D' ||
|
||||
pvd[3] != '0' || pvd[4] != '0' || pvd[5] != '1' ||
|
||||
pvd[6] != 1 ||
|
||||
strncmp(pvd + 40, "MINIX", 5) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* 3. Both cXdYp1 and p2 should have a superblock. */
|
||||
found= 1; /* Assume everything is okay */
|
||||
for (minor = 1; minor <= 2; minor++) {
|
||||
name2[8]= '0' + probelist[disk];
|
||||
name2[10]= '0' + minor;
|
||||
|
||||
fd = open(name2, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (errno != ENXIO)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"open '%s' failed: %s\n",
|
||||
name2, strerror(errno));
|
||||
}
|
||||
found= 0;
|
||||
break;
|
||||
/* Try to read PVD. */
|
||||
pos = lseek(fd, 16*CD_SECTOR, SEEK_SET);
|
||||
if (pos != 16*CD_SECTOR) {
|
||||
close(fd);
|
||||
continue;
|
||||
}
|
||||
r = read(fd, pvd, sizeof(pvd));
|
||||
if (r != sizeof(pvd))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"error reading super block from '%s': %s\n",
|
||||
name2, strerror(errno));
|
||||
close(fd);
|
||||
found= 0;
|
||||
break;
|
||||
}
|
||||
close(fd);
|
||||
|
||||
magicp= (u16_t *)&pvd[SUPER_OFF+MAGIC_OFF];
|
||||
if (*magicp != SUPER_V3)
|
||||
{
|
||||
fprintf(stderr, "bad super block on %s\n",
|
||||
name2);
|
||||
found= 0;
|
||||
break;
|
||||
if (r != sizeof(pvd)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check PVD ID. */
|
||||
if (pvd[0] != 1 || pvd[1] != 'C' || pvd[2] != 'D' ||
|
||||
pvd[3] != '0' || pvd[4] != '0' || pvd[5] != '1' ||
|
||||
pvd[6] != 1 ||
|
||||
strncmp(pvd + 40, "MINIX", 5) != 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
fprintf(stderr, "\nFound.\n");
|
||||
printf("%s\n", name1);
|
||||
exit(0);
|
||||
printf("%s\n", name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\nNot found.\n");
|
||||
|
||||
fprintf(stderr, "\nNot found.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,12 +70,13 @@ char *argv[];
|
|||
v = fsversion(device, "mount");
|
||||
switch (v) {
|
||||
case FSVERSION_MFS1:
|
||||
case FSVERSION_MFS2:
|
||||
case FSVERSION_MFS3: type = MINIX_FS_TYPE; break;
|
||||
case FSVERSION_MFS2:
|
||||
case FSVERSION_MFS3: type = MINIX_FS_TYPE; break;
|
||||
case FSVERSION_EXT2: type = "ext2"; break;
|
||||
case FSVERSION_ISO9660: type = "isofs"; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (minix_mount(device, argv[2], mountflags, srvflags, type, args) < 0) {
|
||||
err = strerror(errno);
|
||||
fprintf(stderr, "mount: Can't mount %s on %s: %s\n",
|
||||
|
@ -146,11 +147,11 @@ mount_all()
|
|||
}
|
||||
|
||||
device = fs->fs_spec;
|
||||
/* passing a null string for block special device means don't
|
||||
* use a device at all and this is what we need to do for
|
||||
/* passing a null string for block special device means don't
|
||||
* use a device at all and this is what we need to do for
|
||||
* entries starting with "none"
|
||||
*/
|
||||
if (!strcmp(device, "none"))
|
||||
if (!strcmp(device, "none"))
|
||||
device = NULL;
|
||||
|
||||
if (minix_mount(device, mountpoint, mountflags, 0, fs->fs_vfstype,
|
||||
|
|
|
@ -15,8 +15,7 @@ ROOTSECTS="`expr $ROOTMB '*' 1024 '*' 2`"
|
|||
BOOTXXSECTS=32
|
||||
USRKB="`du -sxk /usr | awk '{ print $1 }'`"
|
||||
TOTALMB="`expr 3 + $USRKB / 1024 + $ROOTMB`"
|
||||
ROOTFILES="`find -x / | wc -l`"
|
||||
USRFILES="`find -x /usr | wc -l`"
|
||||
TOTALFILES="`find -x / | wc -l`"
|
||||
|
||||
# /usr/install isn't copied onto the new system; compensate
|
||||
INSTALLDIR=/usr/install
|
||||
|
@ -691,26 +690,36 @@ echo ""
|
|||
echo "All files will now be copied to your hard disk. This may take a while."
|
||||
echo ""
|
||||
|
||||
mount /dev/$usr /mnt >/dev/null || exit # Mount the intended /usr.
|
||||
|
||||
(cd /usr || exit 1
|
||||
list="`ls | fgrep -v install`"
|
||||
pax -rw -pe -v $list /mnt 2>&1
|
||||
) | progressbar "$USRFILES" || exit # Copy the usr floppy.
|
||||
|
||||
umount /dev/$usr >/dev/null || exit # Unmount the intended /usr.
|
||||
mount /dev/$root /mnt >/dev/null || exit
|
||||
mkdir -p /mnt/usr
|
||||
mount /dev/$usr /mnt/usr >/dev/null || exit # Mount the intended /usr.
|
||||
if [ "$nohome" = 0 ]; then
|
||||
mkdir -p /mnt/home
|
||||
mount /dev/$home /mnt/home >/dev/null || exit # Mount the intended /home
|
||||
fi
|
||||
|
||||
# Running from the installation CD.
|
||||
pax -rw -pe -vX / /mnt 2>&1 | progressbar "$ROOTFILES" || exit
|
||||
chmod o-w /mnt/usr
|
||||
for set in /i386/binary/sets/*.tgz; do
|
||||
echo "Extracting $(basename "$set")..."
|
||||
COUNT_FILES=$(cat $(echo "$set" | sed -e "s/\.tgz/\.count/"))
|
||||
(cd /mnt; pax -rz -f $set -v -pe 2>&1 | progressbar "$COUNT_FILES" || exit)
|
||||
done;
|
||||
|
||||
echo "Creating device nodes..."
|
||||
(cd /mnt/dev; MAKEDEV -s all)
|
||||
|
||||
# Fix permissions
|
||||
chmod $(stat -f %Lp /usr) /mnt/usr
|
||||
chown $(stat -f %u /usr) /mnt/usr
|
||||
chgrp $(stat -f %g /usr) /mnt/usr
|
||||
if [ "$nohome" = 0 ]; then
|
||||
chmod $(stat -f %Lp /home) /mnt/home
|
||||
chown $(stat -f %u /home) /mnt/home
|
||||
chgrp $(stat -f %g /home) /mnt/home
|
||||
fi
|
||||
|
||||
cp /mnt/etc/motd.install /mnt/etc/motd
|
||||
|
||||
|
||||
# Fix /var/log
|
||||
rm /mnt/var/log
|
||||
ln -s /usr/log /mnt/var/log
|
||||
|
||||
# CD remnants that aren't for the installed system
|
||||
rm /mnt/etc/issue /mnt/CD /mnt/.* 2>/dev/null
|
||||
echo >/mnt/etc/fstab "/dev/$root / mfs rw 0 1
|
||||
|
@ -722,8 +731,6 @@ none /dev/pts ptyfs rw,rslabel=ptyfs 0 0"
|
|||
# National keyboard map.
|
||||
test -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt/etc/keymap
|
||||
|
||||
# Make bootable.
|
||||
mount /dev/$usr /mnt/usr >/dev/null || exit
|
||||
# XXX we have to use "-f" here, because installboot worries about BPB, which
|
||||
# we don't have...
|
||||
installboot_nbsd -f /dev/$primary /usr/mdec/bootxx_minixfs3 >/dev/null || exit
|
||||
|
@ -755,12 +762,37 @@ echo ""
|
|||
|
||||
/bin/netconf -p /mnt || echo FAILED TO CONFIGURE NETWORK
|
||||
|
||||
PACKAGES_DIR="/usr/packages/$(uname -v | cut -f2 -d' ')/$(uname -p)/All"
|
||||
if [ -e "$PACKAGES_DIR" ]
|
||||
then
|
||||
echo "Installing pkgin..."
|
||||
|
||||
sh -c "cp $PACKAGES_DIR/pkgin-* $PACKAGES_DIR/pkg_install-* $PACKAGES_DIR/openssl-* /mnt/tmp &&
|
||||
chroot /mnt pkg_add /tmp/openssl-* /tmp/pkg_install-* /tmp/pkgin-*"
|
||||
rm -f /mnt/tmp/*
|
||||
|
||||
if [ -f "$PACKAGES_DIR/pkg_summary.bz2" ]
|
||||
then
|
||||
echo ""
|
||||
echo "Packages are bundled on this installation media."
|
||||
echo "They are available under the directory $PACKAGES_DIR"
|
||||
echo "To install them after rebooting, mount this CD, set PKG_PATH to this directory"
|
||||
echo "and use pkg_add."
|
||||
echo "If you mount the CD at /mnt, PKG_PATH should be:"
|
||||
echo "/mnt$PACKAGES_DIR"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
umount /dev/$usr && echo Unmounted $usr
|
||||
umount /dev/$root && echo Unmounted $root
|
||||
if [ "$nohome" = 0 ]; then
|
||||
umount /dev/$home && echo Unmounted $home
|
||||
fi
|
||||
|
||||
echo "
|
||||
Please type 'reboot' to exit MINIX 3 and reboot. To boot into your new
|
||||
system, you might have to remove installation media.
|
||||
Please type 'shutdown -r now' to exit MINIX 3 and reboot. To boot into
|
||||
your new system, you might have to remove the installation media.
|
||||
|
||||
This ends the MINIX 3 setup script. You may want to take care of post
|
||||
installation steps, such as local testing and configuration.
|
||||
|
|
|
@ -72,6 +72,8 @@ PROGRAMS+= cdprobe
|
|||
dir.cdprobe:= minix/commands/cdprobe
|
||||
PROGRAMS+= pwd_mkdb
|
||||
dir.pwd_mkdb:= usr.sbin/pwd_mkdb
|
||||
PROGRAMS+= isofs
|
||||
dir.isofs:= minix/fs/isofs
|
||||
|
||||
.if ${MKSMALL} != "yes"
|
||||
PROGRAMS+= ahci
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
boot
|
||||
boot
|
||||
0 0
|
||||
d--755 0 0
|
||||
bin d--755 0 0
|
||||
|
@ -25,6 +25,7 @@ d--755 0 0
|
|||
#if RAMDISK_SMALL == 1
|
||||
ext2 ---755 0 0 ext2
|
||||
#endif
|
||||
isofs ---755 0 0 isofs
|
||||
#endif
|
||||
#ifdef __arm__
|
||||
mmc ---755 0 0 mmc
|
||||
|
|
|
@ -54,8 +54,11 @@ fi
|
|||
|
||||
if /bin/sysenv rootdevname >/dev/null
|
||||
then rootdevname=/dev/`/bin/sysenv rootdevname`
|
||||
else echo "rootdevname not set"
|
||||
exit 1
|
||||
else
|
||||
if ! sysenv cdproberoot >/dev/null
|
||||
then echo "rootdevname not set"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "`sysenv bin_img`" = 1 ]
|
||||
|
@ -65,14 +68,12 @@ fi
|
|||
|
||||
if sysenv cdproberoot >/dev/null
|
||||
then
|
||||
echo
|
||||
echo
|
||||
echo 'Looking for boot CD. This may take a minute.'
|
||||
echo 'Please ignore any error messages.'
|
||||
echo
|
||||
cddev=`cdprobe` || { echo 'No CD found'; exit 1; }
|
||||
export cddev
|
||||
echo "Loading ramdisk from ${cddev}p1"
|
||||
loadramdisk "$cddev"p1
|
||||
rootdevname=$(cdprobe) || { echo 'No CD found'; exit 1; }
|
||||
export rootdevname
|
||||
elif [ "$rootdevname" = "/dev/ram" ]
|
||||
then
|
||||
ramimagename=/dev/`/bin/sysenv ramimagename`
|
||||
|
@ -81,8 +82,12 @@ then
|
|||
fi
|
||||
|
||||
echo "Root device name is $rootdevname"
|
||||
if [ -e $FSCK ]
|
||||
then $FSCK -p $rootdevname
|
||||
|
||||
if ! sysenv cdproberoot >/dev/null
|
||||
then
|
||||
if [ -e $FSCK ]
|
||||
then $FSCK -p $rootdevname
|
||||
fi
|
||||
fi
|
||||
|
||||
# Change root from temporary boot ramdisk to the configure
|
||||
|
|
|
@ -24,9 +24,10 @@ void read_tsc(u32_t *hi, u32_t *lo);
|
|||
void read_tsc_64(u64_t *t);
|
||||
|
||||
/* return values for fsversion */
|
||||
#define FSVERSION_MFS1 0x00001
|
||||
#define FSVERSION_MFS2 0x00002
|
||||
#define FSVERSION_MFS3 0x00003
|
||||
#define FSVERSION_EXT2 0x10002
|
||||
#define FSVERSION_MFS1 0x00001
|
||||
#define FSVERSION_MFS2 0x00002
|
||||
#define FSVERSION_MFS3 0x00003
|
||||
#define FSVERSION_EXT2 0x10002
|
||||
#define FSVERSION_ISO9660 0x20001
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* n = fsversion("/dev/hd1", "df");
|
||||
*
|
||||
* The first argument is the special file for the file system.
|
||||
* The first argument is the special file for the file system.
|
||||
* The second is the program name, which is used in error messages.
|
||||
*/
|
||||
|
||||
|
@ -22,42 +22,66 @@
|
|||
|
||||
static char super[SUPER_BLOCK_BYTES];
|
||||
|
||||
#define MAGIC_OFFSET_MFS 0x18
|
||||
#define MAGIC_OFFSET_EXT 0x38
|
||||
#define MAGIC_OFFSET_MFS 0x18
|
||||
#define MAGIC_OFFSET_EXT 0x38
|
||||
#define MAGIC_OFFSET_ISO9660 0x8000
|
||||
#define MAGIC_VALUE_EXT2 0xef53
|
||||
|
||||
static int check_super(off_t offset, unsigned short magic)
|
||||
{
|
||||
return (memcmp(super + offset, &magic, sizeof(magic)) == 0) ? 1 : 0;
|
||||
return (memcmp(super + offset, &magic, sizeof(magic)) == 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
int fsversion(dev, prog)
|
||||
char *dev, *prog;
|
||||
int fsversion(char *dev, char *prog)
|
||||
{
|
||||
int fd;
|
||||
int result = -1, fd;
|
||||
|
||||
if ((fd = open(dev, O_RDONLY)) < 0) {
|
||||
std_err(prog);
|
||||
std_err(" cannot open ");
|
||||
perror(dev);
|
||||
return(-1);
|
||||
}
|
||||
if ((fd = open(dev, O_RDONLY)) < 0) {
|
||||
std_err(prog);
|
||||
std_err(" cannot open ");
|
||||
perror(dev);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
lseek(fd, (off_t) SUPER_BLOCK_BYTES, SEEK_SET); /* skip boot block */
|
||||
if (read(fd, (char *) &super, sizeof(super)) != sizeof(super)) {
|
||||
std_err(prog);
|
||||
std_err(" cannot read super block on ");
|
||||
perror(dev);
|
||||
lseek(fd, (off_t) SUPER_BLOCK_BYTES, SEEK_SET); /* skip boot block */
|
||||
if (read(fd, (char *) &super, sizeof(super)) != sizeof(super)) {
|
||||
std_err(prog);
|
||||
std_err(" cannot read super block on ");
|
||||
perror(dev);
|
||||
close(fd);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* first check MFS, a valid MFS may look like EXT but not vice versa */
|
||||
if (check_super(MAGIC_OFFSET_MFS, SUPER_MAGIC)) {
|
||||
result = FSVERSION_MFS1;
|
||||
goto done;
|
||||
}
|
||||
else if (check_super(MAGIC_OFFSET_MFS, SUPER_V2)) {
|
||||
result = FSVERSION_MFS2;
|
||||
goto done;
|
||||
}
|
||||
else if (check_super(MAGIC_OFFSET_MFS, SUPER_V3)) {
|
||||
result = FSVERSION_MFS3;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* check ext2 */
|
||||
if (check_super(MAGIC_OFFSET_EXT, MAGIC_VALUE_EXT2)) {
|
||||
result = FSVERSION_EXT2;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* check ISO 9660 */
|
||||
lseek(fd, (off_t) MAGIC_OFFSET_ISO9660, SEEK_SET);
|
||||
if (read(fd, (char *) &super, sizeof(super)) == sizeof(super)) {
|
||||
if (memcmp(super+1, "CD001", 5) == 0) {
|
||||
result = FSVERSION_ISO9660;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
close(fd);
|
||||
return(-1);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
/* first check MFS, a valid MFS may look like EXT but not vice versa */
|
||||
if (check_super(MAGIC_OFFSET_MFS, SUPER_MAGIC)) return FSVERSION_MFS1;
|
||||
if (check_super(MAGIC_OFFSET_MFS, SUPER_V2)) return FSVERSION_MFS2;
|
||||
if (check_super(MAGIC_OFFSET_MFS, SUPER_V3)) return FSVERSION_MFS3;
|
||||
if (check_super(MAGIC_OFFSET_EXT, MAGIC_VALUE_EXT2)) return FSVERSION_EXT2;
|
||||
|
||||
return(-1);
|
||||
return result;
|
||||
}
|
||||
|
|
19
releasetools/image.defaults
Normal file
19
releasetools/image.defaults
Normal file
|
@ -0,0 +1,19 @@
|
|||
: ${OBJ=../obj.${ARCH}}
|
||||
: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin}
|
||||
: ${CROSS_PREFIX=${CROSS_TOOLS}/${TOOLCHAIN_TRIPLET}}
|
||||
: ${JOBS=1}
|
||||
: ${DESTDIR=${OBJ}/destdir.$ARCH}
|
||||
: ${RELEASEDIR=${OBJ}/releasedir/$ARCH/binary}
|
||||
: ${RELEASETOOLSDIR=./releasetools/}
|
||||
: ${BUILDVARS=}
|
||||
: ${CREATE_IMAGE_ONLY=0}
|
||||
: ${RELEASE_VERSION=$(sh sys/conf/osrelease.sh)}
|
||||
|
||||
: ${WORK_DIR=${OBJ}/work}
|
||||
: ${SETS_DIR=${OBJ}/releasedir/${ARCH}/binary/sets}
|
||||
|
||||
: ${PACKAGE_DIR=}
|
||||
: ${PKG_INFO=pkg_info}
|
||||
: ${BUNDLE_PACKAGES=}
|
||||
|
||||
: ${ASR_HACK=0}
|
349
releasetools/image.functions
Normal file
349
releasetools/image.functions
Normal file
|
@ -0,0 +1,349 @@
|
|||
|
||||
#
|
||||
# spec file handling
|
||||
#
|
||||
|
||||
#
|
||||
# Add a directory to a spec file
|
||||
#
|
||||
# $1 : directory to add
|
||||
# $2 : spec file
|
||||
add_dir_spec() {
|
||||
echo "./$1 type=dir uid=0 gid=0 mode=0755" >> ${WORK_DIR}/$2
|
||||
}
|
||||
|
||||
#
|
||||
# Add a file to a spec file
|
||||
#
|
||||
# $1 : file to add
|
||||
# $2 : spec file
|
||||
add_file_spec() {
|
||||
echo "./$1 type=file uid=0 gid=0 mode=0755 size=$(wc -c < ${ROOT_DIR}/${1})" >> ${WORK_DIR}/$2
|
||||
}
|
||||
|
||||
#
|
||||
# Add a symbolic link to a spec file
|
||||
#
|
||||
# $1 : symlink to add
|
||||
# $2 : link to
|
||||
# $3 : spec file
|
||||
add_link_spec() {
|
||||
echo "./$1 type=link uid=0 gid=0 mode=0755 link=$2" >> ${WORK_DIR}/$3
|
||||
}
|
||||
|
||||
#
|
||||
# workdir handling
|
||||
#
|
||||
|
||||
#
|
||||
# Create the workdir (a directory where Minix is built using sets)
|
||||
# spec files are put in WORK_DIR, the file system created in ROOT_DIR
|
||||
#
|
||||
# $1 : sets to extract
|
||||
build_workdir() {
|
||||
# Extract sets
|
||||
mkdir ${ROOT_DIR}
|
||||
for set in $1; do
|
||||
if [ ! -e ${SETS_DIR}/${set}.tgz ]; then
|
||||
echo "Missing ${SETS_DIR}/${set}.tgz, aborting"
|
||||
echo "Are the release sets tarballs created?"
|
||||
exit 1
|
||||
fi
|
||||
echo " * Extracting $set..."
|
||||
(cd ${ROOT_DIR}; ${CROSS_TOOLS}/nbpax -rnz -f ${SETS_DIR}/${set}.tgz .)
|
||||
done
|
||||
|
||||
# Build login/password files
|
||||
${CROSS_TOOLS}/nbpwd_mkdb -V 0 -p -d ${ROOT_DIR} ${ROOT_DIR}/etc/master.passwd
|
||||
|
||||
# Build specifications files
|
||||
cp ${ROOT_DIR}/etc/mtree/set* ${WORK_DIR}
|
||||
${ROOT_DIR}/usr/bin/MAKEDEV -s -m all >> ${WORK_DIR}/extra.dev
|
||||
}
|
||||
|
||||
#
|
||||
# Add tarball sets to the workdir (for installation CD)
|
||||
#
|
||||
workdir_add_sets() {
|
||||
# Add sets to the root
|
||||
mkdir ${ROOT_DIR}/${ARCH}; add_dir_spec "${ARCH}" extra.sets
|
||||
mkdir ${ROOT_DIR}/${ARCH}/binary; add_dir_spec "${ARCH}/binary" extra.sets
|
||||
mkdir ${ROOT_DIR}/${ARCH}/binary/sets; add_dir_spec "${ARCH}/binary/sets" extra.sets
|
||||
|
||||
DEST_SETS_DIR="${ARCH}/binary/sets"
|
||||
for set in ${SETS_DIR}/*.tgz; do
|
||||
# Copy set itself
|
||||
cp ${set} ${ROOT_DIR}/${DEST_SETS_DIR}
|
||||
add_file_spec "${DEST_SETS_DIR}/$(basename ${set})" extra.sets
|
||||
|
||||
# Add file count
|
||||
COUNT_SRC=$(echo $(basename ${set}) | sed -e "s/\(.*\)\.tgz/\set.\1/")
|
||||
COUNT_NAME=$(echo $(basename ${set}) | sed -e "s/\.tgz/\.count/")
|
||||
if [ -e "${DESTDIR}/etc/mtree/${COUNT_SRC}" ]
|
||||
then
|
||||
wc -l < ${DESTDIR}/etc/mtree/${COUNT_SRC} > ${ROOT_DIR}/${DEST_SETS_DIR}/${COUNT_NAME}
|
||||
else
|
||||
# Can't find mtree file, set bogus number
|
||||
echo 1 > ${ROOT_DIR}/${DEST_SETS_DIR}/${COUNT_NAME}
|
||||
fi
|
||||
add_file_spec "${DEST_SETS_DIR}/${COUNT_NAME}" extra.sets
|
||||
done
|
||||
|
||||
# Add checksums
|
||||
cp ${SETS_DIR}/MD5 ${ROOT_DIR}/${DEST_SETS_DIR}
|
||||
add_file_spec "${DEST_SETS_DIR}/MD5" extra.sets
|
||||
cp ${SETS_DIR}/SHA512 ${ROOT_DIR}/${DEST_SETS_DIR}
|
||||
add_file_spec "${DEST_SETS_DIR}/SHA512" extra.sets
|
||||
}
|
||||
|
||||
#
|
||||
# Add CD boot files to the workdir
|
||||
#
|
||||
workdir_add_cdfiles() {
|
||||
# Add boot monitor
|
||||
cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/minixboot
|
||||
add_file_spec "minixboot" extra.cdfiles
|
||||
|
||||
# Add README
|
||||
cp releasetools/release/cd/README.TXT ${ROOT_DIR}/README.TXT
|
||||
add_file_spec "README.TXT" extra.cdfiles
|
||||
}
|
||||
|
||||
#
|
||||
# Extract kernel to designated directory
|
||||
#
|
||||
# $1: Directory where to extract
|
||||
workdir_add_kernel()
|
||||
{
|
||||
(cd ${ROOT_DIR}; ${CROSS_TOOLS}/nbpax -rnz -f ${SETS_DIR}/minix-kernel.tgz .)
|
||||
|
||||
# Move kernel files to the correct directory
|
||||
if [ ! -d ${ROOT_DIR}/boot/$1 ]
|
||||
then
|
||||
mkdir ${ROOT_DIR}/boot/$1
|
||||
add_dir_spec "boot/$1" extra.kernel
|
||||
fi
|
||||
|
||||
mv ${ROOT_DIR}/boot/minix/.temp/* ${ROOT_DIR}/boot/$1
|
||||
rm -rf ${ROOT_DIR}/boot/minix/.temp
|
||||
for i in $(cd ${ROOT_DIR}/boot/$1 && echo *)
|
||||
do
|
||||
add_file_spec "boot/$1/$i" extra.kernel
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Read METALOG and use mtree to convert the user and group names into uid and gids.
|
||||
# Used as the reference mtree for building file systems.
|
||||
#
|
||||
create_input_spec()
|
||||
{
|
||||
cat ${WORK_DIR}/set* ${WORK_DIR}/extra* | ${CROSS_TOOLS}/nbmtree -N ${ROOT_DIR}/etc -C -K device > ${WORK_DIR}/input
|
||||
|
||||
if [ ${ASR_HACK} -eq 1 ]
|
||||
then
|
||||
# Hacky workaround for ASR-randomized service binaries since they don't get nicely packaged in a tarball
|
||||
# add any generated ASR-randomized service binaries (but not their root directory, which is already there)
|
||||
# TODO: apply stricter file permissions for both these and the base /service binaries, against local attacks
|
||||
(cd ${DESTDIR} && find ./usr/service/asr -type d | sed '1d;s/$/ type=dir uid=0 gid=0 mode=0755/') >> ${WORK_DIR}/input
|
||||
(cd ${DESTDIR} && find ./usr/service/asr -type f | sed 's/$/ type=file uid=0 gid=0 mode=0755/') >> ${WORK_DIR}/input
|
||||
cp -r ${DESTDIR}/usr/service/asr ${ROOT_DIR}/usr/service
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Split mtree into partitions and create proto files for nbmkfs.mfs
|
||||
#
|
||||
# $1 : partitions to create (example: usr home)
|
||||
create_protos()
|
||||
{
|
||||
# build filter
|
||||
FILTER_COMMAND="cat ${WORK_DIR}/input"
|
||||
for i in $1
|
||||
do
|
||||
FILTER_COMMAND="$FILTER_COMMAND | grep -v \"^./$i/\" "
|
||||
done
|
||||
|
||||
# fill root.img (skipping entries inside partitions while keeping partition mount points)
|
||||
eval $FILTER_COMMAND | ${CROSS_TOOLS}/nbtoproto -b ${ROOT_DIR} -o ${WORK_DIR}/proto.root
|
||||
|
||||
# create proto files for partitions using toproto
|
||||
for i in $1
|
||||
do
|
||||
cat ${WORK_DIR}/input | grep "^\./$i/\|^. " | sed "s,\./$i,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${ROOT_DIR}/$i -o ${WORK_DIR}/proto.$i
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Bundle packages (won't preinstall them)
|
||||
#
|
||||
# $1 : packages to bundle
|
||||
bundle_packages()
|
||||
{
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -z $PACKAGE_DIR ]
|
||||
then
|
||||
echo "Error: PACKAGE_DIR is not set while trying to bundle packages."
|
||||
echo "Please fetch binary packages to bundle and set PACKAGE_DIR to continue."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DESTPACKAGES="usr/packages/$RELEASE_VERSION/$ARCH/All"
|
||||
RELEASEPACKAGE="${ROOT_DIR}/$DESTPACKAGES"
|
||||
index=pkg_summary
|
||||
|
||||
# create directories
|
||||
mkdir -p $RELEASEPACKAGE
|
||||
add_dir_spec "usr/packages" extra.pkgsrc
|
||||
add_dir_spec "usr/packages/$RELEASE_VERSION" extra.pkgsrc
|
||||
add_dir_spec "usr/packages/$RELEASE_VERSION/$ARCH" extra.pkgsrc
|
||||
add_dir_spec "usr/packages/$RELEASE_VERSION/$ARCH/All" extra.pkgsrc
|
||||
add_link_spec "packages" "usr/packages" extra.pkgsrc
|
||||
for pkgprefix in $1
|
||||
do
|
||||
realfn=$(echo $PACKAGE_DIR/${pkgprefix}*.tgz | cut -d' ' -f1)
|
||||
if [ -f "$realfn" ]
|
||||
then
|
||||
# Copy package
|
||||
p="$(basename $realfn)"
|
||||
echo " * Bundling $p..."
|
||||
cp "$realfn" "$RELEASEPACKAGE/$p"
|
||||
add_file_spec "$DESTPACKAGES/$p" extra.pkgsrc
|
||||
else
|
||||
echo "Error: Can't find $pkgprefix in directory $PACKAGE_DIR for bundling package."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -x "$(which $PKG_INFO)" ]
|
||||
then
|
||||
# Create packages index
|
||||
echo " * Generating package index..."
|
||||
indexname=$indexpath/$p.$index
|
||||
$PKG_INFO -X $RELEASEPACKAGE/*.tgz >> $RELEASEPACKAGE/$index
|
||||
|
||||
# Compress index
|
||||
echo " * Compressing index..."
|
||||
bzip2 -f $RELEASEPACKAGE/$index
|
||||
add_file_spec "$DESTPACKAGES/$index.bz2" extra.pkgsrc
|
||||
else
|
||||
echo " * Skipping package index generation."
|
||||
echo " PKG_INFO ("$(which $PKG_INFO)") not executable."
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# stuff executed automatically to set up environment
|
||||
#
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 [options]"
|
||||
echo " -X xsrc Build with X11 located in \"xsrc\" and extract its sets for image"
|
||||
echo " (do not automatically extract for installation CD)"
|
||||
echo " -b Add ASR service binaries to the image"
|
||||
echo " (said binaries must be built beforehand)"
|
||||
echo ""
|
||||
echo "Environment variables:"
|
||||
echo " CREATE_IMAGE_ONLY If set to 1, skip invocation of build.sh (default: 0)"
|
||||
echo " JOBS Number of CPUs to use for build.sh to use (default: 1)"
|
||||
echo " SETS Sets to extract for image (default: depends on script)"
|
||||
echo " BUILDVARS Extra options passed to build.sh (default: none)"
|
||||
echo ""
|
||||
echo " PACKAGE_DIR Path to packages to bundle (default: none)"
|
||||
echo " BUNDLE_PACKAGES List of packages to bundle (default: none)"
|
||||
echo " PKG_INFO Path to 'pkg_info' for bundling (default: pkg_info)"
|
||||
}
|
||||
|
||||
# parse options
|
||||
while getopts "iX:bh" c
|
||||
do
|
||||
case "$c" in
|
||||
i) echo "This method of generating the ISO installation media is obsolete."
|
||||
echo "Run ./releasetools/x86_cdimage.sh instead."
|
||||
exit 1;;
|
||||
|
||||
X) # we don't want to extract X sets by default for the installation CD
|
||||
if [ $0 != "releasetools/x86_cdimage.sh" ]
|
||||
then
|
||||
SETS="$SETS xbase xcomp xetc xfont xserver"
|
||||
fi
|
||||
MKX11=yes
|
||||
export MKX11
|
||||
BUILDVARS="$BUILDVARS -X $OPTARG";;
|
||||
|
||||
b) # bitcode build: increase partition sizes
|
||||
ROOT_SIZE="$((${ROOT_SIZE} + 192*(2**20) / 512))"
|
||||
USR_SIZE="$((${USR_SIZE} + 256*(2**20) / 512))"
|
||||
ASR_HACK=1;;
|
||||
|
||||
h) usage
|
||||
exit 0;;
|
||||
|
||||
:) usage
|
||||
exit 2;;
|
||||
|
||||
\?)
|
||||
usage
|
||||
exit 2;;
|
||||
esac
|
||||
done
|
||||
|
||||
#
|
||||
# Are we going to build the minix sources?
|
||||
#
|
||||
|
||||
if [ ${CREATE_IMAGE_ONLY} -eq 1 ]
|
||||
then
|
||||
if [ ! -d ${DESTDIR} ]
|
||||
then
|
||||
echo "Minix source code doesn't appear to have been built."
|
||||
echo "Please try with \$CREATE_IMAGE_ONLY set to 0."
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d ${RELEASEDIR} ]
|
||||
then
|
||||
echo "Minix release tarball sets don't appear to have been created."
|
||||
echo "Please try with \$CREATE_IMAGE_ONLY set to 0."
|
||||
exit 1
|
||||
fi
|
||||
# FIXME: this won't change anything for tarballs
|
||||
#${CROSS_TOOLS}/nbmake-i386 -C releasetools do-hdboot
|
||||
else
|
||||
echo "Going to build Minix source code..."
|
||||
#
|
||||
# Remove the generated files to allow us call build.sh without '-V SLOPPY_FLIST=yes'.
|
||||
#
|
||||
rm -f ${FSTAB}
|
||||
|
||||
#
|
||||
# Now start the build.
|
||||
#
|
||||
sh ${BUILDSH} -j ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} ${BUILDVARS} -U -u release
|
||||
|
||||
fi
|
||||
|
||||
# sanity check
|
||||
if [ -d "${WORK_DIR}/.git" ]
|
||||
then
|
||||
echo "WORK_DIR directory has a Git repository in it, abort!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# clean working directory
|
||||
if [ -e "${WORK_DIR}" ]
|
||||
then
|
||||
rm -rf "${WORK_DIR}"
|
||||
fi
|
||||
mkdir -p ${WORK_DIR}
|
||||
|
||||
# get absolute paths to those directories
|
||||
CROSS_TOOLS=$(cd ${CROSS_TOOLS} && pwd)
|
||||
DESTDIR=$(cd ${DESTDIR} && pwd)
|
||||
OBJ=$(cd ${OBJ} && pwd)
|
||||
SETS_DIR=$(cd ${SETS_DIR} && pwd)
|
||||
WORK_DIR=$(cd ${WORK_DIR} && pwd)
|
||||
ROOT_DIR=${WORK_DIR}/fs
|
|
@ -19,7 +19,6 @@ p5-MailTools-
|
|||
p5-Error-
|
||||
p5-Email-Valid-1
|
||||
p5-Authen-SASL-2
|
||||
expat-
|
||||
curl-
|
||||
python27-
|
||||
libxml2-
|
||||
|
@ -43,7 +42,6 @@ tegaki-zinnia-japanese-kyoiku-
|
|||
ucon64-
|
||||
unzoo-
|
||||
zoo-
|
||||
wwwcount-
|
||||
z80-asm-
|
||||
zombies-
|
||||
bootstrap-mk-files-
|
||||
|
@ -54,7 +52,6 @@ zsh-
|
|||
zsync-
|
||||
zzuf-
|
||||
buffer-
|
||||
p5-XML-Parser-2
|
||||
intltool-
|
||||
readline-
|
||||
libtool-base-
|
||||
|
|
|
@ -44,9 +44,11 @@ CD CONTENTS:
|
|||
|
||||
This CD contains:
|
||||
|
||||
- README.TXT This file
|
||||
|
||||
There are also many invisible files used for installing MINIX 3.
|
||||
- README.TXT This file
|
||||
- i386/ Base system distribution files, for
|
||||
installation
|
||||
- usr/packages/ Extra packages, if bundled with this CD
|
||||
- Everything else MINIX 3 files
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
|
|
95
releasetools/x86_cdimage.sh
Executable file
95
releasetools/x86_cdimage.sh
Executable file
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
#
|
||||
# This script creates a bootable image and should at some point in the future
|
||||
# be replaced by the proper NetBSD infrastructure.
|
||||
#
|
||||
|
||||
: ${ARCH=i386}
|
||||
: ${OBJ=../obj.${ARCH}}
|
||||
: ${TOOLCHAIN_TRIPLET=i586-elf32-minix-}
|
||||
: ${BUILDSH=build.sh}
|
||||
|
||||
: ${SETS="minix tests"}
|
||||
: ${IMG=minix_x86.iso}
|
||||
|
||||
if [ ! -f ${BUILDSH} ]
|
||||
then
|
||||
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set up disk creation environment
|
||||
. releasetools/image.defaults
|
||||
. releasetools/image.functions
|
||||
|
||||
# where the kernel & boot modules will be
|
||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||
|
||||
echo "Building work directory..."
|
||||
build_workdir "$SETS"
|
||||
|
||||
echo "Adding extra files..."
|
||||
workdir_add_sets
|
||||
workdir_add_cdfiles
|
||||
|
||||
# create a fstab entry in /etc
|
||||
cat >${ROOT_DIR}/etc/fstab <<END_FSTAB
|
||||
none /sys devman rw,rslabel=devman 0 0
|
||||
none /dev/pts ptyfs rw,rslabel=ptyfs 0 0
|
||||
END_FSTAB
|
||||
add_file_spec "etc/fstab" extra.fstab
|
||||
|
||||
# workdir_add_kernel minix_default
|
||||
|
||||
# add boot.cfg
|
||||
cat >${ROOT_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 disable=inet
|
||||
menu=Regular MINIX 3 (with AHCI):multiboot /boot/minix/.temp/kernel bootcd=1 cdproberoot=1 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
|
||||
END_BOOT_CFG
|
||||
add_file_spec "boot.cfg" extra.cdfiles
|
||||
|
||||
# add README.TXT
|
||||
cp releasetools/release/cd/README.TXT ${ROOT_DIR}/README.TXT
|
||||
add_file_spec "README.TXT" extra.cdfiles
|
||||
|
||||
# set correct message of the day (log in and install tip)
|
||||
cp releasetools/release/cd/etc/issue ${ROOT_DIR}/etc/issue
|
||||
add_file_spec "etc/issue" extra.cdfiles
|
||||
|
||||
echo "Bundling packages..."
|
||||
bundle_packages "$BUNDLE_PACKAGES"
|
||||
|
||||
echo "Creating specification files..."
|
||||
create_input_spec
|
||||
create_protos
|
||||
|
||||
echo "Writing ISO..."
|
||||
${CROSS_TOOLS}/nbmakefs -t cd9660 -F ${WORK_DIR}/input -o "rockridge,bootimage=i386;${DESTDIR}/usr/mdec/bootxx_cd9660,label=MINIX" ${IMG} ${ROOT_DIR}
|
||||
|
||||
#mods=$(cd ${MODDIR}; echo mod* | tr ' ' ',')
|
||||
|
||||
echo "ISO image at `pwd`/${IMG}"
|
||||
echo "To boot this image on kvm:"
|
||||
#echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -kernel kernel -append \"bootcd=1 cdproberoot=1 disable=inet\" -initrd \"${mods}\" -cdrom `pwd`/${IMG}"
|
||||
echo "qemu-system-i386 --enable-kvm -cdrom `pwd`/${IMG}"
|
|
@ -3,7 +3,7 @@ set -e
|
|||
|
||||
#
|
||||
# This script creates a bootable image and should at some point in the future
|
||||
# be replaced by makefs.
|
||||
# be replaced by the proper NetBSD infrastructure.
|
||||
#
|
||||
# Supported command line switches:
|
||||
# -i build iso image instead of qemu imaeg
|
||||
|
@ -12,208 +12,100 @@ set -e
|
|||
|
||||
: ${ARCH=i386}
|
||||
: ${OBJ=../obj.${ARCH}}
|
||||
: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin}
|
||||
: ${CROSS_PREFIX=${CROSS_TOOLS}/i586-elf32-minix-}
|
||||
: ${JOBS=1}
|
||||
: ${DESTDIR=${OBJ}/destdir.$ARCH}
|
||||
: ${RELEASETOOLSDIR=./releasetools/}
|
||||
: ${FSTAB=${DESTDIR}/etc/fstab}
|
||||
: ${BUILDVARS=}
|
||||
: ${TOOLCHAIN_TRIPLET=i586-elf32-minix-}
|
||||
: ${BUILDSH=build.sh}
|
||||
: ${CREATE_IMAGE_ONLY=0}
|
||||
: ${RC=minix_x86.rc}
|
||||
|
||||
#
|
||||
# Directory where to store temporary file system images
|
||||
#
|
||||
: ${IMG_DIR=${OBJ}/img}
|
||||
: ${CDFILES=${IMG_DIR}/cd}
|
||||
|
||||
# All sized are written in 512 byte blocks
|
||||
#
|
||||
# we create a disk image of about 2 gig's
|
||||
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
|
||||
#
|
||||
# these sizes are insufficient for bitcode builds!
|
||||
# invoke this script with the -b flag to increase sizes accordingly
|
||||
#
|
||||
: ${ROOT_SIZE=$(( 64*(2**20) / 512))}
|
||||
: ${HOME_SIZE=$(( 128*(2**20) / 512))}
|
||||
: ${USR_SIZE=$(( 1792*(2**20) / 512))}
|
||||
|
||||
#
|
||||
# Do some math to determine the start addresses of the partitions.
|
||||
# Don't leave holes so the 'partition' invocation later is easy.
|
||||
#
|
||||
|
||||
|
||||
# Where the kernel & boot modules will be
|
||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||
|
||||
while getopts "ib" c
|
||||
do
|
||||
case "$c" in
|
||||
i) : ${IMG=minix_x86.iso}
|
||||
ISOMODE=1
|
||||
;;
|
||||
b) # bitcode build: increase partition sizes
|
||||
ROOT_SIZE="$((${ROOT_SIZE} + 192*(2**20) / 512))"
|
||||
USR_SIZE="$((${USR_SIZE} + 256*(2**20) / 512))"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
: ${SETS="minix tests"}
|
||||
: ${IMG=minix_x86.img}
|
||||
|
||||
if [ "x${ISOMODE}" = "x1" ]
|
||||
then
|
||||
# In iso mode, make all FSes fit (i.e. as small as possible), but
|
||||
# leave some space on /
|
||||
ROOTSIZEARG="-x 5"
|
||||
else
|
||||
# In hd image mode, FSes have fixed sizes
|
||||
ROOTSIZEARG="-b $((${ROOT_SIZE} / 8))"
|
||||
USRSIZEARG="-b $((${USR_SIZE} / 8))"
|
||||
HOMESIZEARG="-b $((${HOME_SIZE} / 8))"
|
||||
fi
|
||||
|
||||
if [ ! -f ${BUILDSH} ]
|
||||
then
|
||||
echo "Please invoke me from the root source dir, where ${BUILDSH} is."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:${PATH}
|
||||
# we create a disk image of about 2 gig's
|
||||
# for alignment reasons, prefer sizes which are multiples of 4096 bytes
|
||||
: ${BOOTXX_SECS=32}
|
||||
: ${ROOT_SIZE=$(( 128*(2**20) - ${BOOTXX_SECS} * 512 ))}
|
||||
: ${HOME_SIZE=$(( 128*(2**20) ))}
|
||||
: ${USR_SIZE=$(( 1792*(2**20) ))}
|
||||
|
||||
#
|
||||
# Are we going to build the minix sources?
|
||||
#
|
||||
# set up disk creation environment
|
||||
. releasetools/image.defaults
|
||||
. releasetools/image.functions
|
||||
|
||||
if [ ${CREATE_IMAGE_ONLY} -eq 1 ]
|
||||
then
|
||||
if [ ! -d ${DESTDIR} ]
|
||||
then
|
||||
echo "Minix source code does'nt appear to have been built."
|
||||
echo "Please try with \$CREATE_IMAGE_ONLY set to 0."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# all sizes are written in 512 byte blocks
|
||||
ROOTSIZEARG="-b $((${ROOT_SIZE} / 512 / 8))"
|
||||
USRSIZEARG="-b $((${USR_SIZE} / 512 / 8))"
|
||||
HOMESIZEARG="-b $((${HOME_SIZE} / 512 / 8))"
|
||||
|
||||
#
|
||||
# Artifacts from this script are stored in the IMG_DIR
|
||||
#
|
||||
rm -rf ${IMG_DIR} ${IMG}
|
||||
mkdir -p ${IMG_DIR} ${CDFILES}
|
||||
# where the kernel & boot modules will be
|
||||
MODDIR=${DESTDIR}/boot/minix/.temp
|
||||
|
||||
if [ ${CREATE_IMAGE_ONLY} -eq 0 ]
|
||||
then
|
||||
echo "Going to build Minix source code..."
|
||||
#
|
||||
# Remove the generated files to allow us call build.sh without '-V SLOPPY_FLIST=yes'.
|
||||
#
|
||||
rm -f ${FSTAB}
|
||||
echo "Building work directory..."
|
||||
build_workdir "$SETS"
|
||||
|
||||
#
|
||||
# Now start the build.
|
||||
#
|
||||
sh ${BUILDSH} -j ${JOBS} -m ${ARCH} -O ${OBJ} -D ${DESTDIR} ${BUILDVARS} -U -u distribution
|
||||
else
|
||||
${CROSS_TOOLS}/nbmake-i386 -C releasetools do-hdboot
|
||||
fi
|
||||
echo "Adding extra files..."
|
||||
|
||||
#
|
||||
# create a fstab entry in /etc this is normally done during the
|
||||
# setup phase on x86
|
||||
#
|
||||
cat >${FSTAB} <<END_FSTAB
|
||||
/dev/c0d0p2 /usr mfs rw 0 2
|
||||
/dev/c0d0p3 /home mfs rw 0 2
|
||||
# create a fstab entry in /etc
|
||||
cat >${ROOT_DIR}/etc/fstab <<END_FSTAB
|
||||
/dev/c0d0p1 /usr mfs rw 0 2
|
||||
/dev/c0d0p2 /home mfs rw 0 2
|
||||
none /sys devman rw,rslabel=devman 0 0
|
||||
none /dev/pts ptyfs rw,rslabel=ptyfs 0 0
|
||||
END_FSTAB
|
||||
add_file_spec "etc/fstab" extra.fstab
|
||||
|
||||
rm -f ${DESTDIR}/SETS.*
|
||||
cp ${DESTDIR}/usr/mdec/boot_monitor ${ROOT_DIR}/boot_monitor
|
||||
add_file_spec "boot_monitor" extra.boot
|
||||
|
||||
${CROSS_TOOLS}/nbpwd_mkdb -V 0 -p -d ${DESTDIR} ${DESTDIR}/etc/master.passwd
|
||||
# add_link_spec "boot/minix_latest" "minix_default" extra.kernel
|
||||
# workdir_add_kernel minix_default
|
||||
# workdir_add_kernel minix/$RELEASE_VERSION
|
||||
|
||||
#
|
||||
# make the different file system. this part is *also* hacky. We first convert
|
||||
# the METALOG.sanitised using mtree into a input METALOG containing uids and
|
||||
# gids.
|
||||
# After that we do some magic processing to add device nodes (also missing from METALOG)
|
||||
# and convert the METALOG into a proto file that can be used by mkfs.mfs
|
||||
#
|
||||
echo "Creating the file systems"
|
||||
# add boot.cfg
|
||||
cat >${ROOT_DIR}/boot.cfg <<END_BOOT_CFG
|
||||
clear=1
|
||||
timeout=5
|
||||
default=2
|
||||
menu=Start MINIX 3:load_mods /boot/minix/.temp/mod*; multiboot /boot/minix/.temp/kernel rootdevname=c0d0p0
|
||||
END_BOOT_CFG
|
||||
add_file_spec "boot.cfg" extra.boot
|
||||
|
||||
#
|
||||
# read METALOG and use mtree to convert the user and group names into uid and gids
|
||||
# FIX put "input somewhere clean"
|
||||
#
|
||||
cat ${DESTDIR}/METALOG.sanitised | ${CROSS_TOOLS}/nbmtree -N ${DESTDIR}/etc -C -K device > ${IMG_DIR}/input
|
||||
echo "Bundling packages..."
|
||||
bundle_packages "$BUNDLE_PACKAGES"
|
||||
|
||||
# add rc (if any)
|
||||
if [ -f ${RC} ]; then
|
||||
cp ${RC} ${DESTDIR}/usr/etc/rc.local
|
||||
echo "./usr/etc/rc.local type=file uid=0 gid=0 mode=0644" >> ${IMG_DIR}/input
|
||||
fi
|
||||
|
||||
# add fstab
|
||||
echo "./etc/fstab type=file uid=0 gid=0 mode=0755 size=747 time=1365060731.000000000" >> ${IMG_DIR}/input
|
||||
|
||||
# add any generated ASR-randomized service binaries (but not their root directory, which is already there)
|
||||
# TODO: apply stricter file permissions for both these and the base /service binaries, against local attacks
|
||||
(cd ${DESTDIR} && find ./usr/service/asr -type d | sed '1d;s/$/ type=dir uid=0 gid=0 mode=0755/') >> ${IMG_DIR}/input
|
||||
(cd ${DESTDIR} && find ./usr/service/asr -type f | sed 's/$/ type=file uid=0 gid=0 mode=0755/') >> ${IMG_DIR}/input
|
||||
|
||||
# fill root.img (skipping /usr entries while keeping the /usr directory)
|
||||
cat ${IMG_DIR}/input | grep -v "^./usr/" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR} -o ${IMG_DIR}/root.proto
|
||||
|
||||
#
|
||||
# Create proto files for /usr and /home using toproto.
|
||||
#
|
||||
cat ${IMG_DIR}/input | grep "^\./usr/\|^. " | sed "s,\./usr,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/usr -o ${IMG_DIR}/usr.proto
|
||||
cat ${IMG_DIR}/input | grep "^\./home/\|^. " | sed "s,\./home,\.,g" | ${CROSS_TOOLS}/nbtoproto -b ${DESTDIR}/home -o ${IMG_DIR}/home.proto
|
||||
|
||||
if [ "x${ISOMODE}" = "x1" ]
|
||||
then
|
||||
cp ${DESTDIR}/usr/mdec/boot_monitor ${CDFILES}/boot
|
||||
cp ${MODDIR}/* ${CDFILES}/
|
||||
. ${RELEASETOOLSDIR}/release.functions
|
||||
cd_root_changes # uses $CDFILES and writes $CDFILES/boot.cfg
|
||||
# start the image off with the iso image; reduce root size to reserve
|
||||
${CROSS_TOOLS}/nbwriteisofs -s0x0 -l MINIX -B ${DESTDIR}/usr/mdec/bootxx_cd9660 -n ${CDFILES} ${IMG}
|
||||
ISO_SIZE=$((`${CROSS_TOOLS}/nbstat -f %z ${IMG}` / 512))
|
||||
else
|
||||
# just make an empty iso partition
|
||||
ISO_SIZE=8
|
||||
fi
|
||||
echo "Creating specification files..."
|
||||
create_input_spec
|
||||
create_protos "usr home"
|
||||
|
||||
#
|
||||
# Generate /root, /usr and /home partition images.
|
||||
#
|
||||
echo "Writing Minix filesystem images"
|
||||
ROOT_START=${ISO_SIZE}
|
||||
echo " - ROOT"
|
||||
_ROOT_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${IMG_DIR}/root.proto`/512))
|
||||
echo "Writing disk image..."
|
||||
rm -f "$IMG"
|
||||
ROOT_START=${BOOTXX_SECS}
|
||||
echo " * ROOT"
|
||||
_ROOT_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${ROOTSIZEARG} -I $((${ROOT_START}*512)) ${IMG} ${WORK_DIR}/proto.root)
|
||||
_ROOT_SIZE=$(($_ROOT_SIZE / 512))
|
||||
USR_START=$((${ROOT_START} + ${_ROOT_SIZE}))
|
||||
echo " - USR"
|
||||
_USR_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d ${USRSIZEARG} -I $((${USR_START}*512)) ${IMG} ${IMG_DIR}/usr.proto`/512))
|
||||
echo " * USR"
|
||||
_USR_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${USRSIZEARG} -I $((${USR_START}*512)) ${IMG} ${WORK_DIR}/proto.usr)
|
||||
_USR_SIZE=$(($_USR_SIZE / 512))
|
||||
HOME_START=$((${USR_START} + ${_USR_SIZE}))
|
||||
echo " - HOME"
|
||||
_HOME_SIZE=$((`${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${IMG_DIR}/home.proto`/512))
|
||||
echo " * HOME"
|
||||
_HOME_SIZE=$(${CROSS_TOOLS}/nbmkfs.mfs -d ${HOMESIZEARG} -I $((${HOME_START}*512)) ${IMG} ${WORK_DIR}/proto.home)
|
||||
_HOME_SIZE=$(($_HOME_SIZE / 512))
|
||||
|
||||
#
|
||||
# Write the partition table using the natively compiled
|
||||
# minix partition utility
|
||||
#
|
||||
${CROSS_TOOLS}/nbpartition -m ${IMG} 0 81:${ISO_SIZE} \
|
||||
81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
|
||||
${CROSS_TOOLS}/nbpartition -m ${IMG} ${BOOTXX_SECS} 81:${_ROOT_SIZE} 81:${_USR_SIZE} 81:${_HOME_SIZE}
|
||||
${CROSS_TOOLS}/nbinstallboot -f -m ${ARCH} ${IMG} ${DESTDIR}/usr/mdec/bootxx_minixfs3
|
||||
|
||||
|
||||
mods="`( cd ${MODDIR}; echo mod* | tr ' ' ',' )`"
|
||||
if [ "x${ISOMODE}" = "x1" ]
|
||||
then
|
||||
echo "CD image at `pwd`/${IMG}"
|
||||
else
|
||||
echo "To boot this image on kvm:"
|
||||
echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256 -kernel kernel -append \"rootdevname=c0d0p1\" -initrd \"${mods}\" -hda `pwd`/${IMG}"
|
||||
fi
|
||||
echo "Disk image at `pwd`/${IMG}"
|
||||
echo "To boot this image on kvm:"
|
||||
echo "cd ${MODDIR} && qemu-system-i386 --enable-kvm -m 256 -kernel kernel -append \"rootdevname=c0d0p0\" -initrd \"${mods}\" -hda `pwd`/${IMG}"
|
||||
|
|
|
@ -353,8 +353,8 @@ str_press_key: .asciz "\r\nPress any key to boot from CD"
|
|||
str_dot: .asciz "."
|
||||
str_read_error: .asciz "Can't read CD"
|
||||
str_no_pvd: .asciz "Can't find Primary Volume Descriptor"
|
||||
str_no_loader: .asciz "Can't find /boot"
|
||||
str_loader: .asciz "BOOT.;1"
|
||||
str_no_loader: .asciz "Can't find /minixboot"
|
||||
str_loader: .asciz "MINIXBOOT.;1"
|
||||
|
||||
/* Used to calculate free bytes */
|
||||
free_space = end - .
|
||||
|
|
Loading…
Reference in a new issue