Subversion Repositories SvarDOS

Rev

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

Rev 205 Rev 246
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
55
COREPKGS="attrib chkdsk choice command cpidos ctmouse deltree devload diskcopy display dosfsck edit fc fdapm fdisk fdnpkg format himemx kernel keyb keyb_lay label mem mode more move shsucdx sort tree undelete xcopy udvd2"
55
COREPKGS="attrib chkdsk choice command cpidos ctmouse deltree devload diskcopy display dosfsck edit fc fdapm fdisk fdnpkg format himemx kernel keyb keyb_lay label mem mode more move shsucdx sort tree undelete xcopy udvd2"
56
 
56
 
57
 
57
 
58
 
58
 
59
# function that builds the packages repository
59
# function that builds the packages repository
60
function dorepo {
60
function dorepo {
61
  # copy all zip files to the web repo
61
  # copy all zip files to the web repo
62
  cp "$PKGDIR"/* $REPOROOT/
62
  cp "$PKGDIR"/* $REPOROOT/
63
  # now strip the sources from repo versions
63
  # now strip the sources from repo versions
64
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "SOURCE/*" ';'
64
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "SOURCE/*" ';'
65
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "source/*" ';'
65
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "source/*" ';'
66
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "Source/*" ';'
66
  find "$REPOROOT/" -iname '*.zip' -exec zip "{}" -d "Source/*" ';'
67
 
67
 
68
  # build repo idx
68
  # build repo idx
69
  $BUILDIDX "$REPOROOT/"
69
  $BUILDIDX "$REPOROOT/"
70
}
70
}
71
 
71
 
72
 
72
 
73
# prepares image for floppy sets of size $1
73
# prepares image for floppy sets of:
-
 
74
# $1 cylinders
-
 
75
# $2 heads (sides)
-
 
76
# $3 sectors per track
-
 
77
# $4 size
74
function prep_flop {
78
function prep_flop {
75
  mkdir $1
79
  mkdir $4
76
  mformat -C -f $1 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$1/disk1.img"
80
  mformat -C -t $1 -h $2 -s $3 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$4/disk1.img"
77
  mcopy -sQm -i "$1/disk1.img" "$FLOPROOT/"* ::/
81
  mcopy -sQm -i "$4/disk1.img" "$FLOPROOT/"* ::/
78
 
82
 
79
  # now populate the floppies
83
  # now populate the floppies
80
  curdisk=1
84
  curdisk=1
81
  for p in $COREPKGS ; do
85
  for p in $COREPKGS ; do
82
    # if copy fails, then probably the floppy is full - try again after
86
    # if copy fails, then probably the floppy is full - try again after
83
    # creating an additional floppy image
87
    # creating an additional floppy image
84
    if ! mcopy -mi "$1/disk$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
88
    if ! mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
85
      curdisk=$((curdisk+1))
89
      curdisk=$((curdisk+1))
86
      mformat -C -f $1 -v SVARDOS -i "$1/disk$curdisk.img"
90
      mformat -C -t $1 -h $2 -s $3 -v SVARDOS -i "$4/disk$curdisk.img"
87
      mcopy -mi "$1/disk$curdisk.img" "$CDROOT/$p.zip" ::/
91
      mcopy -mi "$4/disk$curdisk.img" "$CDROOT/$p.zip" ::/
88
    fi
92
    fi
89
  done
93
  done
90
 
94
 
91
  # add a short readme
95
  # add a short readme
92
  echo "This directory contains a set of $curdisk floppy images of the SvarDOS distribution in the $1 KB floppy format." > "$1/readme.txt"
96
  echo "This directory contains a set of $curdisk floppy images of the SvarDOS distribution in the $4 KB floppy format." > "$4/readme.txt"
93
  echo "" >> "$1/readme.txt"
97
  echo "" >> "$4/readme.txt"
94
  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." >> "$1/readme.txt"
98
  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"
95
  echo "" >> "$1/readme.txt"
99
  echo "" >> "$4/readme.txt"
96
  echo "Latest SvarDOS version is available on the project's homepage: http://svardos.osdn.io" >> "$1/readme.txt"
100
  echo "Latest SvarDOS version is available on the project's homepage: http://svardos.osdn.io" >> "$4/readme.txt"
97
 
101
 
98
  unix2dos "$1/readme.txt"
102
  unix2dos "$4/readme.txt"
99
 
103
 
100
  # zip the images (and remove them at the same time)
104
  # zip the images (and remove them at the same time)
101
  rm -f "$PUBDIR/svardos-floppy-$1k.zip"
105
  rm -f "$PUBDIR/svardos-floppy-$4k.zip"
102
  zip -9 -rmj "$PUBDIR/svardos-floppy-$1k.zip" $1/*
106
  zip -9 -rmj "$PUBDIR/svardos-floppy-$4k.zip" $4/*
103
 
107
 
104
  # clean up
108
  # clean up
105
  rmdir $1
109
  rmdir $4
106
}
110
}
107
 
111
 
108
 
112
 
109
### actual code flow starts here ############################################
113
### actual code flow starts here ############################################
110
 
114
 
111
# check presence of the buildidx tool
115
# check presence of the buildidx tool
112
if [ ! -f "$BUILDIDX" ] ; then
116
if [ ! -f "$BUILDIDX" ] ; then
113
  echo "buildidx not found at $BUILDIDX"
117
  echo "buildidx not found at $BUILDIDX"
114
  exit 1
118
  exit 1
115
fi
119
fi
116
 
120
 
117
# remember where I am, so I can get back here once all is done
121
# remember where I am, so I can get back here once all is done
118
origdir=`pwd`
122
origdir=`pwd`
119
 
123
 
120
mkdir "$CDROOT"
124
mkdir "$CDROOT"
121
mkdir "$FLOPROOT"
125
mkdir "$FLOPROOT"
122
 
126
 
123
# build the repo (also builds the listing.txt file)
127
# build the repo (also builds the listing.txt file)
124
dorepo
128
dorepo
125
 
129
 
126
# add CORE packages to CDROOT + create the list of packages on floppy
130
# add CORE packages to CDROOT + create the list of packages on floppy
127
for pkg in $COREPKGS ; do
131
for pkg in $COREPKGS ; do
128
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
132
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
129
  echo "$pkg" >> "$FLOPROOT/install.lst"
133
  echo "$pkg" >> "$FLOPROOT/install.lst"
130
done
134
done
131
 
135
 
132
# prepare the content of the boot (install) floppy
136
# prepare the content of the boot (install) floppy
133
cp "install/install.com" "$FLOPROOT/"
137
cp "install/install.com" "$FLOPROOT/"
134
cp "install/nls/"install.?? "$FLOPROOT/"
138
cp "install/nls/"install.?? "$FLOPROOT/"
135
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
139
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
136
 
140
 
137
# build the boot (CD) floppy image
141
# build the boot (CD) floppy image
138
export MTOOLS_NO_VFAT=1
142
export MTOOLS_NO_VFAT=1
139
mformat -C -f 1440 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
143
mformat -C -f 1440 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
140
mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
144
mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
141
 
145
 
142
# prepare images for floppies in different sizes and numbers
146
# prepare images for floppies in different sizes (args are C H S SIZE)
143
prep_flop 2880
147
prep_flop 80 2 36 2880
144
prep_flop 1440
148
prep_flop 80 2 18 1440
145
prep_flop 1200
149
prep_flop 80 2 15 1200
146
prep_flop 720
150
prep_flop 80 2  9  720
147
 
151
 
148
CDISO="$PUBDIR/svardos-cd.iso"
152
CDISO="$PUBDIR/svardos-cd.iso"
149
CDZIP="$PUBDIR/svardos-cd.zip"
153
CDZIP="$PUBDIR/svardos-cd.zip"
150
 
154
 
151
# delete previous (if any) iso
155
# delete previous (if any) iso
152
echo "cleaning up old versions..."
156
echo "cleaning up old versions..."
153
rm -f "$CDISO" "$CDZIP"
157
rm -f "$CDISO" "$CDZIP"
154
 
158
 
155
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT"
159
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT"
156
 
160
 
157
# compress the ISO
161
# compress the ISO
158
zip -mj9 "$CDZIP" "$CDISO"
162
zip -mj9 "$CDZIP" "$CDISO"
159
 
163
 
160
# cleanup temporary things
164
# cleanup temporary things
161
if [ "x$1" != "xnoclean" ] ; then
165
if [ "x$1" != "xnoclean" ] ; then
162
  rm -rf "$CDROOT" "$FLOPROOT"
166
  rm -rf "$CDROOT" "$FLOPROOT"
163
fi
167
fi
164
 
168
 
165
cd "$origdir"
169
cd "$origdir"
166
 
170
 
167
#cd svnlschk
171
#cd svnlschk
168
#./webgen.sh
172
#./webgen.sh
169
#cd ..
173
#cd ..
170
 
174
 
171
echo "ALL DONE!"
175
echo "ALL DONE!"
172
 
176
 
173
exit 0
177
exit 0
174
 
178