Subversion Repositories SvarDOS

Rev

Rev 1499 | Rev 1528 | 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
1261 mateusz.vi 5
# Copyright (C) 2016-2023 Mateusz Viste
148 mv_fox 6
#
847 mateusz.vi 7
# This script builds floppy and CD images. It should be executed each time that
852 mateusz.vi 8
# a CORE package has been modified or the build script changed. This is usually
9
# done by the cron.sh script, itself called by a cron job.
11 mv_fox 10
#
854 mateusz.vi 11
# usage: ./build.sh outputdir buildver [noclean] > logfile
194 mateuszvis 12
#
2 mv_fox 13
 
11 mv_fox 14
### parameters block starts here ############################################
15
 
632 mateusz.vi 16
REPOROOT=`realpath ./packages`
1261 mateusz.vi 17
REPOROOTCORE=`realpath ./packages-core`
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
 
854 mateusz.vi 24
# look for mandatory output dir and build id
25
if [ "x$2" == "x" ] ; then
26
  echo "usage: build.sh outputdir buildver [noclean]"
836 mateusz.vi 27
  exit 1
28
fi
854 mateusz.vi 29
CURDATE="$2"
30
PUBDIR=`realpath "$1"`
836 mateusz.vi 31
 
32
CDROOT="$PUBDIR/tmp_cdroot.build"
33
FLOPROOT="$PUBDIR/tmp_floproot.build"
34
 
35
 
171 mv_fox 36
# auto-detect whether to use mkisofs or genisoimage
37
 
38
if [ "x$GENISOIMAGE" == "x" ] ; then
180 mateuszvis 39
mkisofs --help 2> /dev/null
171 mv_fox 40
if [ $? -eq 0 ] ; then
41
  GENISOIMAGE='mkisofs'
42
fi
43
fi
44
 
45
if [ "x$GENISOIMAGE" == "x" ] ; then
180 mateuszvis 46
genisoimage --help 2> /dev/null
171 mv_fox 47
if [ $? -eq 0 ] ; then
48
  GENISOIMAGE='genisoimage'
49
fi
50
fi
51
 
52
if [ "x$GENISOIMAGE" == "x" ] ; then
53
  echo "ERROR: neither genisoimage nor mkisofs was found on this system"
54
  exit 1
55
fi
56
 
57
 
180 mateuszvis 58
# abort if anything fails
59
set -e
134 mv_fox 60
 
61
 
300 mateuszvis 62
# list of packages to be part of CORE (always installed)
1261 mateusz.vi 63
COREPKGS=`ls -1 'packages-core' | grep -o '^[a-z]*'`
192 mateuszvis 64
 
300 mateuszvis 65
# list of packages to be part of EXTRA (only sometimes installed, typically drivers)
66
EXTRAPKGS="pcntpk udvd2"
192 mateuszvis 67
 
300 mateuszvis 68
# all packages
69
ALLPKGS="$COREPKGS $EXTRAPKGS"
192 mateuszvis 70
 
300 mateuszvis 71
 
246 mateuszvis 72
# prepares image for floppy sets of:
73
# $1 cylinders
74
# $2 heads (sides)
75
# $3 sectors per track
76
# $4 size
849 mateusz.vi 77
# $5 working directory (for temporary files etc)
1527 mateusz.vi 78
# $6 name of the set (eg. "1440k" or "1440k-EN")
79
# $7 where to put a copy of the image (optional)
194 mateuszvis 80
function prep_flop {
1527 mateusz.vi 81
  WORKDIR="$5/$6"
849 mateusz.vi 82
  mkdir "$WORKDIR"
83
  mformat -C -t $1 -h $2 -s $3 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$WORKDIR/disk1.img"
84
  mcopy -sQm -i "$WORKDIR/disk1.img" "$FLOPROOT/"* ::/
196 mateuszvis 85
 
86
  # now populate the floppies
87
  curdisk=1
1127 mateusz.vi 88
  LIST=$ALLPKGS
89
 
90
  while [ ! -z "$LIST" ] ; do
91
 
92
    unset PENDING
93
    for p in $LIST ; do
94
      # if copy fails, then probably the floppy is full - try other packages
95
      # but remember all that fails so they will be retried on a new floppy
96
      if ! mcopy -mi "$WORKDIR/disk$curdisk.img" "$CDROOT/$p.svp" ::/ ; then
97
        PENDING="$PENDING $p"
98
      fi
99
    done
100
 
101
    LIST="$PENDING"
102
    # if there are any pending items, then create a new floppy and try pushing pending packages to it
103
    if [ ! -z "$PENDING" ] ; then
196 mateuszvis 104
      curdisk=$((curdisk+1))
849 mateusz.vi 105
      mformat -C -t $1 -h $2 -s $3 -v SVARDOS -i "$WORKDIR/disk$curdisk.img"
196 mateuszvis 106
    fi
1127 mateusz.vi 107
 
194 mateuszvis 108
  done
196 mateuszvis 109
 
205 mateuszvis 110
  # add a short readme
849 mateusz.vi 111
  echo "This directory contains a set of $curdisk floppy images of the SvarDOS distribution in the $4 KB floppy format." > "$WORKDIR/readme.txt"
112
  echo "" >> "$WORKDIR/readme.txt"
113
  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." >> "$WORKDIR/readme.txt"
114
  echo "" >> "$WORKDIR/readme.txt"
862 mateusz.vi 115
  echo "Latest SvarDOS version is available on the project's homepage: http://svardos.org" >> "$WORKDIR/readme.txt"
205 mateuszvis 116
 
849 mateusz.vi 117
  unix2dos "$WORKDIR/readme.txt"
205 mateuszvis 118
 
279 mateuszvis 119
  # make a copy of the image, if requested
1527 mateusz.vi 120
  if [ "x$7" != "x" ] ; then
121
    cp "$WORKDIR/disk1.img" $7
279 mateuszvis 122
  fi
123
 
196 mateuszvis 124
  # zip the images (and remove them at the same time)
1527 mateusz.vi 125
  zip -9 -rmj "$PUBDIR/svardos-$CURDATE-floppy-$6.zip" "$WORKDIR"/*
196 mateuszvis 126
 
127
  # clean up
849 mateusz.vi 128
  rmdir "$WORKDIR"
194 mateuszvis 129
}
130
 
131
 
134 mv_fox 132
### actual code flow starts here ############################################
133
 
148 mv_fox 134
# remember where I am, so I can get back here once all is done
11 mv_fox 135
origdir=`pwd`
136
 
836 mateusz.vi 137
echo "###############################################################################"
138
echo " STARTING BUILD $CURDATE"
139
echo "###############################################################################"
140
echo "dest dir: $PUBDIR"
141
echo "current time is `date` and it's a beautiful day somewhere in the world"
142
echo
143
 
189 mateuszvis 144
mkdir "$CDROOT"
192 mateuszvis 145
mkdir "$FLOPROOT"
189 mateuszvis 146
 
192 mateuszvis 147
# add CORE packages to CDROOT + create the list of packages on floppy
195 mateuszvis 148
for pkg in $COREPKGS ; do
1261 mateusz.vi 149
  cp "$REPOROOTCORE/$pkg.svp" "$CDROOT/"
192 mateuszvis 150
  echo "$pkg" >> "$FLOPROOT/install.lst"
151
done
152
 
791 mateusz.vi 153
# add EXTRA packages to CDROOT (but not in the list of packages to install)
300 mateuszvis 154
for pkg in $EXTRAPKGS ; do
700 mateusz.vi 155
  cp "$REPOROOT/$pkg.svp" "$CDROOT/"
300 mateuszvis 156
done
157
 
158
 
836 mateusz.vi 159
echo
160
echo "### Populating the floppy root at $FLOPROOT"
161
echo
162
 
862 mateusz.vi 163
# prepare the content of the boot (install) floppy, unzipping everything
164
# in lowercase (-L) to avoid any case mismatching later in the build process
192 mateuszvis 165
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
1261 mateusz.vi 166
unzip -CLj "$REPOROOTCORE/cpidos.svp" 'cpi/ega*.cpx' -d "$FLOPROOT/"
167
unzip -CLj "$REPOROOTCORE/svarcom.svp" command.com -d "$FLOPROOT/"
168
unzip -CLj "$REPOROOTCORE/display.svp" bin/display.exe -d "$FLOPROOT/"
169
unzip -CLj "$REPOROOTCORE/fdapm.svp" bin/fdapm.com -d "$FLOPROOT/"
1478 mateusz.vi 170
unzip -CLj "$REPOROOTCORE/fdisk.svp" bin/fdisk.exe -d "$FLOPROOT/"
1261 mateusz.vi 171
unzip -CLj "$REPOROOTCORE/format.svp" bin/format.exe -d "$FLOPROOT/"
172
unzip -CLj "$REPOROOTCORE/kernel.svp" bin/kernel.sys bin/sys.com -d "$FLOPROOT/"
173
unzip -CLj "$REPOROOTCORE/mem.svp" bin/mem.exe -d "$FLOPROOT/"
174
unzip -CLj "$REPOROOTCORE/mode.svp" bin/mode.com -d "$FLOPROOT/"
1499 mateusz.vi 175
unzip -CLj "$REPOROOTCORE/more.svp" bin/more.com -d "$FLOPROOT/"
1261 mateusz.vi 176
unzip -CLj "$REPOROOTCORE/pkg.svp" bin/pkg.exe -d "$FLOPROOT/"
1465 mateusz.vi 177
unzip -CLj "$REPOROOTCORE/sved.svp" bin/sved.com -d "$FLOPROOT/"
192 mateuszvis 178
 
867 mateusz.vi 179
# generate a simple autoexec.bat file
180
echo '@ECHO OFF' > "$FLOPROOT/autoexec.bat"
181
echo '' >> "$FLOPROOT/autoexec.bat"
182
echo 'REM Load DISPLAY driver if present' >> "$FLOPROOT/autoexec.bat"
183
echo 'IF EXIST DISPLAY.EXE DISPLAY CON=(EGA,,1)' >> "$FLOPROOT/autoexec.bat"
184
echo '' >> "$FLOPROOT/autoexec.bat"
185
echo 'FDAPM APMDOS' >> "$FLOPROOT/autoexec.bat"
186
echo '' >> "$FLOPROOT/autoexec.bat"
187
echo 'ECHO.' >> "$FLOPROOT/autoexec.bat"
188
echo 'ECHO  ********************' >> "$FLOPROOT/autoexec.bat"
189
echo 'ECHO   WELCOME TO SVARDOS' >> "$FLOPROOT/autoexec.bat"
190
echo 'ECHO  ********************' >> "$FLOPROOT/autoexec.bat"
191
echo "ECHO  build: $CURDATE" >> "$FLOPROOT/autoexec.bat"
192
echo 'ECHO.' >> "$FLOPROOT/autoexec.bat"
193
echo '' >> "$FLOPROOT/autoexec.bat"
194
echo "INSTALL $CURDATE" >> "$FLOPROOT/autoexec.bat"
195
unix2dos "$FLOPROOT/autoexec.bat"
862 mateusz.vi 196
 
867 mateusz.vi 197
 
836 mateusz.vi 198
echo
862 mateusz.vi 199
echo "### Computing the USB image"
200
echo
201
 
202
# prepare the USB bootable image
203
USBIMG=$PUBDIR/svardos-usb.img
204
cp files/boot-svardos.img $USBIMG
205
mcopy -sQm -i "$USBIMG@@32256" "$FLOPROOT/"* ::/
206
for p in $ALLPKGS ; do
207
  mcopy -mi "$USBIMG@@32256" "$CDROOT/$p.svp" ::/
208
done
209
 
210
# compress the USB image
211
zip -mj9 "$PUBDIR/svardos-$CURDATE-usb.zip" "$USBIMG"
212
 
213
 
214
echo
836 mateusz.vi 215
echo "### Creating floppy images"
216
echo
1212 mateusz.vi 217
echo "You might notice a lot of DISK FULL warnings below. Do not worry, these"
218
echo "are expected and are perfectly normal. It is a side effect of trying to"
219
echo "fit as many packages as possible on the floppy sets."
220
echo
836 mateusz.vi 221
 
194 mateuszvis 222
# build the boot (CD) floppy image
192 mateuszvis 223
export MTOOLS_NO_VFAT=1
224
 
246 mateuszvis 225
# prepare images for floppies in different sizes (args are C H S SIZE)
1527 mateusz.vi 226
prep_flop 80 2 36 2880 "$PUBDIR" "2.88M" "$CDROOT/boot.img"
227
prep_flop 80 2 18 1440 "$PUBDIR" "1.44M"
228
prep_flop 80 2 15 1200 "$PUBDIR" "1.2M"
229
prep_flop 80 2  9  720 "$PUBDIR" "720K"
194 mateuszvis 230
 
1527 mateusz.vi 231
# remove internationalization files for EN-ONLY releases. This is the only way
232
# to build the 360K variant
862 mateusz.vi 233
rm "$FLOPROOT"/*.cpx
234
rm "$FLOPROOT"/install.lng
235
rm "$FLOPROOT"/display.exe
236
rm "$FLOPROOT"/mode.com
237
#
238
 
1527 mateusz.vi 239
# disabling EN-ONLY builds of 1.4M, 1.2M and 720K because EN-ONLY does not
240
# decrease the amount of diskettes at this moment.
241
#prep_flop 80 2 18 1440 "$PUBDIR" "1.44M-EN_ONLY"
242
#prep_flop 80 2 15 1200 "$PUBDIR" "1.2M-EN_ONLY"
243
#prep_flop 80 2  9  720 "$PUBDIR" "720K-EN_ONLY"
244
prep_flop 40 2  9  360 "$PUBDIR" "360K-EN_ONLY"
862 mateusz.vi 245
 
1527 mateusz.vi 246
 
836 mateusz.vi 247
echo
248
echo "### Computing DOSEMU.zip"
249
echo
250
 
321 mateuszvis 251
# prepare the DOSEMU boot zip
836 mateusz.vi 252
DOSEMUDIR="$PUBDIR/tmp_dosemu-prep-files.build"
321 mateuszvis 253
mkdir "$DOSEMUDIR"
322 mateuszvis 254
# INSTALL.BAT
624 mateuszvis 255
echo 'IF NOT EXIST C:\TEMP\NUL MKDIR C:\TEMP' >> "$DOSEMUDIR/install.bat"
322 mateuszvis 256
echo 'mkdir %DOSDIR%' >> "$DOSEMUDIR/install.bat"
257
echo 'mkdir %DOSDIR%\cfg' >> "$DOSEMUDIR/install.bat"
258
echo 'ECHO # pkg config file - specifies locations where packages should be installed >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
259
echo 'ECHO DIR PROGS C:\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
260
echo 'ECHO DIR GAMES C:\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
261
echo 'ECHO DIR DRIVERS C:\DRIVERS\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
262
echo 'ECHO DIR DEVEL C:\DEVEL\ >> %DOSDIR%\cfg\pkg.cfg' >> "$DOSEMUDIR/install.bat"
321 mateuszvis 263
for p in $COREPKGS ; do
700 mateusz.vi 264
  cp "$CDROOT/$p.svp" "$DOSEMUDIR/"
265
  echo "pkg install $p.svp" >> "$DOSEMUDIR/install.bat"
266
  echo "del $p.svp" >> "$DOSEMUDIR/install.bat"
321 mateuszvis 267
done
322 mateuszvis 268
echo 'ECHO my_ip = dhcp >> %DOSDIR%\CFG\WATTCP.CFG' >> "$DOSEMUDIR/install.bat"
269
echo 'del pkg.exe' >> "$DOSEMUDIR/install.bat"
1103 mateusz.vi 270
echo 'DEL C:\CONFIG.SYS' >> "$DOSEMUDIR/install.bat"
271
echo 'COPY C:\CONFIG.NEW C:\CONFIG.SYS' >> "$DOSEMUDIR/install.bat"
272
echo 'DEL C:\CONFIG.NEW' >> "$DOSEMUDIR/install.bat"
273
echo 'SET COMSPEC=C:\COMMAND.COM' >> "$DOSEMUDIR/install.bat"
274
echo 'DEL C:\CMD.COM' >> "$DOSEMUDIR/install.bat"
322 mateuszvis 275
echo 'ECHO.' >> "$DOSEMUDIR/install.bat"
276
echo 'ECHO -------------------------' >> "$DOSEMUDIR/install.bat"
1103 mateusz.vi 277
echo 'ECHO  SVARDOS SETUP COMPLETED' >> "$DOSEMUDIR/install.bat"
278
echo 'ECHO   PLEASE RESTART DOSEMU' >> "$DOSEMUDIR/install.bat"
322 mateuszvis 279
echo 'ECHO -------------------------' >> "$DOSEMUDIR/install.bat"
280
echo 'ECHO.' >> "$DOSEMUDIR/install.bat"
1261 mateusz.vi 281
unzip -Cj "$REPOROOTCORE/kernel.svp" bin/kernel.sys -d "$DOSEMUDIR/"
282
unzip -CLj "$REPOROOTCORE/svarcom.svp" command.com -d "$DOSEMUDIR/"
1103 mateusz.vi 283
mv "$DOSEMUDIR/command.com" "$DOSEMUDIR/cmd.com"
1261 mateusz.vi 284
unzip -Cj "$REPOROOTCORE/pkg.svp" bin/pkg.exe -d "$DOSEMUDIR/"
322 mateuszvis 285
# CONFIG.SYS
1103 mateusz.vi 286
echo 'FILES=25' >> "$DOSEMUDIR/config.sys"
322 mateuszvis 287
echo 'DOS=HIGH,UMB' >> "$DOSEMUDIR/config.sys"
326 mateuszvis 288
echo 'DOSDATA=UMB' >> "$DOSEMUDIR/config.sys"
325 mateuszvis 289
echo 'DEVICE=D:\dosemu\emufs.sys' >> "$DOSEMUDIR/config.sys"
322 mateuszvis 290
echo 'DEVICE=D:\dosemu\umb.sys' >> "$DOSEMUDIR/config.sys"
325 mateuszvis 291
echo 'DEVICEHIGH=D:\dosemu\ems.sys' >> "$DOSEMUDIR/config.sys"
322 mateuszvis 292
echo 'INSTALL=D:\dosemu\emufs.com' >> "$DOSEMUDIR/config.sys"
1103 mateusz.vi 293
cp "$DOSEMUDIR/config.sys" "$DOSEMUDIR/config.new"
294
echo 'SHELL=C:\CMD.COM /P' >> "$DOSEMUDIR/config.sys"
295
echo 'SHELL=C:\COMMAND.COM /P' >> "$DOSEMUDIR/config.new"
322 mateuszvis 296
# AUTOEXEC.BAT
321 mateuszvis 297
echo "@ECHO OFF" >> "$DOSEMUDIR/autoexec.bat"
322 mateuszvis 298
echo 'SET DOSDIR=C:\SVARDOS' >> "$DOSEMUDIR/autoexec.bat"
299
echo 'SET WATTCP.CFG=%DOSDIR%\CFG' >> "$DOSEMUDIR/autoexec.bat"
300
echo 'SET DIRCMD=/p/ogne' >> "$DOSEMUDIR/autoexec.bat"
624 mateuszvis 301
echo 'SET TEMP=C:\TEMP' >> "$DOSEMUDIR/autoexec.bat"
322 mateuszvis 302
echo 'PATH %DOSDIR%\BIN' >> "$DOSEMUDIR/autoexec.bat"
303
echo "" >> "$DOSEMUDIR/autoexec.bat"
1103 mateusz.vi 304
echo 'IF NOT EXIST INSTALL.BAT GOTO NORMBOOT' >> "$DOSEMUDIR/autoexec.bat"
322 mateuszvis 305
echo "REM *** this is a one-time setup script used only during first initialization ***" >> "$DOSEMUDIR/autoexec.bat"
1103 mateusz.vi 306
echo 'CALL INSTALL.BAT' >> "$DOSEMUDIR/autoexec.bat"
307
echo 'DEL INSTALL.BAT' >> "$DOSEMUDIR/autoexec.bat"
308
echo 'GOTO ENDOFFILE' >> "$DOSEMUDIR/autoexec.bat"
322 mateuszvis 309
echo "" >> "$DOSEMUDIR/autoexec.bat"
1103 mateusz.vi 310
echo ":NORMBOOT" >> "$DOSEMUDIR/autoexec.bat"
321 mateuszvis 311
echo "ECHO." >> "$DOSEMUDIR/autoexec.bat"
312
echo "ECHO Welcome to SvarDOS (powered by DOSEMU)! Type HELP if you are lost." >> "$DOSEMUDIR/autoexec.bat"
313
echo "ECHO." >> "$DOSEMUDIR/autoexec.bat"
1103 mateusz.vi 314
echo ":ENDOFFILE" >> "$DOSEMUDIR/autoexec.bat"
321 mateuszvis 315
rm -f "$PUBDIR/svardos-dosemu.zip"
643 mateusz.vi 316
zip -rm9jk "$PUBDIR/svardos-$CURDATE-dosemu.zip" "$DOSEMUDIR"
321 mateuszvis 317
rmdir "$DOSEMUDIR"
318
 
836 mateusz.vi 319
echo
320
echo "### Generating ISO CD image"
321
echo
322
 
643 mateusz.vi 323
CDISO="$PUBDIR/svardos-$CURDATE-cd.iso"
324
CDZIP="$PUBDIR/svardos-$CURDATE-cd.zip"
194 mateuszvis 325
 
279 mateuszvis 326
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT/boot.img"
2 mv_fox 327
 
204 mateuszvis 328
# compress the ISO
329
zip -mj9 "$CDZIP" "$CDISO"
330
 
192 mateuszvis 331
# cleanup temporary things
836 mateusz.vi 332
if [ "x$2" != "xnoclean" ] ; then
333
  echo
904 bttr 334
  echo "### Cleanup of temporary directories:"
836 mateusz.vi 335
  echo "# $CDROOT"
336
  echo "# $FLOPROOT"
337
  echo
194 mateuszvis 338
  rm -rf "$CDROOT" "$FLOPROOT"
339
fi
189 mateuszvis 340
 
11 mv_fox 341
cd "$origdir"
342
 
836 mateusz.vi 343
echo
344
echo "### ALL DONE! ###"
16 mv_fox 345
 
2 mv_fox 346
exit 0