blob: 9e470990e1ddd8ea925c75cc4ece7ba80ee65a9a (
plain)
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
|
#!/bin/bash
# sb2-upgrade-config:
# - This script is used to automatically update/upgrade configuration files.
# - Called from the "sb2" script whenever needed; see the configuration
# version check in load_configuration() of "sb2".
# - Should not be called directly from the command line!
#
# Copyright (C) 2009 Nokia Corporation.
# Licensed under GPL version 2
my_path=$_
if [ $(basename $my_path) != $(basename $0) ]; then
my_path=$0
if [ $(basename $my_path) = $my_path ]; then
my_path=$(which $my_path)
fi
fi
SBOX_SHARE_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
SBOX_TARGET=$1
SBOX_CONFIG_DIR=~/.scratchbox2/$SBOX_TARGET/sb2.config.d
function exit_error()
{
echo "$my_path: Error: $@"
exit 1
}
if [ -z "$SBOX_TARGET" ]; then
exit_error "this script is intended for sb2's internal use only!"
fi
function log_config_action()
{
tstamp=`/bin/date '+%Y-%m-%d %H:%M:%S'`
echo "$tstamp $*" >>$SBOX_CONFIG_DIR/CONFIG-LOG
}
# Get the original arguments that were specified to sb2-init from
# the old configuration file; we only need three variables from that file..
function get_sb2_init_arguments_from_old_config_file()
{
OLD_CONFIG_FILE=$HOME/.scratchbox2/$SBOX_TARGET/sb2.config
if [ ! -f $OLD_CONFIG_FILE ]; then
exit_error "$OLD_CONFIG_FILE does not exist"
fi
# Check version
vers=`egrep -m 1 '^SBOX_CONFIG_VERSION=' $OLD_CONFIG_FILE`
SBOX_CONFIG_VERSION=0
eval $vers
if [ "$SBOX_CONFIG_VERSION" -lt 5 ]; then
exit_error "configuration file version is too old ($OLD_CONFIG_FILE)"
fi
# Get original options & target name & compiler(s)
args=`egrep -m 1 '^SBOX_INIT_ORIG_ARGS=' $OLD_CONFIG_FILE`
eval $args
# Get original target_root
targetroot=`egrep -m 1 '^SBOX_TARGET_ROOT=' $OLD_CONFIG_FILE`
eval $targetroot
export SB2INIT_TARGET_ROOT=$SBOX_TARGET_ROOT
$SBOX_SHARE_DIR/scripts/sb2-parse-sb2-init-args $SBOX_INIT_ORIG_ARGS \
> $SBOX_CONFIG_DIR/sb2-init-args
log_config_action "Config upgrade: arguments of original sb2-init restored from old config file"
}
function update_toolchain_configs()
{
secondary_compiler=""
for compiler_path in $*; do
echo "Updating compiler $compiler_path"
log_config_action "Config upgrade: settings for compiler $compiler_path"
$SBOX_SHARE_DIR/scripts/sb2-config-gcc-toolchain \
$secondary_compiler \
-R "$SB2INIT_TARGET_ROOT" \
-S "$SBOX_SHARE_DIR/../.." \
-t "$SB2INIT_TARGET" \
-m "$SB2INIT_MAPPING_MODE" \
-C "$SB2INIT_SBOX_EXTRA_CROSS_COMPILER_ARGS" \
-- \
$compiler_path
if [ $? != 0 ]; then
log_config_action "failed to configure $compiler_path"
echo "Failed to configure $compiler_path"
exit 1
fi
secondary_compiler="-V"
done
}
if [ ! -d $SBOX_CONFIG_DIR ]; then
mkdir $SBOX_CONFIG_DIR
log_config_action "Config upgrade: Created configuration directory"
fi
if [ ! -f $SBOX_CONFIG_DIR/sb2-init-args ]; then
# This is an old target.
# Need to get sb2-init's parameters from the old config file
get_sb2_init_arguments_from_old_config_file
fi
# read in the values that were used when sb2-init was executed:
. $SBOX_CONFIG_DIR/sb2-init-args
#==============================================
# Finally:
# check if we need to actually update something:
# version "11" added separate config files for gcc toolchains:
if [ ! -f $SBOX_CONFIG_DIR/config-stamp.11 ]; then
update_toolchain_configs $SB2INIT_COMPILERS
fi
log_config_action "Config updated to version #11"
touch $SBOX_CONFIG_DIR/config-stamp.11
|