/
makeInstallImage.sh.in
332 lines (256 loc) · 9.66 KB
/
makeInstallImage.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#!/bin/sh
#
# The contents of this file are subject to the Initial
# Developer's Public License Version 1.0 (the "License");
# you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
# http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
#
# Software distributed under the License is distributed AS IS,
# WITHOUT WARRANTY OF ANY KIND, either express or implied.
# See the License for the specific language governing rights
# and limitations under the License.
#
# The Original Code was created by Mark O'Donohue
# for the Firebird Open Source RDBMS project.
#
# Copyright (c) Mark O'Donohue <mark.odonohue@ludwig.edu.au>
# and all contributors signed below.
#
# All Rights Reserved.
# Contributor(s): ______________________________________.
# Alex Peshkoff
#
fb_install_prefix=@prefix@
# Script to copy install files from the build/transport area
# This script builds an image of the installed system into
# the gen/buildroot directory.
# Making an assumption that this program is being run in the gen directory
BuildRootDir=..
BuiltFBDir=Release/firebird # Where the just build fb exists.
TargetDir=buildroot # Where we want to build the install image
SecurityDatabase=security5.fdb
TomMathBuild="@TOMMATH_BUILD@"
TomCryptBuild="@TOMCRYPT_BUILD@"
#------------------------------------------------------------------------
# addLibs
# Add required libraries in the beginning of script.
# Place it to target directory.
addLibs() {
libSdir=$1
libScript=$2
libTdir=$3
libTarget=$libTdir/$libScript
rm -f $libTarget
touch $libTarget
echo "#!/bin/sh" >>$libTarget
echo >>$libTarget
LIB=`objdump -p $libSdir/firebird|grep NEEDED|grep tomcrypt|awk '{print $2;}'`
[ "$LIB" ] && echo "export LIBTOMCRYPT=$LIB" >>$libTarget
LIB=`objdump -p $libSdir/isql|grep NEEDED|egrep "(curses|termcap|tinfo)"|awk '{print $2;}'`
[ "$LIB" ] && echo "export LIBCURSES=$LIB" >>$libTarget
echo >>$libTarget
for i in posixLibrary.sh linuxLibrary.sh
do
echo "# $i" >>$libTarget
cat $libSdir/$i >>$libTarget
echo "" >>$libTarget # avoid missing linefeed
done
cat $libSdir/$libScript >>$libTarget
}
#------------------------------------------------------------------------
# copyIfExists
# Copy file if it exists
#
copyIfExists() {
Files=""
while [ ${#} -gt 1 ]; do
Files="$Files ${1}"
shift
done
NewDir=${1}
for OldFile in $Files; do
if [ -f $OldFile ]; then
cp -df $OldFile $NewDir
fi
done
}
#------------------------------------------------------------------------
# linkFiles
# This function creates soft links
linkFiles() {
From=$1
Files=$2
To=$3
Check=$4
if [ "$To" = "$Check" ]; then
return 0
fi
for file in $Files; do
ln -s $From/$file $To/$file
done
}
#------------------------------------------------------------------------
# makeDirs
# Make paths, passed as a list in 1st arg
makeDirs() {
Dirs=$1
for d in $Dirs; do
Dir=${TargetDir}${d}
mkdir -p $Dir
chmod 0755 $Dir
done
}
#------------------------------------------------------------------------
# ReadOnlyTree
# Set correct rights to files in given subtree
ReadOnlyTree() {
Tree=$1
for i in `find ${Tree} -type d -print`
do
chmod 0755 $i
done
for i in `find ${Tree} -type f -print`
do
chmod 0644 $i
done
}
#------------------------------------------------------------------------
# copyFiles
# This function copies all the files for a distribution into a
# directory heirachy mirroring the installation.
copyFiles() {
# The guts of the tranfer of files and other directories
#cleanup
if [ -d $TargetDir ]
then
chmod -R +xw $TargetDir
rm -fr $TargetDir
fi
#directories
makeDirs "@FB_BINDIR@ @FB_SBINDIR@ @FB_CONFDIR@ @FB_LIBDIR@ @FB_INCDIR@/firebird @FB_DOCDIR@/sql.extensions \
@FB_SAMPLEDIR@ @FB_SAMPLEDBDIR@ @FB_HELPDIR@ @FB_INTLDIR@ @FB_MISCDIR@ @FB_SECDBDIR@ @FB_MSGDIR@ @FB_LOGDIR@ \
@FB_GUARDDIR@ @FB_PLUGDIR@ @FB_TZDATADIR@"
for i in udf; do
makeDirs @FB_MISCDIR@/upgrade/$i
done
makeDirs /usr/include
#bin
cp $BuiltFBDir/bin/gbak ${TargetDir}@FB_BINDIR@/gbak
cp $BuiltFBDir/bin/gfix ${TargetDir}@FB_BINDIR@/gfix
cp $BuiltFBDir/bin/gpre ${TargetDir}@FB_BINDIR@/gpre
cp $BuiltFBDir/bin/gsec ${TargetDir}@FB_BINDIR@/gsec
cp $BuiltFBDir/bin/nbackup ${TargetDir}@FB_BINDIR@/nbackup
copyIfExists $BuiltFBDir/bin/gsplit ${TargetDir}@FB_BINDIR@
cp $BuiltFBDir/bin/gstat ${TargetDir}@FB_BINDIR@/gstat
copyIfExists $BuiltFBDir/bin/fbsvcmgr ${TargetDir}@FB_BINDIR@
copyIfExists $BuiltFBDir/bin/fbtracemgr ${TargetDir}@FB_BINDIR@
cp $BuiltFBDir/bin/isql ${TargetDir}@FB_BINDIR@/isql
cp $BuiltFBDir/bin/qli ${TargetDir}@FB_BINDIR@/qli
chmod 0755 ${TargetDir}@FB_BINDIR@/*
#sbin
cp -f $BuiltFBDir/bin/firebird ${TargetDir}@FB_SBINDIR@/firebird
cp -f $BuiltFBDir/bin/fbguard ${TargetDir}@FB_SBINDIR@
copyIfExists $BuiltFBDir/bin/fb_lock_print ${TargetDir}@FB_SBINDIR@
addLibs $BuiltFBDir/bin changeServerMode.sh ${TargetDir}@FB_SBINDIR@
cp $BuiltFBDir/bin/registerDatabase.sh ${TargetDir}@FB_SBINDIR@
cp $BuiltFBDir/bin/fb_config ${TargetDir}@FB_SBINDIR@
addLibs $BuiltFBDir/bin FirebirdUninstall.sh ${TargetDir}@FB_SBINDIR@
chmod 0755 ${TargetDir}@FB_SBINDIR@/*
chmod 0700 ${TargetDir}@FB_SBINDIR@/*.sh
#install script
addLibs $BuiltFBDir/bin install.sh $BuildRootDir/gen/install
#examples - copy only if we have them
exampleFiles=`find $BuiltFBDir/examples/README -type f -print`
if [ -z "$exampleFiles" ]; then
echo "Example files have not been built!"
else
(cd $BuiltFBDir/examples; tar cf - .) | (cd ${TargetDir}@FB_SAMPLEDIR@; tar xf -)
rm -rf ${TargetDir}@FB_SAMPLEDIR@/empbuild
makeDirs @FB_SAMPLEDBDIR@
cp $BuiltFBDir/examples/empbuild/*.fdb ${TargetDir}@FB_SAMPLEDBDIR@
ReadOnlyTree ${TargetDir}@FB_SAMPLEDIR@
chmod 0664 ${TargetDir}@FB_SAMPLEDBDIR@/*.fdb
#plugins samples
makeDirs ${TargetDir}@FB_SAMPLEDIR@/prebuilt
cp $BuiltFBDir/plugins/*fbSample* ${TargetDir}@FB_SAMPLEDIR@/prebuilt/plugins
cp $BuiltFBDir/bin/*fbSample* ${TargetDir}@FB_SAMPLEDIR@/prebuilt/bin
chmod 0644 ${TargetDir}@FB_SAMPLEDIR@/prebuilt/plugins/*
# exec bit for sample binaries
chmod 0755 ${TargetDir}@FB_SAMPLEDIR@/prebuilt/bin/*
fi
#QLI help
copyIfExists $BuiltFBDir/help/help.gbak ${TargetDir}@FB_HELPDIR@
cp $BuiltFBDir/help/help.fdb ${TargetDir}@FB_HELPDIR@
chmod 0444 ${TargetDir}@FB_HELPDIR@/*.fdb
#message file
cp $BuiltFBDir/*.msg ${TargetDir}@FB_MSGDIR@
chmod 0444 ${TargetDir}@FB_MSGDIR@/*.msg
#secureDB (access rights will be set at install time)
cp $BuiltFBDir/$SecurityDatabase ${TargetDir}@FB_SECDBDIR@
#include (.h .pas files)
cp $BuiltFBDir/include/*.h ${TargetDir}@FB_INCDIR@
cp $BuildRootDir/src/include/firebird/*.h ${TargetDir}@FB_INCDIR@/firebird
tar -C $BuildRootDir/src/include/firebird -cf - impl | tar -C ${TargetDir}@FB_INCDIR@/firebird -x
cp $BuildRootDir/src/include/gen/Firebird.pas ${TargetDir}@FB_INCDIR@/firebird
ReadOnlyTree ${TargetDir}@FB_INCDIR@
#lib
cp -df $BuiltFBDir/lib/libfbclient.so* ${TargetDir}@FB_LIBDIR@
cp -f $BuiltFBDir/lib/libib_util.so ${TargetDir}@FB_LIBDIR@/libib_util.so
if [ "$TomMathBuild" = "Y" ]; then
makeDirs @FB_LIBDIR@/.tm
cp -df $BuildRootDir/extern/libtommath/.libs/libtommath.so* ${TargetDir}@FB_LIBDIR@/.tm
fi
if [ "$TomCryptBuild" = "Y" ]; then
cp -df $BuildRootDir/extern/libtomcrypt/.libs/libtomcrypt.so* ${TargetDir}@FB_LIBDIR@
fi
chmod 0755 ${TargetDir}@FB_LIBDIR@/*.so*
#plugins
(cd $BuiltFBDir/plugins;tar cf - --exclude='*fbSample*' .) | (cd ${TargetDir}@FB_PLUGDIR@; tar xvf -)
for file in `find ${TargetDir}@FB_PLUGDIR@ -name '*.so*' -print`; do
chmod 0755 ${file}
done
makeDirs ${TargetDir}@FB_TZDATADIR@
cp $BuiltFBDir/tzdata/*.res ${TargetDir}@FB_TZDATADIR@
chmod 0444 ${TargetDir}@FB_TZDATADIR@/*.res
#intl
cp $BuiltFBDir/intl/libfbintl.so ${TargetDir}@FB_INTLDIR@/fbintl
cp $BuiltFBDir/intl/fbintl.conf ${TargetDir}@FB_INTLDIR@
chmod 0755 ${TargetDir}@FB_INTLDIR@/fbintl
chmod 0644 ${TargetDir}@FB_INTLDIR@/fbintl.conf
# Note that the following items copy files from outside the build tree.
# Copy the sql-declarations into the UDF-directory
#doc
cp $BuildRootDir/doc/*.pdf ${TargetDir}@FB_DOCDIR@
cp $BuildRootDir/doc/README.* ${TargetDir}@FB_DOCDIR@
cp $BuildRootDir/doc/sql.extensions/README* ${TargetDir}@FB_DOCDIR@/sql.extensions
cp $BuildRootDir/*.md ${TargetDir}@FB_CONFDIR@
for i in `find ${TargetDir}@FB_MISCDIR@ -print`; do
if [ -d $i ]; then
chmod 0755 $i
else
chmod 0644 $i
fi
done
#misc
cp $BuildRootDir/src/misc/intl.sql ${TargetDir}@FB_MISCDIR@
cp $BuildRootDir/src/misc/upgrade/v4.0/udf_replace* ${TargetDir}@FB_MISCDIR@/upgrade/udf
cp $BuildRootDir/gen/install/misc/firebird.init.d.* ${TargetDir}@FB_MISCDIR@
cp $BuildRootDir/gen/install/misc/rc.config.firebird ${TargetDir}@FB_MISCDIR@
cp $BuildRootDir/gen/install/misc/firebird.service ${TargetDir}@FB_MISCDIR@
chmod -R go-rwx ${TargetDir}@FB_MISCDIR@
#conf
cp $BuiltFBDir/firebird.conf ${TargetDir}@FB_CONFDIR@
cp $BuiltFBDir/databases.conf ${TargetDir}@FB_CONFDIR@
cp $BuiltFBDir/fbtrace.conf ${TargetDir}@FB_CONFDIR@
cp $BuiltFBDir/plugins.conf ${TargetDir}@FB_CONFDIR@
cp $BuiltFBDir/replication.conf ${TargetDir}@FB_CONFDIR@
chmod 0644 ${TargetDir}@FB_CONFDIR@/*.conf
#license
cp $BuildRootDir/builds/install/misc/*License.txt ${TargetDir}@FB_CONFDIR@
chmod 0444 ${TargetDir}@FB_CONFDIR@/*License.txt
# link include files to /usr/include
linkFiles "@FB_INCDIR@" "firebird iberror.h ibase.h ib_util.h" "${TargetDir}/usr/include" "${TargetDir}@FB_INCDIR@"
}
#=== MAIN ====================================================================
copyFiles