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