Subversion Repositories SvarDOS

Rev

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

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