automation/product_builder/scripts/Utils.sh
author cawthron
Thu, 30 Jul 2009 13:29:28 -0500
branchRCL_2_1
changeset 383 c7f424dea615
permissions -rw-r--r--
add Symbian Foundation build scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
383
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     1
#!/bin/bash
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     2
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     3
# utilities used by build scripts
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     4
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     5
# To include these utilites, add these lines to another script in the same folder.
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     6
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     7
#   utilsDir=`dirname $0`
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     8
#   [ "$utilsDir" = "." ] && utilsDir=`pwd`
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
     9
#   source $utilsDir/Utils.sh
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    10
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    11
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    12
program=$0
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    13
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    14
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    15
# ------------------------------------------------------------------
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    16
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    17
# prepare to parse command line args
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    18
#   usage: prepare_parse_args arg1 [arg2] ...
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    19
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    20
# To parse command line args, add these lines after source $utilsDir/Utils.sh
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    21
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    22
#   argsText="--ARG1:<varlue> --ARG2:<value>"
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    23
#   prepare_parse_args ARG1 ARG2 > /tmp/$$.parse_args
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    24
#   source /tmp/$$.parse_args
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    25
#   rm -f /tmp/$$.parse_args
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    26
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    27
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    28
function prepare_parse_args {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    29
    local name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    30
    local sedcmd='`echo $i | sed 's/[-a-zA-Z0-9_]*://'`'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    31
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    32
    echo 'for i in $*'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    33
    echo 'do'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    34
    echo '  case $i in'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    35
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    36
    for name in $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    37
    do
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    38
        echo "    --$name:*)"
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    39
        echo "      $name=$sedcmd"
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    40
        echo "      echo $name=\$$name"
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    41
		echo '    ;;'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    42
    done
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    43
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    44
    echo '    --help)'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    45
    echo '      usage $argsText'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    46
    echo '    ;;'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    47
    echo '    --verbose)'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    48
    echo '      verbose=YES'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    49
    echo '    ;;'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    50
    echo '    *)'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    51
    echo '    ;;'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    52
  	echo 'esac'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    53
    echo 'done'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    54
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    55
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    56
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    57
this_step=0
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    58
total_errors=0
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    59
return_code=0
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    60
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    61
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    62
# count and print number of errors
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    63
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    64
function set_returncode {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    65
    this_step=$(($this_step+1))
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    66
    if [ $1 -ne 0 ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    67
        total_errors=$(($total_errors+1))
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    68
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    69
    return_code=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    70
    echo time = `date +%R`, step = $this_step, return code = $1, total errors = $total_errors
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    71
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    72
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    73
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    74
# print error message and exit
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    75
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    76
function error_exit {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    77
    echo $program ERROR: $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    78
    echo BUILD FAILED
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    79
    set_returncode 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    80
    exit $total_errors
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    81
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    82
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    83
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    84
# print a command line
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    85
# run the command line
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    86
# remember the exit status
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    87
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    88
function run {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    89
    echo $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    90
    $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    91
    set_returncode $?
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    92
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    93
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    94
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    95
# run and exit if non-zero return code
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    96
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    97
function must_run {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    98
    echo $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
    99
    $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   100
    return_code=$?
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   101
    set_returncode $return_code
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   102
    if [ $return_code -ne 0 ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   103
        exit $total_errors
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   104
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   105
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   106
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   107
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   108
# run the command line
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   109
# remember the exit status
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   110
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   111
function run_quiet {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   112
    $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   113
    set_returncode $?
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   114
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   115
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   116
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   117
# show a usage message and exit
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   118
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   119
function usage {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   120
    echo usage: $program $* --help --verbose
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   121
    set_returncode 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   122
    exit $total_errors
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   123
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   124
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   125
# ------------------------------------------------------------------
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   126
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   127
# move or copy plugins from one layout to another
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   128
# usage: move_or_copy_plugins <move_plugins | copy_plugins> [ -q] src_folder dst_folder map_file [map_file...]
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   129
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   130
function move_or_copy_plugins {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   131
    if [ "$1" != "move_plugins" -a "$1" != "copy_plugins" ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   132
        echo 'usage: move_or_copy_plugins <move_plugins | copy_plugins> [ -q] src_folder dst_folder map_file [map_file...]'
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   133
        return 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   134
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   135
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   136
    local move_or_copy=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   137
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   138
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   139
    local verbose=1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   140
    if [ "$1" = "-q" ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   141
        verbose=0
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   142
        shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   143
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   144
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   145
    if [ $# -lt 3 ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   146
        echo usage: $move_or_copy [ -q] src_folder dst_folder map_file [map_file...]
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   147
        return 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   148
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   149
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   150
    local src_folder=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   151
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   152
    local dst_folder=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   153
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   154
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   155
    if [ ! -d $src_folder ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   156
        echo ERROR: $move_or_copy: cannot find $src_folder
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   157
        return 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   158
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   159
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   160
    [ -d $dst_folder/features ] || mkdir -p $dst_folder/features
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   161
    [ -d $dst_folder/plugins ] || mkdir -p $dst_folder/plugins
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   162
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   163
    local name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   164
    local name2
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   165
    local have_x86_eol
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   166
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   167
    for name in $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   168
    do
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   169
        if [ ! -f $name ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   170
            echo ERROR: $move_or_copy: cannot find map file: $name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   171
            return 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   172
        fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   173
    done
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   174
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   175
    for name in `cat $* | grep -v "^#" | grep , | cut -d"," -f2`
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   176
    do
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   177
        #echo $src_folder/${name} $src_folder/${name}_*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   178
        # Except for x86_64 plugins, plugins follow the convention that they do not have underscores in the name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   179
        # For example: org.eclipse.swt.win32.win32.x86_* matches
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   180
        #    org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   181
        #    org.eclipse.swt.win32.win32.x86_64.source_3.4.1.v3449c.jar
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   182
        #    org.eclipse.swt.win32.win32.x86_64_3.4.1.v3449c.jar
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   183
        # Check for x86_64 and handle the exception
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   184
        echo $name | grep x86$ > /dev/null 2>&1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   185
        if [ $? -eq 0 ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   186
            have_x86_eol=1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   187
        else
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   188
            have_x86_eol=0
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   189
        fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   190
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   191
        features_or_plugins=`echo $name | cut -d"/" -f1`
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   192
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   193
        # The x86 names may expand to more than one filename
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   194
        for name2 in $src_folder/${name}_*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   195
        do
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   196
            if [ "$name2" = '$src_folder/${name}_*' ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   197
                # no match found
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   198
                [ $verbose -eq 1 ] && echo WARNING: $move_or_copy: cannot find $src_folder/${name}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   199
            else
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   200
                echo $name2 | grep x86_64 > /dev/null 2>&1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   201
                if [ $? -ne 0 -o $have_x86_eol -eq 0 ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   202
                    # do this if name2 does not have x86_64  OR  if pattern does end in x86
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   203
                    if [ "$move_or_copy" = "move_plugins" ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   204
                        run mv $name2 $dst_folder/$features_or_plugins
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   205
                    else
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   206
                        run cp -pr $name2 $dst_folder/$features_or_plugins
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   207
                    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   208
                fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   209
            fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   210
        done
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   211
    done
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   212
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   213
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   214
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   215
# move plugins from one layout to another
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   216
# usage: move_plugins [ -q] src_folder dst_folder map_file [map_file...]
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   217
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   218
function move_plugins {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   219
    move_or_copy_plugins move_plugins $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   220
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   221
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   222
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   223
# copy plugins from one layout to another
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   224
# usage: copy_plugins [ -q] src_folder dst_folder map_file [map_file...]
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   225
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   226
function copy_plugins {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   227
    move_or_copy_plugins copy_plugins $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   228
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   229
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   230
# ------------------------------------------------------------------
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   231
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   232
# clone mercurial repository
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   233
# usage: hg_clone checkout_folder buildtags_file username password host revision repo [repo...]
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   234
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   235
function hg_clone {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   236
    if [ $# -lt 7 ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   237
        echo usage: usage: hg_clone checkout_folder buildtags_file username password host revision repo [repo...]
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   238
        set_returncode 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   239
        return 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   240
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   241
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   242
    local checkout_folder=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   243
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   244
    local buildtags_file=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   245
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   246
    local username=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   247
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   248
    local password=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   249
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   250
    local host=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   251
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   252
    local revision=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   253
    shift
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   254
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   255
    if [ ! -d $checkout_folder ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   256
        echo ERROR: hg_clone: cannot find $checkout_folder
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   257
        set_returncode 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   258
        return 1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   259
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   260
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   261
    local url=http://${username}:${password}@$host
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   262
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   263
    local name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   264
    for name in $*
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   265
    do
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   266
        if [ ! -d $checkout_folder/$name ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   267
            run cd $checkout_folder
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   268
            run mkdir -p $name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   269
            run rmdir $name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   270
            echo hg clone http://$host/$name $name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   271
            run_quiet hg clone $url/$name $name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   272
        else
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   273
            run cd $checkout_folder/$name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   274
            echo hg pull http://$host/$name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   275
            run_quiet hg pull $url/$name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   276
        fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   277
        run cd $checkout_folder/$name
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   278
        run hg update -C $revision
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   279
        echo http://$host/$name `hg identify` >> $buildtags_file
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   280
    done
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   281
}
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   282
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   283
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   284
# ------------------------------------------------------------------
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   285
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   286
# remove update site URLs from feature.xml
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   287
#
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   288
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   289
function remove_update_site_urls {
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   290
    local feature_xml=$1
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   291
    local temp_file=$2
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   292
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   293
    xml2oneline $feature_xml > $temp_file
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   294
    grep tools.ext.nokia.com/updates $temp_file > /dev/null
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   295
    if [ $? -eq 0 ]; then
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   296
        echo remove update site tools.ext.nokia.com/updates from $feature_xml
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   297
        grep -v tools.ext.nokia.com/updates $temp_file | grep -v \<url\> | grep -v \</url\> > $feature_xml
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   298
        unix2dos $feature_xml
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   299
    fi
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   300
    rm -f $temp_file
c7f424dea615 add Symbian Foundation build scripts
cawthron
parents:
diff changeset
   301
}