Subversion Repositories SvarDOS

Rev

Rev 316 | Rev 322 | 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
4
# http://svardos.osdn.io
5
# Copyright (C) 2016-2021 Mateusz Viste
148 mv_fox 6
#
180 mateuszvis 7
# This script generates the SvarDOS repository index and builds ISO CD images.
8
# It should be executed each time that a package has been modified, added or
9
# removed.
11 mv_fox 10
#
194 mateuszvis 11
# usage: ./build.sh [noclean]
12
#
2 mv_fox 13
 
11 mv_fox 14
### parameters block starts here ############################################
15
 
180 mateuszvis 16
PKGDIR=`realpath ./packages`
17
REPOROOT=`realpath ./website/repo`
185 mateuszvis 18
BUILDIDX=`realpath ./buildidx/buildidx`
180 mateuszvis 19
PUBDIR=`realpath ./website/download`
148 mv_fox 20
CDROOT=`realpath ./cdroot`
192 mateuszvis 21
FLOPROOT=`realpath ./floproot`
148 mv_fox 22
CUSTFILES=`realpath ./files`
2 mv_fox 23
 
171 mv_fox 24
GENISOIMAGE=''    # can be mkisofs, genisoimage or empty for autodetection
25
 
11 mv_fox 26
### parameters block ends here ##############################################
27
 
171 mv_fox 28
# auto-detect whether to use mkisofs or genisoimage
29
 
30
if [ "x$GENISOIMAGE" == "x" ] ; then
180 mateuszvis 31
mkisofs --help 2> /dev/null
171 mv_fox 32
if [ $? -eq 0 ] ; then
33
  GENISOIMAGE='mkisofs'
34
fi
35
fi
36
 
37
if [ "x$GENISOIMAGE" == "x" ] ; then
180 mateuszvis 38
genisoimage --help 2> /dev/null
171 mv_fox 39
if [ $? -eq 0 ] ; then
40
  GENISOIMAGE='genisoimage'
41
fi
42
fi
43
 
44
if [ "x$GENISOIMAGE" == "x" ] ; then
45
  echo "ERROR: neither genisoimage nor mkisofs was found on this system"
46
  exit 1
47
fi
48
 
49
 
180 mateuszvis 50
# abort if anything fails
51
set -e
134 mv_fox 52
 
53
 
300 mateuszvis 54
# list of packages to be part of CORE (always installed)
307 mateuszvis 55
COREPKGS="amb attrib chkdsk choice command cpidos deltree devload diskcopy display dosfsck edit fc fdapm fdisk format help himemx kernel keyb keyb_lay label mem mode more move pkg pkgnet shsucdx sort tree"
192 mateuszvis 56
 
300 mateuszvis 57
# list of packages to be part of EXTRA (only sometimes installed, typically drivers)
58
EXTRAPKGS="pcntpk udvd2"
192 mateuszvis 59
 
300 mateuszvis 60
# all packages
61
ALLPKGS="$COREPKGS $EXTRAPKGS"
192 mateuszvis 62
 
300 mateuszvis 63
 
180 mateuszvis 64
# function that builds the packages repository
65
function dorepo {
66
  # copy all zip files to the web repo
67
  cp "$PKGDIR"/* $REPOROOT/
68
  # now strip the sources from repo versions
69
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "SOURCE/*" ';'
70
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "source/*" ';'
71
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "Source/*" ';'
134 mv_fox 72
 
180 mateuszvis 73
  # build repo idx
74
  $BUILDIDX "$REPOROOT/"
134 mv_fox 75
}
76
 
194 mateuszvis 77
 
246 mateuszvis 78
# prepares image for floppy sets of:
79
# $1 cylinders
80
# $2 heads (sides)
81
# $3 sectors per track
82
# $4 size
279 mateuszvis 83
# $5 where to put a copy of the image (optional)
194 mateuszvis 84
function prep_flop {
246 mateuszvis 85
  mkdir $4
86
  mformat -C -t $1 -h $2 -s $3 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$4/disk1.img"
87
  mcopy -sQm -i "$4/disk1.img" "$FLOPROOT/"* ::/
196 mateuszvis 88
 
89
  # now populate the floppies
90
  curdisk=1
300 mateuszvis 91
  for p in $ALLPKGS ; do
196 mateuszvis 92
    # if copy fails, then probably the floppy is full - try again after
93
    # creating an additional floppy image
246 mateuszvis 94
    if ! mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
196 mateuszvis 95
      curdisk=$((curdisk+1))
246 mateuszvis 96
      mformat -C -t $1 -h $2 -s $3 -v SVARDOS -i "$4/disk$curdisk.img"
97
      mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/
196 mateuszvis 98
    fi
194 mateuszvis 99
  done
196 mateuszvis 100
 
205 mateuszvis 101
  # add a short readme
246 mateuszvis 102
  echo "This directory contains a set of $curdisk floppy images of the SvarDOS distribution in the $4 KB floppy format." > "$4/readme.txt"
103
  echo "" >> "$4/readme.txt"
104
  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"
105
  echo "" >> "$4/readme.txt"
106
  echo "Latest SvarDOS version is available on the project's homepage: http://svardos.osdn.io" >> "$4/readme.txt"
205 mateuszvis 107
 
246 mateuszvis 108
  unix2dos "$4/readme.txt"
205 mateuszvis 109
 
279 mateuszvis 110
  # make a copy of the image, if requested
111
  if [ "x$5" != "x" ] ; then
112
    cp "$4/disk1.img" $5
113
  fi
114
 
196 mateuszvis 115
  # zip the images (and remove them at the same time)
246 mateuszvis 116
  rm -f "$PUBDIR/svardos-floppy-$4k.zip"
117
  zip -9 -rmj "$PUBDIR/svardos-floppy-$4k.zip" $4/*
196 mateuszvis 118
 
119
  # clean up
246 mateuszvis 120
  rmdir $4
194 mateuszvis 121
}
122
 
123
 
134 mv_fox 124
### actual code flow starts here ############################################
125
 
148 mv_fox 126
# check presence of the buildidx tool
127
if [ ! -f "$BUILDIDX" ] ; then
128
  echo "buildidx not found at $BUILDIDX"
112 mv_fox 129
  exit 1
130
fi
131
 
148 mv_fox 132
# remember where I am, so I can get back here once all is done
11 mv_fox 133
origdir=`pwd`
134
 
189 mateuszvis 135
mkdir "$CDROOT"
192 mateuszvis 136
mkdir "$FLOPROOT"
189 mateuszvis 137
 
180 mateuszvis 138
# build the repo (also builds the listing.txt file)
139
dorepo
16 mv_fox 140
 
192 mateuszvis 141
# add CORE packages to CDROOT + create the list of packages on floppy
195 mateuszvis 142
for pkg in $COREPKGS ; do
192 mateuszvis 143
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
144
  echo "$pkg" >> "$FLOPROOT/install.lst"
145
done
146
 
300 mateuszvis 147
# add EXTRA packages to CDROOT (but not in the list of packages so instal won't install them by default)
148
for pkg in $EXTRAPKGS ; do
149
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
150
done
151
 
152
 
192 mateuszvis 153
# prepare the content of the boot (install) floppy
154
cp "install/install.com" "$FLOPROOT/"
155
cp "install/nls/"install.?? "$FLOPROOT/"
156
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
305 mateuszvis 157
unzip -Cj packages/cpidos.zip 'cpi/ega*.cpx' -d "$FLOPROOT/"
158
unzip -Cj packages/command.zip bin/command.com -d "$FLOPROOT/"
159
unzip -Cj packages/display.zip bin/display.exe -d "$FLOPROOT/"
160
unzip -Cj packages/edit.zip bin/edit.exe -d "$FLOPROOT/"
161
unzip -Cj packages/fdapm.zip bin/fdapm.com -d "$FLOPROOT/"
162
unzip -Cj packages/fdisk.zip bin/fdisk.exe bin/fdiskpt.ini -d "$FLOPROOT/"
163
unzip -Cj packages/format.zip bin/format.exe -d "$FLOPROOT/"
164
unzip -Cj packages/kernel.zip bin/kernel.sys bin/sys.com -d "$FLOPROOT/"
165
unzip -Cj packages/mem.zip bin/mem.exe -d "$FLOPROOT/"
166
unzip -Cj packages/mode.zip bin/mode.com -d "$FLOPROOT/"
167
unzip -Cj packages/more.zip bin/more.exe -d "$FLOPROOT/"
168
unzip -Cj packages/pkg.zip bin/pkg.exe -d "$FLOPROOT/"
192 mateuszvis 169
 
194 mateuszvis 170
# build the boot (CD) floppy image
192 mateuszvis 171
export MTOOLS_NO_VFAT=1
279 mateuszvis 172
#mformat -C -f 2880 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
173
#mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
192 mateuszvis 174
 
246 mateuszvis 175
# prepare images for floppies in different sizes (args are C H S SIZE)
279 mateuszvis 176
prep_flop 80 2 36 2880 "$CDROOT/boot.img"
246 mateuszvis 177
prep_flop 80 2 18 1440
178
prep_flop 80 2 15 1200
179
prep_flop 80 2  9  720
316 mateuszvis 180
#prep_flop 96 64 32 98304 "$PUBDIR/svardos-zip100.img" # ZIP 100M (for USB boot in "USB-ZIP mode")
194 mateuszvis 181
 
321 mateuszvis 182
# prepare the DOSEMU boot zip
183
DOSEMUDIR='dosemu-prep-files'
184
mkdir "$DOSEMUDIR"
185
echo "mkdir %DOSDIR%" >> "$DOSEMUDIR/install.bat"
186
echo "mkdir %DOSDIR%\\cfg" >> "$DOSEMUDIR/install.bat"
187
echo "ECHO # pkg config file - specifies locations where packages should be installed >> %DOSDIR%\\cfg\\pkg.cfg" >> "$DOSEMUDIR/install.bat"
188
echo "ECHO DIR PROGS C:\\ >> %DOSDIR%\\cfg\\pkg.cfg" >> "$DOSEMUDIR/install.bat"
189
echo "ECHO DIR GAMES C:\\ >> %DOSDIR%\\cfg\\pkg.cfg" >> "$DOSEMUDIR/install.bat"
190
echo "ECHO DIR DRIVERS C:\\DRIVERS\\ >> %DOSDIR%\\cfg\\pkg.cfg" >> "$DOSEMUDIR/install.bat"
191
echo "ECHO DIR DEVEL C:\\DEVEL\\ >> %DOSDIR%\\cfg\\pkg.cfg" >> "$DOSEMUDIR/install.bat"
192
for p in $COREPKGS ; do
193
  cp "$CDROOT/$p.zip" "$DOSEMUDIR/"
194
  echo "pkg install $p.zip" >> "$DOSEMUDIR/install.bat"
195
  echo "del $p.zip" >> "$DOSEMUDIR/install.bat"
196
done
197
echo "del pkg.exe" >> "$DOSEMUDIR/install.bat"
198
unzip -Cj packages/kernel.zip bin/kernel.sys -d "$DOSEMUDIR/"
199
unzip -Cj packages/command.zip bin/command.com -d "$DOSEMUDIR/"
200
unzip -Cj packages/pkg.zip bin/pkg.exe -d "$DOSEMUDIR/"
201
echo "FILES=50" >> "$DOSEMUDIR/config.sys"
202
echo "@ECHO OFF" >> "$DOSEMUDIR/autoexec.bat"
203
echo "SET DOSDIR=C:\\SVARDOS" >> "$DOSEMUDIR/autoexec.bat"
204
echo "PATH %DOSDIR%\\BIN" >> "$DOSEMUDIR/autoexec.bat"
205
echo "IF EXIST INSTALL.BAT GOTO SETUP" >> "$DOSEMUDIR/autoexec.bat"
206
echo "ECHO." >> "$DOSEMUDIR/autoexec.bat"
207
echo "ECHO Welcome to SvarDOS (powered by DOSEMU)! Type HELP if you are lost." >> "$DOSEMUDIR/autoexec.bat"
208
echo "ECHO." >> "$DOSEMUDIR/autoexec.bat"
209
echo "GOTO DONE" >> "$DOSEMUDIR/autoexec.bat"
210
echo "" >> "$DOSEMUDIR/autoexec.bat"
211
echo "REM *** this is a one-time setup script used only during first initialization ***" >> "$DOSEMUDIR/autoexec.bat"
212
echo ":SETUP" >> "$DOSEMUDIR/autoexec.bat"
213
echo "CALL INSTALL.BAT" >> "$DOSEMUDIR/autoexec.bat"
214
echo "DEL INSTALL.BAT" >> "$DOSEMUDIR/autoexec.bat"
215
echo "ECHO." >> "$DOSEMUDIR/autoexec.bat"
216
echo "ECHO -----------------------------------------------------" >> "$DOSEMUDIR/autoexec.bat"
217
echo "ECHO  SVARDOS SETUP COMPLETED. PLEASE RESTART DOSEMU NOW." >> "$DOSEMUDIR/autoexec.bat"
218
echo "PAUSE -----------------------------------------------------" >> "$DOSEMUDIR/autoexec.bat"
219
echo ":DONE" >> "$DOSEMUDIR/autoexec.bat"
220
rm -f "$PUBDIR/svardos-dosemu.zip"
221
zip -rm9jk "$PUBDIR/svardos-dosemu.zip" "$DOSEMUDIR"
222
rmdir "$DOSEMUDIR"
223
 
316 mateuszvis 224
# prepare the USB bootable image
225
USBIMG=$PUBDIR/svardos-usb.img
226
cp files/boot-svardos.img $USBIMG
227
mcopy -sQm -i "$USBIMG@@32256" "$FLOPROOT/"* ::/
228
for p in $ALLPKGS ; do
229
  mcopy -mi "$USBIMG@@32256" "$CDROOT/$p.zip" ::/
230
done
231
 
232
# compress the USB image
321 mateuszvis 233
rm -f "$PUBDIR/svardos-usb.zip"
316 mateuszvis 234
zip -mj9 "$PUBDIR/svardos-usb.zip" "$USBIMG"
235
 
236
# prepare the USB-ZIP bootable image
237
#USBZIPIMG=$PUBDIR/svardos-usbzip.img
238
#cat files/usb-zip.mbr "$PUBDIR/svardos-zip100.img" > $USBZIPIMG
239
 
204 mateuszvis 240
CDISO="$PUBDIR/svardos-cd.iso"
241
CDZIP="$PUBDIR/svardos-cd.zip"
194 mateuszvis 242
 
204 mateuszvis 243
# delete previous (if any) iso
148 mv_fox 244
echo "cleaning up old versions..."
204 mateuszvis 245
rm -f "$CDISO" "$CDZIP"
25 mv_fox 246
 
279 mateuszvis 247
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT/boot.img"
2 mv_fox 248
 
204 mateuszvis 249
# compress the ISO
250
zip -mj9 "$CDZIP" "$CDISO"
251
 
192 mateuszvis 252
# cleanup temporary things
194 mateuszvis 253
if [ "x$1" != "xnoclean" ] ; then
254
  rm -rf "$CDROOT" "$FLOPROOT"
255
fi
189 mateuszvis 256
 
11 mv_fox 257
cd "$origdir"
258
 
180 mateuszvis 259
#cd svnlschk
260
#./webgen.sh
261
#cd ..
165 mv_fox 262
 
180 mateuszvis 263
echo "ALL DONE!"
16 mv_fox 264
 
2 mv_fox 265
exit 0