Subversion Repositories SvarDOS

Rev

Rev 791 | Rev 838 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
134 mv_fox 1
#!/bin/bash
11 mv_fox 2
#
180 mateuszvis 3
# SvarDOS build script
791 mateusz.vi 4
# http://svardos.org
557 mateuszvis 5
# Copyright (C) 2016-2022 Mateusz Viste
148 mv_fox 6
#
791 mateusz.vi 7
# This script generates the SvarDOS repository index and builds floppy and CD
8
# images. It should be executed each time that a CORE package has been
9
# modified, added or removed.
11 mv_fox 10
#
836 mateusz.vi 11
# usage: ./build.sh outputdir [noclean]
194 mateuszvis 12
#
2 mv_fox 13
 
11 mv_fox 14
### parameters block starts here ############################################
15
 
643 mateusz.vi 16
CURDATE=`date +%Y%m%d`
632 mateusz.vi 17
REPOROOT=`realpath ./packages`
148 mv_fox 18
CUSTFILES=`realpath ./files`
2 mv_fox 19
 
171 mv_fox 20
GENISOIMAGE=''    # can be mkisofs, genisoimage or empty for autodetection
21
 
11 mv_fox 22
### parameters block ends here ##############################################
23
 
836 mateusz.vi 24
# look for mandatory output dir
25
if [ "x$1" == "x" ] ; then
26
  echo "usage: build.sh outputdir [noclean] > logfile"
27
  exit 1
28
fi
29
PUBDIR=`realpath "$1"`/$CURDATE.staging
30
 
31
CDROOT="$PUBDIR/tmp_cdroot.build"
32
FLOPROOT="$PUBDIR/tmp_floproot.build"
33
 
34
 
171 mv_fox 35
# auto-detect whether to use mkisofs or genisoimage
36
 
37
if [ "x$GENISOIMAGE" == "x" ] ; then
180 mateuszvis 38
mkisofs --help 2> /dev/null
171 mv_fox 39
if [ $? -eq 0 ] ; then
40
  GENISOIMAGE='mkisofs'
41
fi
42
fi
43
 
44
if [ "x$GENISOIMAGE" == "x" ] ; then
180 mateuszvis 45
genisoimage --help 2> /dev/null
171 mv_fox 46
if [ $? -eq 0 ] ; then
47
  GENISOIMAGE='genisoimage'
48
fi
49
fi
50
 
51
if [ "x$GENISOIMAGE" == "x" ] ; then
52
  echo "ERROR: neither genisoimage nor mkisofs was found on this system"
53
  exit 1
54
fi
55
 
56
 
180 mateuszvis 57
# abort if anything fails
58
set -e
134 mv_fox 59
 
60
 
300 mateuszvis 61
# list of packages to be part of CORE (always installed)
791 mateusz.vi 62
COREPKGS=`ls -1 'packages/core' | grep -o '^[a-z]*'`
192 mateuszvis 63
 
300 mateuszvis 64
# list of packages to be part of EXTRA (only sometimes installed, typically drivers)
65
EXTRAPKGS="pcntpk udvd2"
192 mateuszvis 66
 
300 mateuszvis 67
# all packages
68
ALLPKGS="$COREPKGS $EXTRAPKGS"
192 mateuszvis 69
 
300 mateuszvis 70
 
246 mateuszvis 71
# prepares image for floppy sets of:
72
# $1 cylinders
73
# $2 heads (sides)
74
# $3 sectors per track
75
# $4 size
279 mateuszvis 76
# $5 where to put a copy of the image (optional)
194 mateuszvis 77
function prep_flop {
246 mateuszvis 78
  mkdir $4
79
  mformat -C -t $1 -h $2 -s $3 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$4/disk1.img"
80
  mcopy -sQm -i "$4/disk1.img" "$FLOPROOT/"* ::/
196 mateuszvis 81
 
82
  # now populate the floppies
83
  curdisk=1
300 mateuszvis 84
  for p in $ALLPKGS ; do
196 mateuszvis 85
    # if copy fails, then probably the floppy is full - try again after
86
    # creating an additional floppy image
700 mateusz.vi 87
    if ! mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.svp" ::/ ; then
196 mateuszvis 88
      curdisk=$((curdisk+1))
246 mateuszvis 89
      mformat -C -t $1 -h $2 -s $3 -v SVARDOS -i "$4/disk$curdisk.img"
700 mateusz.vi 90
      mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.svp" ::/
196 mateuszvis 91
    fi
194 mateuszvis 92
  done
196 mateuszvis 93
 
205 mateuszvis 94
  # add a short readme
246 mateuszvis 95
  echo "This directory contains a set of $curdisk floppy images of the SvarDOS distribution in the $4 KB floppy format." > "$4/readme.txt"
96
  echo "" >> "$4/readme.txt"
97
  echo "These images are raw floppy disk dumps. To write them on an actual floppy disk, you have to use a low-level sector copying tool, like dd." >> "$4/readme.txt"
98
  echo "" >> "$4/readme.txt"
99
  echo "Latest SvarDOS version is available on the project's homepage: http://svardos.osdn.io" >> "$4/readme.txt"
205 mateuszvis 100
 
246 mateuszvis 101
  unix2dos "$4/readme.txt"
205 mateuszvis 102
 
279 mateuszvis 103
  # make a copy of the image, if requested
104
  if [ "x$5" != "x" ] ; then
105
    cp "$4/disk1.img" $5
106
  fi
107
 
196 mateuszvis 108
  # zip the images (and remove them at the same time)
246 mateuszvis 109
  rm -f "$PUBDIR/svardos-floppy-$4k.zip"
643 mateusz.vi 110
  zip -9 -rmj "$PUBDIR/svardos-$CURDATE-floppy-$4k.zip" $4/*
196 mateuszvis 111
 
112
  # clean up
246 mateuszvis 113
  rmdir $4
194 mateuszvis 114
}
115
 
116
 
134 mv_fox 117
### actual code flow starts here ############################################
118
 
148 mv_fox 119
# remember where I am, so I can get back here once all is done
11 mv_fox 120
origdir=`pwd`
121
 
836 mateusz.vi 122
echo "###############################################################################"
123
echo " STARTING BUILD $CURDATE"
124
echo "###############################################################################"
125
echo "dest dir: $PUBDIR"
126
echo "current time is `date` and it's a beautiful day somewhere in the world"
127
echo
128
 
129
mkdir "$PUBDIR"
189 mateuszvis 130
mkdir "$CDROOT"
192 mateuszvis 131
mkdir "$FLOPROOT"
189 mateuszvis 132
 
192 mateuszvis 133
# add CORE packages to CDROOT + create the list of packages on floppy
195 mateuszvis 134
for pkg in $COREPKGS ; do
791 mateusz.vi 135
  cp "$REPOROOT/core/$pkg.svp" "$CDROOT/"
192 mateuszvis 136
  echo "$pkg" >> "$FLOPROOT/install.lst"
137
done
138
 
791 mateusz.vi 139
# add EXTRA packages to CDROOT (but not in the list of packages to install)
300 mateuszvis 140
for pkg in $EXTRAPKGS ; do
700 mateusz.vi 141
  cp "$REPOROOT/$pkg.svp" "$CDROOT/"
300 mateuszvis 142
done
143
 
144
 
836 mateusz.vi 145
echo
146
echo "### Populating the floppy root at $FLOPROOT"
147
echo
148
 
192 mateuszvis 149
# prepare the content of the boot (install) floppy
150
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
791 mateusz.vi 151
unzip -Cj "$REPOROOT/core/cpidos.svp" 'cpi/ega*.cpx' -d "$FLOPROOT/"
152
unzip -Cj "$REPOROOT/core/command.svp" bin/command.com -d "$FLOPROOT/"
153
unzip -Cj "$REPOROOT/core/display.svp" bin/display.exe -d "$FLOPROOT/"
154
unzip -Cj "$REPOROOT/core/edit.svp" bin/edit.exe -d "$FLOPROOT/"
155
unzip -Cj "$REPOROOT/core/fdapm.svp" bin/fdapm.com -d "$FLOPROOT/"
156
unzip -Cj "$REPOROOT/core/fdisk.svp" bin/fdisk.exe bin/fdiskpt.ini -d "$FLOPROOT/"
157
unzip -Cj "$REPOROOT/core/format.svp" bin/format.exe -d "$FLOPROOT/"
158
unzip -Cj "$REPOROOT/core/kernel.svp" bin/kernel.sys bin/sys.com -d "$FLOPROOT/"
159
unzip -Cj "$REPOROOT/core/mem.svp" bin/mem.exe -d "$FLOPROOT/"
160
unzip -Cj "$REPOROOT/core/mode.svp" bin/mode.com -d "$FLOPROOT/"
161
unzip -Cj "$REPOROOT/core/more.svp" bin/more.exe -d "$FLOPROOT/"
162
unzip -Cj "$REPOROOT/core/pkg.svp" bin/pkg.exe -d "$FLOPROOT/"
192 mateuszvis 163
 
836 mateusz.vi 164
echo
165
echo "### Creating floppy images"
166
echo
167
 
194 mateuszvis 168
# build the boot (CD) floppy image
192 mateuszvis 169
export MTOOLS_NO_VFAT=1
279 mateuszvis 170
#mformat -C -f 2880 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
171
#mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
192 mateuszvis 172
 
246 mateuszvis 173
# prepare images for floppies in different sizes (args are C H S SIZE)
279 mateuszvis 174
prep_flop 80 2 36 2880 "$CDROOT/boot.img"
246 mateuszvis 175
prep_flop 80 2 18 1440
176
prep_flop 80 2 15 1200
177
prep_flop 80 2  9  720
316 mateuszvis 178
#prep_flop 96 64 32 98304 "$PUBDIR/svardos-zip100.img" # ZIP 100M (for USB boot in "USB-ZIP mode")
194 mateuszvis 179
 
836 mateusz.vi 180
echo
181
echo "### Computing DOSEMU.zip"
182
echo
183
 
321 mateuszvis 184
# prepare the DOSEMU boot zip
836 mateusz.vi 185
DOSEMUDIR="$PUBDIR/tmp_dosemu-prep-files.build"
321 mateuszvis 186
mkdir "$DOSEMUDIR"
322 mateuszvis 187
# INSTALL.BAT
624 mateuszvis 188
echo 'IF NOT EXIST C:\TEMP\NUL MKDIR C:\TEMP' >> "$DOSEMUDIR/install.bat"
322 mateuszvis 189
echo 'mkdir %DOSDIR%' >> "$DOSEMUDIR/install.bat"
190
echo 'mkdir %DOSDIR%\cfg' >> "$DOSEMUDIR/install.bat"
191
echo 'ECHO # pkg config file - specifies locations where packages should be installed >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
192
echo 'ECHO DIR PROGS C:\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
193
echo 'ECHO DIR GAMES C:\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
194
echo 'ECHO DIR DRIVERS C:\DRIVERS\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
195
echo 'ECHO DIR DEVEL C:\DEVEL\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
321 mateuszvis 196
for p in $COREPKGS ; do
700 mateusz.vi 197
  cp "$CDROOT/$p.svp" "$DOSEMUDIR/"
198
  echo "pkg install $p.svp" >> "$DOSEMUDIR/install.bat"
199
  echo "del $p.svp" >> "$DOSEMUDIR/install.bat"
321 mateuszvis 200
done
322 mateuszvis 201
echo 'ECHO my_ip = dhcp >> %DOSDIR%\CFG\WATTCP.CFG' >> "$DOSEMUDIR/install.bat"
202
echo 'del pkg.exe' >> "$DOSEMUDIR/install.bat"
326 mateuszvis 203
echo 'ECHO SHELLHIGH=C:\SVARDOS\BIN\COMMAND.COM /P >> C:\CONFIG.SYS' >> "$DOSEMUDIR/install.bat"
322 mateuszvis 204
echo 'ECHO.' >> "$DOSEMUDIR/install.bat"
205
echo 'ECHO -------------------------' >> "$DOSEMUDIR/install.bat"
206
echo 'ECHO  SVARDOS SETUP COMPLETED ' >> "$DOSEMUDIR/install.bat"
207
echo 'ECHO -------------------------' >> "$DOSEMUDIR/install.bat"
208
echo 'ECHO.' >> "$DOSEMUDIR/install.bat"
791 mateusz.vi 209
unzip -Cj "$REPOROOT/core/kernel.svp" bin/kernel.sys -d "$DOSEMUDIR/"
210
unzip -Cj "$REPOROOT/core/command.svp" bin/command.com -d "$DOSEMUDIR/"
211
unzip -Cj "$REPOROOT/core/pkg.svp" bin/pkg.exe -d "$DOSEMUDIR/"
322 mateuszvis 212
# CONFIG.SYS
213
echo 'FILES=50' >> "$DOSEMUDIR/config.sys"
214
echo 'DOS=HIGH,UMB' >> "$DOSEMUDIR/config.sys"
326 mateuszvis 215
echo 'DOSDATA=UMB' >> "$DOSEMUDIR/config.sys"
325 mateuszvis 216
echo 'DEVICE=D:\dosemu\emufs.sys' >> "$DOSEMUDIR/config.sys"
322 mateuszvis 217
echo 'DEVICE=D:\dosemu\umb.sys' >> "$DOSEMUDIR/config.sys"
325 mateuszvis 218
echo 'DEVICEHIGH=D:\dosemu\ems.sys' >> "$DOSEMUDIR/config.sys"
322 mateuszvis 219
echo 'INSTALL=D:\dosemu\emufs.com' >> "$DOSEMUDIR/config.sys"
220
# AUTOEXEC.BAT
321 mateuszvis 221
echo "@ECHO OFF" >> "$DOSEMUDIR/autoexec.bat"
322 mateuszvis 222
echo 'SET DOSDIR=C:\SVARDOS' >> "$DOSEMUDIR/autoexec.bat"
223
echo 'SET WATTCP.CFG=%DOSDIR%\CFG' >> "$DOSEMUDIR/autoexec.bat"
224
echo 'SET DIRCMD=/p/ogne' >> "$DOSEMUDIR/autoexec.bat"
624 mateuszvis 225
echo 'SET TEMP=C:\TEMP' >> "$DOSEMUDIR/autoexec.bat"
322 mateuszvis 226
echo 'PATH %DOSDIR%\BIN' >> "$DOSEMUDIR/autoexec.bat"
227
echo "" >> "$DOSEMUDIR/autoexec.bat"
228
echo "REM *** this is a one-time setup script used only during first initialization ***" >> "$DOSEMUDIR/autoexec.bat"
229
echo 'IF EXIST INSTALL.BAT CALL INSTALL.BAT' >> "$DOSEMUDIR/autoexec.bat"
230
echo 'IF EXIST INSTALL.BAT DEL INSTALL.BAT' >> "$DOSEMUDIR/autoexec.bat"
231
echo "" >> "$DOSEMUDIR/autoexec.bat"
321 mateuszvis 232
echo "ECHO." >> "$DOSEMUDIR/autoexec.bat"
233
echo "ECHO Welcome to SvarDOS (powered by DOSEMU)! Type HELP if you are lost." >> "$DOSEMUDIR/autoexec.bat"
234
echo "ECHO." >> "$DOSEMUDIR/autoexec.bat"
235
rm -f "$PUBDIR/svardos-dosemu.zip"
643 mateusz.vi 236
zip -rm9jk "$PUBDIR/svardos-$CURDATE-dosemu.zip" "$DOSEMUDIR"
321 mateuszvis 237
rmdir "$DOSEMUDIR"
238
 
836 mateusz.vi 239
echo
240
echo "### Computing the USB image"
241
echo
242
 
316 mateuszvis 243
# prepare the USB bootable image
244
USBIMG=$PUBDIR/svardos-usb.img
245
cp files/boot-svardos.img $USBIMG
246
mcopy -sQm -i "$USBIMG@@32256" "$FLOPROOT/"* ::/
247
for p in $ALLPKGS ; do
700 mateusz.vi 248
  mcopy -mi "$USBIMG@@32256" "$CDROOT/$p.svp" ::/
316 mateuszvis 249
done
250
 
251
# compress the USB image
643 mateusz.vi 252
zip -mj9 "$PUBDIR/svardos-$CURDATE-usb.zip" "$USBIMG"
316 mateuszvis 253
 
254
# prepare the USB-ZIP bootable image
255
#USBZIPIMG=$PUBDIR/svardos-usbzip.img
256
#cat files/usb-zip.mbr "$PUBDIR/svardos-zip100.img" > $USBZIPIMG
257
 
836 mateusz.vi 258
echo
259
echo "### Generating ISO CD image"
260
echo
261
 
643 mateusz.vi 262
CDISO="$PUBDIR/svardos-$CURDATE-cd.iso"
263
CDZIP="$PUBDIR/svardos-$CURDATE-cd.zip"
194 mateuszvis 264
 
204 mateuszvis 265
# delete previous (if any) iso
836 mateusz.vi 266
#echo "cleaning up old versions..."
267
#rm -f "$CDISO" "$CDZIP"
25 mv_fox 268
 
279 mateuszvis 269
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT/boot.img"
2 mv_fox 270
 
204 mateuszvis 271
# compress the ISO
272
zip -mj9 "$CDZIP" "$CDISO"
273
 
192 mateuszvis 274
# cleanup temporary things
836 mateusz.vi 275
if [ "x$2" != "xnoclean" ] ; then
276
  echo
277
  echo "### Clenup of temporary directories:"
278
  echo "# $CDROOT"
279
  echo "# $FLOPROOT"
280
  echo
194 mateuszvis 281
  rm -rf "$CDROOT" "$FLOPROOT"
282
fi
189 mateuszvis 283
 
11 mv_fox 284
cd "$origdir"
285
 
180 mateuszvis 286
#cd svnlschk
287
#./webgen.sh
288
#cd ..
165 mv_fox 289
 
836 mateusz.vi 290
echo
291
echo "### ALL DONE! ###"
16 mv_fox 292
 
2 mv_fox 293
exit 0