Rev 198 | Rev 205 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/bash
#
# SvarDOS build script
# http://svardos.osdn.io
# Copyright (C) 2016-2021 Mateusz Viste
#
# This script generates the SvarDOS repository index and builds ISO CD images.
# It should be executed each time that a package has been modified, added or
# removed.
#
# usage: ./build.sh [noclean]
#
### parameters block starts here ############################################
PKGDIR=`realpath ./packages`
REPOROOT=`realpath ./website/repo`
BUILDIDX=`realpath ./buildidx/buildidx`
PUBDIR=`realpath ./website/download`
CDROOT=`realpath ./cdroot`
FLOPROOT=`realpath ./floproot`
CUSTFILES=`realpath ./files`
GENISOIMAGE='' # can be mkisofs, genisoimage or empty for autodetection
### parameters block ends here ##############################################
# auto-detect whether to use mkisofs or genisoimage
if [ "x$GENISOIMAGE" == "x" ] ; then
mkisofs --help 2> /dev/null
if [ $? -eq 0 ] ; then
GENISOIMAGE='mkisofs'
fi
fi
if [ "x$GENISOIMAGE" == "x" ] ; then
genisoimage --help 2> /dev/null
if [ $? -eq 0 ] ; then
GENISOIMAGE='genisoimage'
fi
fi
if [ "x$GENISOIMAGE" == "x" ] ; then
echo "ERROR: neither genisoimage nor mkisofs was found on this system"
exit 1
fi
# abort if anything fails
set -e
# list of packages to be part of CORE
COREPKGS="attrib chkdsk choice command cpidos ctmouse deltree devload diskcopy display dosfsck edit fc fdapm fdisk fdnpkg format himemx kernel keyb keyb_lay label mem mode more move shsucdx sort tree undelete xcopy udvd2"
# function that builds the packages repository
function dorepo {
# copy all zip files to the web repo
cp "$PKGDIR"/* $REPOROOT/
# now strip the sources from repo versions
find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "SOURCE/*" ';'
find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "source/*" ';'
find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "Source/*" ';'
# build repo idx
$BUILDIDX "$REPOROOT/"
}
# prepares image for floppy sets of size $1
function prep_flop {
mkdir $1
mformat -C -f $1 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$1/1.img"
mcopy -sQm -i "$1/1.img" "$FLOPROOT/"* ::/
# now populate the floppies
curdisk=1
for p in $COREPKGS ; do
# if copy fails, then probably the floppy is full - try again after
# creating an additional floppy image
if ! mcopy -mi "$1/$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
curdisk=$((curdisk+1))
mformat -C -f $1 -v SVARDOS -i "$1/$curdisk.img"
mcopy -mi "$1/$curdisk.img" "$CDROOT/$p.zip" ::/
fi
done
# zip the images (and remove them at the same time)
rm -f "$PUBDIR/svardos-floppy-$1k.zip"
zip -9 -rmj "$PUBDIR/svardos-floppy-$1k.zip" $1/*
# clean up
rmdir $1
}
### actual code flow starts here ############################################
# check presence of the buildidx tool
if [ ! -f "$BUILDIDX" ] ; then
echo "buildidx not found at $BUILDIDX"
exit 1
fi
# remember where I am, so I can get back here once all is done
origdir=`pwd`
mkdir "$CDROOT"
mkdir "$FLOPROOT"
# build the repo (also builds the listing.txt file)
dorepo
# add CORE packages to CDROOT + create the list of packages on floppy
for pkg in $COREPKGS ; do
cp "$REPOROOT/$pkg.zip" "$CDROOT/"
echo "$pkg" >> "$FLOPROOT/install.lst"
done
# prepare the content of the boot (install) floppy
cp "install/install.com" "$FLOPROOT/"
cp "install/nls/"install.?? "$FLOPROOT/"
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
# build the boot (CD) floppy image
export MTOOLS_NO_VFAT=1
mformat -C -f 1440 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
# prepare images for floppies in different sizes and numbers
prep_flop 2880
prep_flop 1440
prep_flop 1200
prep_flop 720
CDISO="$PUBDIR/svardos-cd.iso"
CDZIP="$PUBDIR/svardos-cd.zip"
# delete previous (if any) iso
echo "cleaning up old versions..."
rm -f "$CDISO" "$CDZIP"
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT"
# compress the ISO
zip -mj9 "$CDZIP" "$CDISO"
# cleanup temporary things
if [ "x$1" != "xnoclean" ] ; then
rm -rf "$CDROOT" "$FLOPROOT"
fi
cd "$origdir"
#cd svnlschk
#./webgen.sh
#cd ..
echo "ALL DONE!"
exit 0