Subversion Repositories DevTools

Rev

Rev 4057 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4057 Rev 4069
Line -... Line 1...
-
 
1
################################################################################
-
 
2
#
1
#! /bin/bash
3
#   NOTE:
-
 
4
#   This script will be run under a simple 'sh'
-
 
5
#   Jats will run .sh files under .sh. This is script to JATS and not
-
 
6
#   a stand alone program.
-
 
7
#
-
 
8
#   NOTE: sh under RHEL4 is more forgiving than under UBUNTU and SOLARIS
-
 
9
#         Test on multiple platforms.
-
 
10
#
-
 
11
################################################################################
-
 
12
 
2
#
13
#
3
# Force failed command to exit this shell - all commands must report success
14
# Force failed command to exit this shell - all commands must report success
4
set -e
15
set -e
5
echo
16
echo
6
echo
17
echo
7
 
18
 
8
 
19
 
9
 
-
 
10
#------------------------------------------------------------------------------
20
#------------------------------------------------------------------------------
11
# Takes $1 and removes all relative paths (. and ..) from it.  The cleaned up
21
# Takes $1 and removes all relative paths (. and ..) from it.  The cleaned up
12
# directory is written to stdout.
22
# directory is written to stdout.
13
#------------------------------------------------------------------------------
23
#------------------------------------------------------------------------------
14
cleanup_dir ()
24
cleanup_dir ()
Line 17... Line 27...
17
    
27
    
18
    CLEANUP_DIR=""
28
    CLEANUP_DIR=""
19
    for PART in ${DIR_PARTS}; do
29
    for PART in ${DIR_PARTS}; do
20
        if [ "${PART}" != "." ]; then
30
        if [ "${PART}" != "." ]; then
21
        
31
        
22
            if [ "${PART}" == ".." ]; then
32
            if [ "${PART}" = ".." ]; then
23
                CLEANUP_DIR=`echo "${CLEANUP_DIR}" | sed "s|/[^/]*$||"`
33
                CLEANUP_DIR=`echo "${CLEANUP_DIR}" | sed "s|/[^/]*$||"`
24
            else
34
            else
25
                CLEANUP_DIR="${CLEANUP_DIR}/${PART}"
35
                CLEANUP_DIR="${CLEANUP_DIR}/${PART}"
26
            fi
36
            fi
27
        fi
37
        fi
Line 88... Line 98...
88
        -WorkDirSuffix)         WORK_DIR_SUFFIX=$val;;
98
        -WorkDirSuffix)         WORK_DIR_SUFFIX=$val;;
89
        *)                      echo "Unknown tag: $tag=$val"
99
        *)                      echo "Unknown tag: $tag=$val"
90
    esac
100
    esac
91
done
101
done
92
 
102
 
93
if [ "${DOWNLOAD_PKG}" == "-DownloadPkg" ]; then
103
if [ "${DOWNLOAD_PKG}" = "-DownloadPkg" ]; then
94
    DOWNLOAD_PKG_NAME=${BUILD_NAME}
104
    DOWNLOAD_PKG_NAME=${BUILD_NAME}
95
    DOWNLOAD_PKG_VER=`echo ${BUILD_VERSION} | sed "s|\.[0-9]\+\.cots||"`
105
    DOWNLOAD_PKG_VER=`echo ${BUILD_VERSION} | sed "s|\.[0-9]\+\.cots||"`
96
    DOWNLOAD_PKG=${DOWNLOAD_PKG_NAME}-${DOWNLOAD_PKG_VER}
106
    DOWNLOAD_PKG=${DOWNLOAD_PKG_NAME}-${DOWNLOAD_PKG_VER}
97
else
107
else
98
    DOWNLOAD_PKG_VER=`echo ${DOWNLOAD_PKG} | sed "s|.*-||"`    
108
    DOWNLOAD_PKG_VER=`echo ${DOWNLOAD_PKG} | sed "s|.*-||"`    
Line 101... Line 111...
101
 
111
 
102
 
112
 
103
#------------------------------------------------------------------------------
113
#------------------------------------------------------------------------------
104
# Dump JATS information for debugging purposes
114
# Dump JATS information for debugging purposes
105
#------------------------------------------------------------------------------
115
#------------------------------------------------------------------------------
106
echo "================================================================================"
116
echo "="
107
echo "   JATS SUPPLIED FIELDS"
117
echo "   JATS SUPPLIED FIELDS"
108
echo "================================================================================"
118
echo "="
109
echo " ShellBuild     = ${SHELL_BUILD}"
119
echo " ShellBuild     = ${SHELL_BUILD}"
110
echo " BuildName      = ${BUILD_NAME} ${BUILD_VERSION}"
120
echo " BuildName      = ${BUILD_NAME} ${BUILD_VERSION}"
111
echo " Platform       = ${PLATFORM}"
121
echo " Platform       = ${PLATFORM}"
112
echo " Type           = ${TYPE}"
122
echo " Type           = ${TYPE}"
113
echo " Arch           = ${ARCH}"
123
echo " Arch           = ${ARCH}"
Line 125... Line 135...
125
echo " PackageBinDir  = ${PKG_BIN_DIR}"
135
echo " PackageBinDir  = ${PKG_BIN_DIR}"
126
echo " PackageIncDir  = ${PKG_INC_DIR}"
136
echo " PackageIncDir  = ${PKG_INC_DIR}"
127
echo " PackageLibDir  = ${PKG_LIB_DIR}"
137
echo " PackageLibDir  = ${PKG_LIB_DIR}"
128
echo " PackagePkgDir  = ${PKG_PKG_DIR}"
138
echo " PackagePkgDir  = ${PKG_PKG_DIR}"
129
echo " CompilerDir    = ${COMPILER_DIR}"
139
echo " CompilerDir    = ${COMPILER_DIR}"
130
echo "================================================================================"
140
echo "="
131
echo
141
echo
132
echo
142
echo
133
 
143
 
134
 
144
 
135
#------------------------------------------------------------------------------
145
#------------------------------------------------------------------------------
Line 165... Line 175...
165
            exit 1
175
            exit 1
166
        fi
176
        fi
167
        ;;
177
        ;;
168
 
178
 
169
    *I386*)
179
    *I386*)
170
        if [ "${PLATFORM}" == "LINUX_I386" ]; then
180
        if [ "${PLATFORM}" = "LINUX_I386" ]; then
171
            COMPILE_HOST="i386-cross-linux-gnu"
181
            COMPILE_HOST="i386-cross-linux-gnu"
172
        else
182
        else
173
            COMPILE_HOST="i586-unknown-linux-gnu"
183
            COMPILE_HOST="i586-unknown-linux-gnu"
174
        fi
184
        fi
175
        LINUX_HOST_ARCH=x86
185
        LINUX_HOST_ARCH=x86
Line 180... Line 190...
180
        exit 1
190
        exit 1
181
        ;;
191
        ;;
182
esac
192
esac
183
 
193
 
184
# Setup the location of the cross compiler
194
# Setup the location of the cross compiler
185
if [ "${COMPILE_HOST}" == "i386-redhat-linux" ] || [ "${COMPILER_DIR}" == "gcc" ]; then
195
if [ "${COMPILE_HOST}" = "i386-redhat-linux" ] || [ "${COMPILER_DIR}" = "gcc" ]; then
186
    XGCC_BASE_DIR=
196
    XGCC_BASE_DIR=
187
else
197
else
188
    XGCC_BASE_DIR=`echo ${COMPILER_DIR} | sed 's|/[^/]*/[^/]*$||'`
198
    XGCC_BASE_DIR=`echo ${COMPILER_DIR} | sed 's|/[^/]*/[^/]*$||'`
189
    XGCC_BASE_DIR=`cleanup_dir ${XGCC_BASE_DIR}`
199
    XGCC_BASE_DIR=`cleanup_dir ${XGCC_BASE_DIR}`
190
fi
200
fi
Line 272... Line 282...
272
                    fi
282
                    fi
273
                fi
283
                fi
274
            fi
284
            fi
275
        fi    
285
        fi    
276
    done
286
    done
277
    if [ "${SHARE_BASE_DIR}" == "${DDIR_ELSEWHERE}" ]; then
287
    if [ "${SHARE_BASE_DIR}" = "${DDIR_ELSEWHERE}" ]; then
278
        REL_BASE_DIR=../$(echo ${SHELL_BUILD} | sed "s|/src/.*||")
288
        REL_BASE_DIR=../$(echo ${SHELL_BUILD} | sed "s|/src/.*||")
279
    fi
289
    fi
280
    if [ "${TAR_DECOMP_ARG}" == "" ]; then
290
    if [ "${TAR_DECOMP_ARG}" = "" ]; then
281
        echo "Could not find download file ${DOWNLOAD_PKG}.<tar.gz|tar.bz2|tgz|zip> in any of { ${DOWNLOAD_DIRS} }"
291
        echo "Could not find download file ${DOWNLOAD_PKG}.<tar.gz|tar.bz2|tgz|zip> in any of { ${DOWNLOAD_DIRS} }"
282
        exit 1
292
        exit 1
283
    fi
293
    fi
284
    UNTAR_DIR=${LCL_SRC_DIR}/${DOWNLOAD_PKG}
294
    UNTAR_DIR=${LCL_SRC_DIR}/${DOWNLOAD_PKG}
285
    WORK_DIR=${UNTAR_DIR}.${PLATFORM}${TYPE}
295
    WORK_DIR=${UNTAR_DIR}.${PLATFORM}${TYPE}
Line 339... Line 349...
339
        DJOIN=" "
349
        DJOIN=" "
340
    fi
350
    fi
341
done
351
done
342
 
352
 
343
# Dump configuration
353
# Dump configuration
344
echo "================================================================================"
354
echo "="
345
echo "   BUILD CONFIGURATION"
355
echo "   BUILD CONFIGURATION"
346
echo "================================================================================"
356
echo "="
347
echo " Compile Host   = ${COMPILE_HOST}"
357
echo " Compile Host   = ${COMPILE_HOST}"
348
echo " Compile Build  = ${COMPILE_BUILD}"
358
echo " Compile Build  = ${COMPILE_BUILD}"
349
echo " XGCC Base Dir  = ${XGCC_BASE_DIR}"
359
echo " XGCC Base Dir  = ${XGCC_BASE_DIR}"
350
echo " Base Dir       = ${BASE_DIR}"
360
echo " Base Dir       = ${BASE_DIR}"
351
 
361
 
Line 373... Line 383...
373
if [ ${DEBIAN_PACKAGE} ]; then
383
if [ ${DEBIAN_PACKAGE} ]; then
374
    echo " Debian Package = ${DEB_PKG_DIR}"
384
    echo " Debian Package = ${DEB_PKG_DIR}"
375
fi
385
fi
376
    
386
    
377
echo " Launch Script  = ${LAUNCH_SCRIPT}"
387
echo " Launch Script  = ${LAUNCH_SCRIPT}"
378
echo "================================================================================"
388
echo "="
379
echo
389
echo
380
echo
390
echo
381
 
391
 
382
# Prepare the environment
392
# Prepare the environment
383
echo " --> Preparing environment"
393
echo " --> Preparing environment"
Line 418... Line 428...
418
#
428
#
419
#   Do not prepend the compiler path if it is already present in PATH
429
#   Do not prepend the compiler path if it is already present in PATH
420
#   In particular do not prepend /usr/bin as this will prevent tools
430
#   In particular do not prepend /usr/bin as this will prevent tools
421
#   provided in packages (eg bison) from overriding local versions
431
#   provided in packages (eg bison) from overriding local versions
422
#
432
#
423
if [[ ":${PATH}:" != *:${XGCC_COMPILER_PATH}:* ]] ; then
433
if ! expr -- ":${PATH}:" : ".*:${XGCC_COMPILER_PATH}:" ; then
424
    export PATH="${XGCC_COMPILER_PATH}:${PATH}"
434
    export PATH="${XGCC_COMPILER_PATH}:${PATH}"
-
 
435
echo Prepending coompiler path
425
fi
436
fi
426
 
437
 
427
 
-
 
428
#
438
#
429
# Environment - CHOST is used by some packages (e.g., zlib) to set the 
439
# Environment - CHOST is used by some packages (e.g., zlib) to set the 
430
# host environment compiler.
440
# host environment compiler.
431
#
441
#
432
export CHOST=${COMPILE_HOST}
442
export CHOST=${COMPILE_HOST}
Line 490... Line 500...
490
        rm -fr ${WORK_DIR}
500
        rm -fr ${WORK_DIR}
491
    
501
    
492
        echo " --> Extracting ${DOWNLOAD_PKG}"
502
        echo " --> Extracting ${DOWNLOAD_PKG}"
493
        cd ${LCL_SRC_DIR}
503
        cd ${LCL_SRC_DIR}
494
        # For Zip file use unzip instead of tar
504
        # For Zip file use unzip instead of tar
495
        if [ "${TAR_DECOMP_ARG}" == "unzip" ]; then
505
        if [ "${TAR_DECOMP_ARG}" = "unzip" ]; then
496
            unzip ${TARBALL_FILE}
506
            unzip ${TARBALL_FILE}
497
        else
507
        else
498
            tar -x${TAR_DECOMP_ARG}pf ${TARBALL_FILE}
508
            tar -x${TAR_DECOMP_ARG}pf ${TARBALL_FILE}
499
        fi
509
        fi
500
        
510
        
Line 529... Line 539...
529
                echo "     Directories are copied"
539
                echo "     Directories are copied"
530
            else
540
            else
531
                echo "     Directories are symlinked"
541
                echo "     Directories are symlinked"
532
            fi                
542
            fi                
533
 
543
 
534
            function create_mods()
544
            create_mods() {
535
            {
-
 
536
                local SRC
545
                local SRC
537
                local REL
546
                local REL
538
                local DST
547
                local DST
539
                local NAME
548
                local NAME
540
                local MOD_DIR=$1
549
                local MOD_DIR=$1
Line 604... Line 613...
604
#   Source the users script
613
#   Source the users script
605
#   This is processed in the context of this script
614
#   This is processed in the context of this script
606
#
615
#
607
mkdir -p ${WORK_DIR}
616
mkdir -p ${WORK_DIR}
608
cd ${WORK_DIR}
617
cd ${WORK_DIR}
609
source ${LAUNCH_SCRIPT}
618
. ${LAUNCH_SCRIPT}
610
 
619
 
611
 
620
 
612
if [ ${DEBIAN_PACKAGE} ]; then 
621
if [ ${DEBIAN_PACKAGE} ]; then 
613
    echo " --> Creating Debian packaging scripts"
622
    echo " --> Creating Debian packaging scripts"
614
    unset TOOL_DIR
623
    unset TOOL_DIR
Line 643... Line 652...
643
    done
652
    done
644
fi
653
fi
645
 
654
 
646
echo " --> Cleaning up empty directories"
655
echo " --> Cleaning up empty directories"
647
# Deletes directory $1 if it does not contain any other files or directories
656
# Deletes directory $1 if it does not contain any other files or directories
648
function rmdir_empty()
657
rmdir_empty()
649
{
658
{
650
    if [ -d "$1" ] ; then
659
    if [ -d "$1" ] ; then
651
        # -A = do not list . and ..
660
        # -A = do not list . and ..
652
        # -Q = enclose entry names in double quotes
661
        # -Q = enclose entry names in double quotes
653
        # -l = list one file per line
662
        # -l = list one file per line
Line 656... Line 665...
656
        for DIR in ${DIRS}; do
665
        for DIR in ${DIRS}; do
657
            rmdir_empty $1/${DIR}
666
            rmdir_empty $1/${DIR}
658
        done
667
        done
659
    
668
    
660
        LS=`ls -A -Q -l -F "$1" | grep "\"" | sed "s|^.* \"||" | sed "s|\".*||"`
669
        LS=`ls -A -Q -l -F "$1" | grep "\"" | sed "s|^.* \"||" | sed "s|\".*||"`
661
        if [ "${LS}" == "" ]; then
670
        if [ "${LS}" = "" ]; then
662
            rmdir $1
671
            rmdir $1
663
        fi
672
        fi
664
    fi
673
    fi
665
}
674
}
666
 
675