This file is indexed.

/usr/bin/sb2-config 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
#!/bin/bash
# Copyright (C) 2006,2007 Lauri Leukkunen <lle@rahina.org>
# 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

function log_config_action()
{
	mkdir -p $SBOX_CONFIG_DIR
	tstamp=`/bin/date '+%Y-%m-%d %H:%M:%S'`
	echo "$tstamp	$*" >>$SBOX_CONFIG_DIR/CONFIG-LOG
}

function usage()
{
	cat <<EOF
sb2-config - configure scratchbox2
Usage:
	sb2-config [OPTION]... [COMMAND [PARAMS]]

Options:
    -l                list scratchbox2 targets
    -d TARGETNAME     set default scratchbox2 target
    -t TARGETNAME     set scratchbox2 target to configure
    -h                print this help
    -v                display version

Commands:
    showtarget		     show (default) target
    showlog                  show configuration log
    showenv		     show target-specific environment variables
    setenv VARIABLE VALUE    set target-specific environment variable
    clearenv VARIABLE        set clearing for target-specific environment variable
    unsetenv VARIABLE        remove target-specific environment variable

Examples:
    sb2-config -d ARM
    sb2-config -t ARM setenv FOO bar
EOF
	exit 2
}

function version()
{
	cat $SBOX_DIR/share/scratchbox2/version
	exit 0
}

function list_targets()
{
	if [ ! -d $HOME/.scratchbox2 ]; then
		echo "$HOME/.scratchbox2 missing, create some targets with sb2-init!" >&2
		exit 1
	fi
	list=$(find $HOME/.scratchbox2/ -maxdepth 2 -mindepth 2 \
		-type f -and -name "sb2.config" 2>/dev/null | sort)
	if [ $? != 0 ]; then
		echo "Error occured while getting list of targets" >&2
		exit 2
	fi
	if [ -z "$list" ]; then
		echo "No targets found, create some with sb2-init!" >&2
		exit 1
	fi
	for f in $list; do echo $(basename $(dirname $f)); done
}

function show_config_log()
{
	target=$1

	if [ "$target" == "-" ]; then
		# use default target
		if [ ! -f $HOME/.scratchbox2/config ]; then
			echo "default target has not been set!" >&2
			exit 1
		fi
		. $HOME/.scratchbox2/config
		target=$DEFAULT_TARGET
		echo "Configuration log of '$target'"
	fi
	SBOX_CONFIG_DIR=$HOME/.scratchbox2/$target/sb2.config.d

	if [ ! -d $HOME/.scratchbox2/$target ]; then
		echo "target $target does not exist!" >&2
		exit 1
	fi

	if [ ! -f $SBOX_CONFIG_DIR/CONFIG-LOG ]; then
		echo "target $target does not have a configuration log!" >&2
		exit 1
	fi
	# else log found

	cat $SBOX_CONFIG_DIR/CONFIG-LOG
	exit 0
}

function write_config()
{
	echo "
DEFAULT_TARGET=$DEFAULT_TARGET
" > $HOME/.scratchbox2/config
	log_config_action "sb2-config: this is now the default target."
}

function setenv_var()
{
	varname="$1"
	[ -z "$varname" ] && usage

	shift
	value="$*"

	mkdir -p "$SBOX_CONFIG_DIR/env_vars"
	echo "$varname=$value" >$SBOX_CONFIG_DIR/env_vars/$varname

	log_config_action "sb2-config: setenv $varname=$value"
}

function clearenv_var()
{
	varname="$1"
	[ -z "$varname" ] && usage

	shift
	value="$*"

	mkdir -p "$SBOX_CONFIG_DIR/env_vars"
	:>$SBOX_CONFIG_DIR/env_vars/$varname

	log_config_action "sb2-config: clearenv $varname"
}

function unsetenv_var()
{
	varname="$1"
	[ -z "$varname" ] && usage

	if [ -f "$SBOX_CONFIG_DIR/env_vars/$varname" ]; then
		rm $SBOX_CONFIG_DIR/env_vars/$varname
		log_config_action "sb2-config: unsetenv $varname"
	else
		echo "variable $varname did not exist for this target" >&2
		exit 1
	fi
}


function showenv_vars()
{
	if [ -d $SBOX_CONFIG_DIR/env_vars ]; then
		count=$( ls $SBOX_CONFIG_DIR/env_vars/* 2>/dev/null | wc -l )
		if [ "$count" -gt 0 ]; then
			for i in $SBOX_CONFIG_DIR/env_vars/*; do
				if [ -s "$i" ]; then
					echo declare -x `cat "$i"`
				else
					echo unset `basename "$i"`
				fi
			done
		fi
	fi
	# else there are none.
}

SBOX_DIR=$(readlink -f $(dirname $(readlink -f $my_path))/..)
WRITE_CONFIG=0

if [ $# == 0 ]; then
	# No parameters
	usage
fi

while getopts d:hlL:vt: foo
do
	case $foo in
	(d) DEFAULT_TARGET=$OPTARG
	    targetname=$OPTARG
	    WRITE_CONFIG=1
	    ;;
	(h) usage ;;
	(l) list_targets ;;
	(L) show_config_log $OPTARG ;; # Deprecated! use command 'showlog' instead
	(t) targetname=$OPTARG ;;
	(v) version ;;
	(*) usage ;;
	esac
done
shift $(($OPTIND - 1))

# Use the default target if "-t target" was not used
if [ -z "$targetname" ]; then
	if [ ! -f $HOME/.scratchbox2/config ]; then
		echo "default target has not been set!" >&2
		exit 1
	fi
	. $HOME/.scratchbox2/config
	targetname=$DEFAULT_TARGET
fi

# log_config_action can be used after this, it requires SBOX_CONFIG_DIR
SBOX_CONFIG_DIR=$HOME/.scratchbox2/$targetname/sb2.config.d

if [ $WRITE_CONFIG == 1 ]; then
	write_config
fi

command=$1
if [ -z "$command" ]; then
	exit 0
fi
shift

if [ ! -d $HOME/.scratchbox2/$targetname ]; then
	echo "target $targetname does not exist!" >&2
	exit 1
fi

case "$command" in
showtarget)	echo $targetname;;
showenv)	showenv_vars $*;;
setenv)		setenv_var $*;;
clearenv)	clearenv_var $*;;
unsetenv)	unsetenv_var $*;;
showlog)	show_config_log $targetname;;
*)		usage;;
esac