Subversion Repositories SvarDOS

Rev

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

Rev 198 Rev 204
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 size $1
74
function prep_flop {
74
function prep_flop {
75
  mkdir $1
75
  mkdir $1
76
  mformat -C -f $1 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$1/1.img"
76
  mformat -C -f $1 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$1/1.img"
77
  mcopy -sQm -i "$1/1.img" "$FLOPROOT/"* ::/
77
  mcopy -sQm -i "$1/1.img" "$FLOPROOT/"* ::/
78
 
78
 
79
  # now populate the floppies
79
  # now populate the floppies
80
  curdisk=1
80
  curdisk=1
81
  for p in $COREPKGS ; do
81
  for p in $COREPKGS ; do
82
    # if copy fails, then probably the floppy is full - try again after
82
    # if copy fails, then probably the floppy is full - try again after
83
    # creating an additional floppy image
83
    # creating an additional floppy image
84
    if ! mcopy -mi "$1/$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
84
    if ! mcopy -mi "$1/$curdisk.img" "$CDROOT/$p.zip" ::/ ; then
85
      curdisk=$((curdisk+1))
85
      curdisk=$((curdisk+1))
86
      mformat -C -f $1 -v SVARDOS -i "$1/$curdisk.img"
86
      mformat -C -f $1 -v SVARDOS -i "$1/$curdisk.img"
87
      mcopy -mi "$1/$curdisk.img" "$CDROOT/$p.zip" ::/
87
      mcopy -mi "$1/$curdisk.img" "$CDROOT/$p.zip" ::/
88
    fi
88
    fi
89
  done
89
  done
90
 
90
 
91
  # zip the images (and remove them at the same time)
91
  # zip the images (and remove them at the same time)
92
  rm -f "$PUBDIR/svardos-floppy-$1k.zip"
92
  rm -f "$PUBDIR/svardos-floppy-$1k.zip"
93
  zip -9 -rmj "$PUBDIR/svardos-floppy-$1k.zip" $1/*
93
  zip -9 -rmj "$PUBDIR/svardos-floppy-$1k.zip" $1/*
94
 
94
 
95
  # clean up
95
  # clean up
96
  rmdir $1
96
  rmdir $1
97
}
97
}
98
 
98
 
99
 
99
 
100
### actual code flow starts here ############################################
100
### actual code flow starts here ############################################
101
 
101
 
102
# check presence of the buildidx tool
102
# check presence of the buildidx tool
103
if [ ! -f "$BUILDIDX" ] ; then
103
if [ ! -f "$BUILDIDX" ] ; then
104
  echo "buildidx not found at $BUILDIDX"
104
  echo "buildidx not found at $BUILDIDX"
105
  exit 1
105
  exit 1
106
fi
106
fi
107
 
107
 
108
# remember where I am, so I can get back here once all is done
108
# remember where I am, so I can get back here once all is done
109
origdir=`pwd`
109
origdir=`pwd`
110
 
110
 
111
mkdir "$CDROOT"
111
mkdir "$CDROOT"
112
mkdir "$FLOPROOT"
112
mkdir "$FLOPROOT"
113
 
113
 
114
# build the repo (also builds the listing.txt file)
114
# build the repo (also builds the listing.txt file)
115
dorepo
115
dorepo
116
 
116
 
117
# add CORE packages to CDROOT + create the list of packages on floppy
117
# add CORE packages to CDROOT + create the list of packages on floppy
118
for pkg in $COREPKGS ; do
118
for pkg in $COREPKGS ; do
119
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
119
  cp "$REPOROOT/$pkg.zip" "$CDROOT/"
120
  echo "$pkg" >> "$FLOPROOT/install.lst"
120
  echo "$pkg" >> "$FLOPROOT/install.lst"
121
done
121
done
122
 
122
 
123
# prepare the content of the boot (install) floppy
123
# prepare the content of the boot (install) floppy
124
cp "install/install.com" "$FLOPROOT/"
124
cp "install/install.com" "$FLOPROOT/"
125
cp "install/nls/"install.?? "$FLOPROOT/"
125
cp "install/nls/"install.?? "$FLOPROOT/"
126
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
126
cp -r "$CUSTFILES/floppy/"* "$FLOPROOT/"
127
 
127
 
128
# build the boot (CD) floppy image
128
# build the boot (CD) floppy image
129
export MTOOLS_NO_VFAT=1
129
export MTOOLS_NO_VFAT=1
130
mformat -C -f 1440 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
130
mformat -C -f 1440 -v SVARDOS -B "$CUSTFILES/floppy.mbr" -i "$CDROOT/boot.img"
131
mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
131
mcopy -sQm -i "$CDROOT/boot.img" "$FLOPROOT/"* ::/
132
 
132
 
133
# prepare images for floppies in different sizes and numbers
133
# prepare images for floppies in different sizes and numbers
134
prep_flop 2880
134
prep_flop 2880
135
prep_flop 1440
135
prep_flop 1440
136
prep_flop 1200
136
prep_flop 1200
137
prep_flop 720
137
prep_flop 720
138
 
138
 
-
 
139
CDISO="$PUBDIR/svardos-cd.iso"
-
 
140
CDZIP="$PUBDIR/svardos-cd.zip"
139
 
141
 
140
# delete previous (if any) *.iso and *.md5 files
142
# delete previous (if any) iso
141
echo "cleaning up old versions..."
143
echo "cleaning up old versions..."
142
rm -f "$PUBDIR/svardos.iso" "$PUBDIR/svardos.iso.md5"
-
 
143
 
-
 
144
CDISO="$PUBDIR/svardos.iso"
144
rm -f "$CDISO" "$CDZIP"
145
 
145
 
146
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT"
146
$GENISOIMAGE -input-charset cp437 -b boot.img -iso-level 1 -f -V SVARDOS -o "$CDISO" "$CDROOT"
147
 
147
 
-
 
148
# compress the ISO
-
 
149
zip -mj9 "$CDZIP" "$CDISO"
-
 
150
 
148
# cleanup temporary things
151
# cleanup temporary things
149
if [ "x$1" != "xnoclean" ] ; then
152
if [ "x$1" != "xnoclean" ] ; then
150
  rm -rf "$CDROOT" "$FLOPROOT"
153
  rm -rf "$CDROOT" "$FLOPROOT"
151
fi
154
fi
152
 
155
 
153
# compute the MD5 of the ISO file, taking care to include only the filename in it
-
 
154
echo "computing md5 sums..."
-
 
155
cd `dirname "$CDISO"`
-
 
156
md5sum `basename "$CDISO"` > "$CDISO.md5"
-
 
157
 
-
 
158
cd "$origdir"
156
cd "$origdir"
159
 
157
 
160
#cd svnlschk
158
#cd svnlschk
161
#./webgen.sh
159
#./webgen.sh
162
#cd ..
160
#cd ..
163
 
161
 
164
echo "ALL DONE!"
162
echo "ALL DONE!"
165
 
163
 
166
exit 0
164
exit 0
167
 
165