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.
13 echo "gen-install-script: $1"
23 echo "gen-install-script: WARNING: $1"
27 echo "gen-install-script: error: $1"
39 if command -v $1 >/dev
/null
2>&1
51 printf "gen-install-script: %-20s := %.35s ...\n" $1 "$T"
53 printf "gen-install-script: %-20s := %s %s\n" $1 "$T" "$2"
58 VAL_OPTIONS
="$VAL_OPTIONS $1"
67 local UOP
=$
(echo $OP |
tr '[:lower:]' '[:upper:]' |
tr '\-' '\_')
72 if echo "$arg" |
grep -q -- "--$OP="
74 val
=$
(echo "$arg" | cut
-f2 -d=)
84 OP
="${OP}=[${DEFAULT}]"
85 printf " --%-30s %s\n" "$OP" "$DOC"
90 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
111 if [ "$arg" = "--${FLAG}-${OP}" ]
113 OP
=$
(echo $OP |
tr 'a-z-' 'A-Z_')
114 FLAG
=$
(echo $FLAG |
tr 'a-z' 'A-Z')
115 local V
="CFG_${FLAG}_${OP}"
125 printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
130 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
140 if [ "$arg" = "--${OP}" ]
142 OP
=$
(echo $OP |
tr 'a-z-' 'A-Z_')
153 printf " --%-30s %s\n" "$OP" "$DOC"
161 for option
in $BOOL_OPTIONS
163 if test --disable-$option = $arg
167 if test --enable-$option = $arg
171 if test --$option = $arg
176 for option
in $VAL_OPTIONS
178 if echo "$arg" |
grep -q -- "--$option="
183 if [ "$arg" = "--help" ]
186 echo "No more help available for Configure options,"
187 echo "check the Wiki or join our IRC channel"
190 if test $isArgValid -eq 0
192 err
"Option '$arg' is not recognized"
198 msg
"looking for install programs"
205 CFG_SRC_DIR
="$(cd $(dirname $0) && pwd)"
210 if [ "$1" = "--help" ]
215 echo "Usage: $CFG_SELF [options]"
220 step_msg
"processing $CFG_SELF args"
223 valopt product-name
"Product" "The name of the product, for display"
224 valopt verify-bin
"" "The command to run with --version to verify the install works"
225 valopt rel-manifest-dir
"${CFG_VERIFY_BIN}lib" "The directory under lib/ where the manifest lives"
226 valopt success-message
"Installed." "The string to print after successful installation"
227 valopt output-script
"${CFG_SRC_DIR}/install.sh" "The name of the output script"
228 valopt legacy-manifest-dirs
"" "Places to look for legacy manifests to uninstall"
236 step_msg
"validating $CFG_SELF args"
239 RUST_INSTALLER_VERSION
=`cat "$CFG_SRC_DIR/rust-installer-version"`
241 # Replace dashes in the success message with spaces (our arg handling botches spaces)
242 CFG_PRODUCT_NAME
=`echo "$CFG_PRODUCT_NAME" | sed "s/-/ /g"`
244 # Replace dashes in the success message with spaces (our arg handling botches spaces)
245 CFG_SUCCESS_MESSAGE
=`echo "$CFG_SUCCESS_MESSAGE" | sed "s/-/ /g"`
247 SCRIPT_TEMPLATE
=`cat "${CFG_SRC_DIR}/install-template.sh"`
249 # Using /bin/echo because under sh emulation dash *seems* to escape \n, which screws up the template
250 SCRIPT
=`/bin/echo "${SCRIPT_TEMPLATE}"`
251 SCRIPT
=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_PRODUCT_NAME%%/\"${CFG_PRODUCT_NAME}\"/"`
252 SCRIPT
=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_VERIFY_BIN%%/${CFG_VERIFY_BIN}/"`
253 SCRIPT
=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_REL_MANIFEST_DIR%%/${CFG_REL_MANIFEST_DIR}/"`
254 SCRIPT
=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_SUCCESS_MESSAGE%%/\"${CFG_SUCCESS_MESSAGE}\"/"`
255 SCRIPT
=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_LEGACY_MANIFEST_DIRS%%/\"${CFG_LEGACY_MANIFEST_DIRS}\"/"`
256 SCRIPT
=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_RUST_INSTALLER_VERSION%%/\"$RUST_INSTALLER_VERSION\"/"`
258 /bin
/echo "${SCRIPT}" > "${CFG_OUTPUT_SCRIPT}"
259 need_ok
"couldn't write script"
260 chmod u
+x
"${CFG_OUTPUT_SCRIPT}"
261 need_ok
"couldn't chmod script"