updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / sdx / Xsdx.sh
blobd20fc85c9152841b949f61759fa0914b0d268476
1 #!/bin/bash
3 # Wrapper script for sdx, to facilitate the creation of starkits (including cross-platform builds)
4 # Created for the ArchLinux sdx package, licensed under the same conditions as sdx
5 # Copyright: Simon Bachmann (simonbachmann@freesurf.ch), 2007
8 APPNAME=$0
9 TCLKIT_DIR=/usr/share/sdx/tclkits
10 SDX=/usr/bin/sdx
12 print_help () {
14 case $1 in
16 "")
18 cat << EOF
20 $APPNAME is a script that extends sdx to make it easier to create starkits.
22 For more informations about sdx type: $APPNAME sdxhelp ?command?
23 For more informations about $APPNAME type: $APPNAME help ?command?
25 EOF
28 "help")
29 cat << EOF
30 Specify one of the following commands:
31 sdxhelp Access the sdx help
32 wrap Extended wrap command
33 listkits Display a list of all available tclkits
35 For more information type: $APPNAME help ?command?
37 EOF
40 sdxhelp)
41 cat << EOF
43 Access the sdx help
45 Usage: sdxhelp ?command?
47 command Sdx command to get more information about
49 With no command specified, a list of all sdx commands
50 with a short description is displayed.
52 EOF
55 wrap)
56 cat << EOF
58 Extended wrap command
60 Usage: wrap name ?options?
62 -runtime name The runtime tclkit to use, one of the
63 names returned by "listkits"
64 -runtimefile file Specifiy runtime with full path
66 All other options are unchanged. See 'sdx help wrap' for details.
68 EOF
71 listkits)
72 cat << EOF
74 Display a list of all available tclkits
76 Usage: listkits
78 The name of each tclkit should tell you for wich platform
79 it was built. To add more tclkits, just copy them to
80 $TCLKIT_DIR
82 EOF
86 print_help help ;;
88 esac
92 sdxhelp () {
93 $SDX help $@
96 wrap () {
97 search_kits
98 while [ "$1" != "" ]; do
99 case $1 in
100 -runtime)
101 shift
102 i=`search_array KITS $1`
103 if [ "$i" != "-1" ]; then
104 options="$options -runtime ${PATHS[$i]}"
105 else
106 echo -e "Starkit named $1 does not exist\n"
107 listkits
108 exit
112 -runtimefile)
113 shift
114 options="$options -runtime $1"
118 options="$options $1"
120 esac
121 shift
122 done
124 $SDX wrap $options
127 listkits () {
128 search_kits
129 echo -e "These tclkits are available:\n"
130 for k in "${KITS[@]}"; do
131 echo -e "\t$k"
132 done
133 echo
136 search_array () {
137 eval arr="( \${$1[@]} )"
138 found="-1"
139 ret=1
140 for (( i=0 ; $i < ${#arr[@]} ; i+=1)); do
141 if [ "${arr[$i]}" = "$2" ]; then
142 found=$i
143 ret=0
145 done
147 echo $found
148 return $ret
152 #search tclkits
153 search_kits () {
155 for path in "$TCLKIT_DIR"/*; do
156 k=`basename "$path"`
157 if [ -r "$path" -a -x "$path" ]; then
158 KITS[$i]="$k"
159 PATHS[$i]="$path"
160 let i+=1
162 done
165 #for debug
166 #echo "Found kits: ${KITS[@]}"
167 #echo "Found paths: ${PATHS[@]}"
169 #parse subcommands
170 case $1 in
172 print_help ;;
174 sdxhelp)
175 shift
176 sdxhelp $@ ;;
178 wrap)
179 shift
180 wrap $@ ;;
182 listkits)
183 shift
184 listkits $@ ;;
186 help)
187 shift
188 if [ "$1" = "" ]; then
189 print_help help
190 else
191 print_help $1
195 "--help" | "-h")
196 print_help ;;
199 $SDX $@ ;;
201 esac