Subversion Repositories SvarDOS

Rev

Rev 307 | Rev 321 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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