2 # Copyright 2014 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
15 echo "gen-install-script: ${1-}"
25 echo "gen-install-script: WARNING: $1" >&2
29 echo "gen-install-script: error: $1" >&2
41 if command -v $1 >/dev
/null
2>&1
54 printf "gen-install-script: %-20s := %.35s ...\n" $1 "$t"
56 printf "gen-install-script: %-20s := %s %s\n" $1 "$t"
61 VAL_OPTIONS
="$VAL_OPTIONS $1"
70 local uop
=$
(echo $op |
tr '[:lower:]' '[:upper:]' |
tr '\-' '\_')
75 if echo "$arg" |
grep -q -- "--$op="
77 local val
=$
(echo "$arg" | cut
-f2 -d=)
87 op
="${default}=[${default}]"
88 printf " --%-30s %s\n" "$op" "$doc"
93 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
102 if [ $default -eq 0 ]
114 if [ "$arg" = "--${flag}-${op}" ]
116 op
=$
(echo $op |
tr 'a-z-' 'A-Z_')
117 flag
=$
(echo $flag |
tr 'a-z' 'A-Z')
118 local v
="CFG_${flag}_${op}"
128 printf " --%-30s %s\n" "$flag-$op" "$doc"
133 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
143 if [ "$arg" = "--${op}" ]
145 op
=$
(echo $op |
tr 'a-z-' 'A-Z_')
156 printf " --%-30s %s\n" "$op" "$doc"
164 for option
in $BOOL_OPTIONS
166 if test --disable-$option = $arg
170 if test --enable-$option = $arg
174 if test --$option = $arg
179 for option
in $VAL_OPTIONS
181 if echo "$arg" |
grep -q -- "--$option="
186 if [ "$arg" = "--help" ]
189 echo "No more help available for Configure options,"
190 echo "check the Wiki or join our IRC channel"
193 if test $is_arg_valid -eq 0
195 err
"Option '$arg' is not recognized"
201 msg
"looking for install programs"
211 if [ "$1" = "--help" ]
216 echo "Usage: $0 [options]"
221 step_msg
"processing arguments"
228 valopt product-name
"Product" "The name of the product, for display"
229 valopt rel-manifest-dir
"manifestlib" "The directory under lib/ where the manifest lives"
230 valopt success-message
"Installed." "The string to print after successful installation"
231 valopt output-script
"install.sh" "The name of the output script"
232 valopt legacy-manifest-dirs
"" "Places to look for legacy manifests to uninstall"
240 step_msg
"validating arguments"
243 src_dir
="$(cd $(dirname "$0") && pwd)"
245 rust_installer_version
=`cat "$src_dir/rust-installer-version"`
247 # Replace dashes in the success message with spaces (our arg handling botches spaces)
248 product_name
=`echo "$CFG_PRODUCT_NAME" | sed "s/-/ /g"`
250 # Replace dashes in the success message with spaces (our arg handling botches spaces)
251 success_message
=`echo "$CFG_SUCCESS_MESSAGE" | sed "s/-/ /g"`
253 script_template
=`cat "$src_dir/install-template.sh"`
255 # Using /bin/echo because under sh emulation dash *seems* to escape \n, which screws up the template
256 script=`/bin/echo "$script_template"`
257 script=`/bin/echo "$script" | sed "s/%%TEMPLATE_PRODUCT_NAME%%/\"$product_name\"/"`
258 script=`/bin/echo "$script" | sed "s/%%TEMPLATE_REL_MANIFEST_DIR%%/$CFG_REL_MANIFEST_DIR/"`
259 script=`/bin/echo "$script" | sed "s/%%TEMPLATE_SUCCESS_MESSAGE%%/\"$success_message\"/"`
260 script=`/bin/echo "$script" | sed "s/%%TEMPLATE_LEGACY_MANIFEST_DIRS%%/\"$CFG_LEGACY_MANIFEST_DIRS\"/"`
261 script=`/bin/echo "$script" | sed "s/%%TEMPLATE_RUST_INSTALLER_VERSION%%/\"$rust_installer_version\"/"`
263 /bin
/echo "$script" > "$CFG_OUTPUT_SCRIPT"
264 need_ok
"couldn't write script"
265 chmod u
+x
"$CFG_OUTPUT_SCRIPT"
266 need_ok
"couldn't chmod script"