Subversion Repositories SvarDOS

Rev

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