/usr/share/scratchbox2/scripts/sb2-config-debian is in scratchbox2 2.2.4-1debian1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/bin/bash
# sb2-config-debian - configure Debian build settings for SB2
#
# Copyright (c) 2009 Nokia Corporation.
# Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org>
# Licensed under GPL version 2
# NOTE: sb2-upgrade-config may call this before a new config has
# been stamped, so "sb2" must be invoked with "-u" always from
# this script!
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
function log_config_action()
{
tstamp=`/bin/date '+%Y-%m-%d %H:%M:%S'`
echo "$tstamp $*" >>$SBOX_CONFIG_DIR/CONFIG-LOG
}
function usage()
{
cat <<EOF
sb2-config-debian - Configure Debian build settings for SB2
Usage:
sb2-config-debian [OPTIONS]
This script uses the "dpkg-architecture" tool to detect
values for DEB_HOST_GNU_TYPE, DEB_BUILD_GNU_SYSTEM, etc.
environment variables and stores them to the config directory.
This is normally invoked automatically by "sb2-init".
Options:
-t target set target name
-h print this help
-v verbose operation
EOF
exit 2
}
if [ -z "$*" ]; then
usage
fi
verbose=""
while getopts t:hv option
do
case $option in
(t) TARGET=$OPTARG ;;
(h) usage ;;
(v) verbose=yes ;;
(*) usage ;;
esac
done
shift $(($OPTIND - 1))
if [ -n "$*" ]; then
# has extra arguments.
usage
fi
# ---------- Check parameters
if [ -z "$SBOX_DIR" ]; then
SBOX_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
fi
if [ -z "$TARGET" ]; then
echo "Error: no target given"
exit 1
fi
# ---------- end of parameter checks
SBOX_CONFIG_DIR=~/.scratchbox2/$TARGET/sb2.config.d
# Handle recursive execution gracefully
# (due to sb2-upgrade-config).
[ "$SBOX_CONFIG_DEBIAN_UPGRADE" ] && exit 0
export SBOX_CONFIG_DEBIAN_UPGRADE=yes
if [ -f $SBOX_CONFIG_DIR/gcc.config.sh ]; then
# configured with a cross-compiler;
# get ARCH from the primary gcc config file
. $SBOX_CONFIG_DIR/gcc.config.sh
ARCH=$SB2_GCC_INIT_ARCH
else
# No gcc. Use the value which was specified to sb2-init
. $SBOX_CONFIG_DIR/sb2-init-args
ARCH=$SB2INIT_ARCH
fi
# set DEBIAN_CPU. For some targets it is not the same as $ARCH
DEBIAN_CPU=$ARCH
HOST_ARCH="$(uname -m)"
if echo "$HOST_ARCH" | grep -q "^i.86*"; then
HOST_ARCH="i[3456]86"
fi
if [ -n "$verbose" ] ; then
echo "Host architecture is '$HOST_ARCH'"
fi
case "$ARCH" in
$HOST_ARCH*) ;;
arm*)
# SBOX_GCC_TARGET from gcc.config.sh..
if [ -z "$SBOX_GCC_TARGET" ]; then
DEBIAN_CPU=$ARCH
else
echo $SBOX_GCC_TARGET | grep -q -i eabi
if [ $? == 0 ]; then
DEBIAN_CPU=armel
fi
fi
;;
esac
case "$ARCH" in
arm*)
default_DEB_BUILD_ARCH=$DEBIAN_CPU
default_DEB_BUILD_ARCH_ABI="gnueabi"
default_DEB_BUILD_ARCH_CPU=$ARCH
default_DEB_BUILD_GNU_TYPE=$ARCH-linux-gnueabi
default_DEB_BUILD_GNU_SYSTEM="linux-gnueabi"
default_DEB_HOST_GNU_TYPE=$ARCH-linux-gnueabi
default_DEB_HOST_GNU_SYSTEM="linux-gnueabi"
default_DEB_HOST_ARCH_CPU=$ARCH
default_DEB_HOST_ARCH_OS="linux"
;;
*)
default_DEB_BUILD_ARCH=$DEBIAN_CPU
default_DEB_BUILD_ARCH_ABI="gnu"
default_DEB_BUILD_ARCH_CPU=$DEBIAN_CPU
default_DEB_BUILD_GNU_TYPE=$ARCH-linux-gnu
default_DEB_BUILD_GNU_SYSTEM=""
default_DEB_HOST_GNU_TYPE=$ARCH-linux-gnu
default_DEB_HOST_GNU_SYSTEM=""
default_DEB_HOST_ARCH_CPU=$DEBIAN_CPU
default_DEB_HOST_ARCH_OS="linux"
;;
esac
if [ ! -f $SBOX_CONFIG_DIR/debian.conf ]; then
# first time here (maybe upgrading the configuration);
# debian.conf does not exist. Create a temporary
# file, otherwise "sb2" will fail to run because
# this config file is mandatory now.
#
: >$SBOX_CONFIG_DIR/debian.conf
fi
# test if dpkg-architecture exists and can be executed
DPKG_ARCHITECTURE_FULLPATH=$(sb2 -t $TARGET -m devel which dpkg-architecture)
if [ $? != 0 ]; then
# Can't locate or run dpkg-architecture. Set the values here.
# FIXME: I'm still not sure if these settings are sane,
# they ought to be the same as they have been in sb2
# since the pre-historic days, but still...
if [ -n "$verbose" ] ; then
echo "dpkg-architecture doesn't exist: Using built-in values"
fi
CONFIG_METHOD="used built-in values, arch=$ARCH and debian_cpu=$DEBIAN_CPU"
cat >$SBOX_CONFIG_DIR/debian.conf <<EOF
# Debian configuration file generated by sb2-config-debian
# ($CONFIG_METHOD)
DEB_BUILD_ARCH=$default_DEB_BUILD_ARCH
DEB_BUILD_ARCH_ABI=$default_DEB_BUILD_ARCH_ABI
DEB_BUILD_ARCH_CPU=$default_DEB_BUILD_ARCH_CPU
DEB_BUILD_GNU_CPU=$ARCH
DEB_BUILD_GNU_TYPE=$default_DEB_BUILD_GNU_TYPE
DEB_BUILD_GNU_SYSTEM=$default_DEB_BUILD_GNU_SYSTEM
DEB_HOST_ARCH=$DEBIAN_CPU
DEB_HOST_ARCH_OS=$default_DEB_HOST_ARCH_OS
DEB_HOST_ARCH_CPU=$default_DEB_HOST_ARCH_CPU
DEB_HOST_GNU_CPU=$ARCH
DEB_HOST_GNU_TYPE=$default_DEB_HOST_GNU_TYPE
DEB_HOST_GNU_SYSTEM=$default_DEB_HOST_GNU_SYSTEM
export DEB_BUILD_ARCH
export DEB_BUILD_ARCH_CPU
export DEB_BUILD_ARCH_ABI
export DEB_BUILD_GNU_CPU
export DEB_BUILD_GNU_TYPE
export DEB_BUILD_GNU_SYSTEM
export DEB_HOST_ARCH
export DEB_HOST_ARCH_OS
export DEB_HOST_ARCH_CPU
export DEB_HOST_GNU_CPU
export DEB_HOST_GNU_TYPE
export DEB_HOST_GNU_SYSTEM
EOF
else
if [ -n "$verbose" ] ; then
echo "Found dpkg-architecture at $DPKG_ARCHITECTURE_FULLPATH"
fi
CONFIG_METHOD="values autodetected, based on output of $DPKG_ARCHITECTURE_FULLPATH"
# This is a bit tricky: sb2 may set the DEB_* variables
# always when a session is created (that happens if
# the debian build system settings are already active),
# so we must build a script which clears the settings:
sb2 -u -t $TARGET -m devel dpkg-architecture -a$DEBIAN_CPU |
sed -e 's/=.*//' -e 's/^/unset /' >$SBOX_CONFIG_DIR/debian.tmp0.$$
echo "dpkg-architecture -a$DEBIAN_CPU" >>$SBOX_CONFIG_DIR/debian.tmp0.$$
# Now we can run the script.
cat $SBOX_CONFIG_DIR/debian.tmp0.$$ |
sb2 -u -t $TARGET -m devel >$SBOX_CONFIG_DIR/debian.tmp1.$$
# the "-aARCH" flag of dpkg-architecture affect the target
# settings only (e.g. DEB_HOST_*). If we are cross-compiling
# for a different target architecture, the build host variables
# may refer to our real host now; change them. Because the whole
# idea of scratchbox2 is to virtualize the environment to look like
# this host was identical to the target system.
grep '^DEB_HOST_' $SBOX_CONFIG_DIR/debian.tmp1.$$ |
sed -e 's/^DEB_HOST_/DEB_BUILD_/' >$SBOX_CONFIG_DIR/debian.tmp2.$$
grep -v '^DEB_BUILD_' $SBOX_CONFIG_DIR/debian.tmp1.$$ \
>>$SBOX_CONFIG_DIR/debian.tmp2.$$
# Make sure that DEB_BUILD_ARCH_ABI exists:
grep -q '^DEB_BUILD_ARCH_ABI=' $SBOX_CONFIG_DIR/debian.tmp2.$$
if [ $? != 0 ]; then
echo "DEB_BUILD_ARCH_ABI=$default_DEB_BUILD_ARCH_ABI" \
>>$SBOX_CONFIG_DIR/debian.tmp2.$$
fi
echo "# Debian configuration file generated by sb2-config-debian" \
>$SBOX_CONFIG_DIR/debian.tmp3.$$
echo "# ($CONFIG_METHOD)" >>$SBOX_CONFIG_DIR/debian.tmp3.$$
cat $SBOX_CONFIG_DIR/debian.tmp2.$$ >>$SBOX_CONFIG_DIR/debian.tmp3.$$
# create separate "export" statements for all variables:
grep '^DEB_' $SBOX_CONFIG_DIR/debian.tmp2.$$ |
sed -e 's/^/export /' -e 's/=.*//' >>$SBOX_CONFIG_DIR/debian.tmp3.$$
mv $SBOX_CONFIG_DIR/debian.tmp3.$$ $SBOX_CONFIG_DIR/debian.conf
# remove temp. files
rm $SBOX_CONFIG_DIR/debian.tmp*.$$
fi
log_config_action "Debian build system configured ($CONFIG_METHOD)"
exit 0
|