Subversion Repositories SvarDOS

Rev

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

Rev 284 Rev 300
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
54
# list of packages to be part of CORE (always installed)
55
COREPKGS="amb attrib chkdsk choice command cpidos ctmouse 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 undelete xcopy udvd2"
55
COREPKGS="amb attrib chkdsk choice command cpidos ctmouse 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)
-
 
58
EXTRAPKGS="pcntpk udvd2"
-
 
59
 
-
 
60
# all packages
-
 
61
ALLPKGS="$COREPKGS $EXTRAPKGS"
57
 
62
 
58
 
63
 
59
# function that builds the packages repository
64
# function that builds the packages repository
60
function dorepo {
65
function dorepo {
61
  # copy all zip files to the web repo
66
  # copy all zip files to the web repo
62
  cp "$PKGDIR"/* $REPOROOT/
67
  cp "$PKGDIR"/* $REPOROOT/
63
  # now strip the sources from repo versions
68
  # now strip the sources from repo versions
64
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "SOURCE/*" ';'
69
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "SOURCE/*" ';'
65
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "source/*" ';'
70
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "source/*" ';'
66
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "Source/*" ';'
71
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "Source/*" ';'
67
 
72
 
68
  # build repo idx
73
  # build repo idx
69
  $BUILDIDX "$REPOROOT/"
74
  $BUILDIDX "$REPOROOT/"
70
}
75
}
71
 
76
 
72
 
77
 
73
# prepares image for floppy sets of:
78
# prepares image for floppy sets of:
74
# $1 cylinders
79
# $1 cylinders
75
# $2 heads (sides)
80
# $2 heads (sides)
76
# $3 sectors per track
81
# $3 sectors per track
77
# $4 size
82
# $4 size
78
# $5 where to put a copy of the image (optional)
83
# $5 where to put a copy of the image (optional)
79
function prep_flop {
84
function prep_flop {
80
  mkdir $4
85
  mkdir $4
81
  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"
82
  mcopy -sQm -i "$4/disk1.img" "$FLOPROOT/"* ::/
87
  mcopy -sQm -i "$4/disk1.img" "$FLOPROOT/"* ::/
83
 
88
 
84
  # now populate the floppies
89
  # now populate the floppies
85
  curdisk=1
90
  curdisk=1
86
  for p in $COREPKGS ; do
91
  for p in $ALLPKGS ; do
87
    # 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
88
    # creating an additional floppy image
93
    # creating an additional floppy image
89
    if ! mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
94
    if ! mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
90
      curdisk=$((curdisk+1))
95
      curdisk=$((curdisk+1))
91
      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"
92
      mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/
97
      mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/
93
    fi
98
    fi
94
  done
99
  done
95
 
100
 
96
  # add a short readme
101
  # add a short readme
97
  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"
98
  echo "" >> "$4/readme.txt"
103
  echo "" >> "$4/readme.txt"
99
  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"
100
  echo "" >> "$4/readme.txt"
105
  echo "" >> "$4/readme.txt"
101
  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"
102
 
107
 
103
  unix2dos "$4/readme.txt"
108
  unix2dos "$4/readme.txt"
104
 
109
 
105
  # make a copy of the image, if requested
110
  # make a copy of the image, if requested
106
  if [ "x$5" != "x" ] ; then
111
  if [ "x$5" != "x" ] ; then
107
    cp "$4/disk1.img" $5
112
    cp "$4/disk1.img" $5
108
  fi
113
  fi
109
 
114
 
110
  # zip the images (and remove them at the same time)
115
  # zip the images (and remove them at the same time)
111
  rm -f "$PUBDIR/svardos-floppy-$4k.zip"
116
  rm -f "$PUBDIR/svardos-floppy-$4k.zip"
112
  zip -9 -rmj "$PUBDIR/svardos-floppy-$4k.zip" $4/*
117
  zip -9 -rmj "$PUBDIR/svardos-floppy-$4k.zip" $4/*
113
 
118
 
114
  # clean up
119
  # clean up
115
  rmdir $4
120
  rmdir $4
116
}
121
}
117
 
122
 
118
 
123
 
119
### actual code flow starts here ############################################
124
### actual code flow starts here ############################################
120
 
125
 
121
# check presence of the buildidx tool
126
# check presence of the buildidx tool
122
if [ ! -f "$BUILDIDX" ] ; then
127
if [ ! -f "$BUILDIDX" ] ; then
123
  echo "buildidx not found at $BUILDIDX"
128
  echo "buildidx not found at $BUILDIDX"
124
  exit 1
129
  exit 1
125
fi
130
fi
126
 
131
 
127
# 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
128
origdir=`pwd`
133
origdir=`pwd`
129
 
134
 
130
mkdir "$CDROOT"
135
mkdir "$CDROOT"
131
mkdir "$FLOPROOT"
136
mkdir "$FLOPROOT"
132
 
137
 
133
# build the repo (also builds the listing.txt file)
138
# build the repo (also builds the listing.txt file)
134
dorepo
139
dorepo
135
 
140
 
136
# 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
137
for pkg in $COREPKGS ; do
142
for pkg in $COREPKGS ; do
138
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
143
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
139
  echo "$pkg" >> "$FLOPROOT/install.lst"
144
  echo "$pkg" >> "$FLOPROOT/install.lst"
140
done
145
done
141
 
146
 
-
 
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
 
142
# prepare the content of the boot (install) floppy
153
# prepare the content of the boot (install) floppy
143
cp "install/install.com" "$FLOPROOT/"
154
cp "install/install.com" "$FLOPROOT/"
144
cp "install/nls/"install.?? "$FLOPROOT/"
155
cp "install/nls/"install.?? "$FLOPROOT/"
145
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
156
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
146
unzip -j packages/pkg.zip bin/pkg.exe -d "$FLOPROOT/"
157
unzip -j packages/pkg.zip bin/pkg.exe -d "$FLOPROOT/"
147
 
158
 
148
# build the boot (CD) floppy image
159
# build the boot (CD) floppy image
149
export MTOOLS_NO_VFAT=1
160
export MTOOLS_NO_VFAT=1
150
#mformat -C -f 2880 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
161
#mformat -C -f 2880 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
151
#mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
162
#mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
152
 
163
 
153
# prepare images for floppies in different sizes (args are C H S SIZE)
164
# prepare images for floppies in different sizes (args are C H S SIZE)
154
prep_flop 80 2 36 2880 "$CDROOT/boot.img"
165
prep_flop 80 2 36 2880 "$CDROOT/boot.img"
155
prep_flop 80 2 18 1440
166
prep_flop 80 2 18 1440
156
prep_flop 80 2 15 1200
167
prep_flop 80 2 15 1200
157
prep_flop 80 2  9  720
168
prep_flop 80 2  9  720
158
 
169
 
159
CDISO="$PUBDIR/svardos-cd.iso"
170
CDISO="$PUBDIR/svardos-cd.iso"
160
CDZIP="$PUBDIR/svardos-cd.zip"
171
CDZIP="$PUBDIR/svardos-cd.zip"
161
 
172
 
162
# delete previous (if any) iso
173
# delete previous (if any) iso
163
echo "cleaning up old versions..."
174
echo "cleaning up old versions..."
164
rm -f "$CDISO" "$CDZIP"
175
rm -f "$CDISO" "$CDZIP"
165
 
176
 
166
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT/boot.img"
177
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT/boot.img"
167
 
178
 
168
# compress the ISO
179
# compress the ISO
169
zip -mj9 "$CDZIP" "$CDISO"
180
zip -mj9 "$CDZIP" "$CDISO"
170
 
181
 
171
# cleanup temporary things
182
# cleanup temporary things
172
if [ "x$1" != "xnoclean" ] ; then
183
if [ "x$1" != "xnoclean" ] ; then
173
  rm -rf "$CDROOT" "$FLOPROOT"
184
  rm -rf "$CDROOT" "$FLOPROOT"
174
fi
185
fi
175
 
186
 
176
cd "$origdir"
187
cd "$origdir"
177
 
188
 
178
#cd svnlschk
189
#cd svnlschk
179
#./webgen.sh
190
#./webgen.sh
180
#cd ..
191
#cd ..
181
 
192
 
182
echo "ALL DONE!"
193
echo "ALL DONE!"
183
 
194
 
184
exit 0
195
exit 0
185
 
196