summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2015-02-17 12:24:54 -0800
committerBrian Anderson <banderson@mozilla.com>2015-02-17 12:29:21 -0800
commite9303b9e60c43bf1bea0266d4badda3645c48e3c (patch)
tree83422331fd3e548343a8d204d4613132de55bc40
parent644c0d3610540c4099536e5c43197bcf51101134 (diff)
downloadrust-installer-rm-submodules.tar.gz
Remove submodulesrm-submodules
-rw-r--r--.gitmodules6
m---------test/rust-installer-v16
-rw-r--r--test/rust-installer-v1/.gitignore1
-rw-r--r--test/rust-installer-v1/README.md30
-rwxr-xr-xtest/rust-installer-v1/gen-install-script.sh253
-rwxr-xr-xtest/rust-installer-v1/gen-installer.sh303
-rw-r--r--test/rust-installer-v1/install-template.sh554
m---------test/rust-installer-v26
-rw-r--r--test/rust-installer-v2/.gitignore2
-rw-r--r--test/rust-installer-v2/.gitmodules3
-rw-r--r--test/rust-installer-v2/.travis.yml2
-rw-r--r--test/rust-installer-v2/README.md74
-rw-r--r--test/rust-installer-v2/combine-installers.sh347
-rwxr-xr-xtest/rust-installer-v2/gen-install-script.sh261
-rwxr-xr-xtest/rust-installer-v2/gen-installer.sh332
-rw-r--r--test/rust-installer-v2/install-template.sh743
-rw-r--r--test/rust-installer-v2/rust-installer-version1
-rwxr-xr-xtest/rust-installer-v2/test.sh588
-rw-r--r--test/rust-installer-v2/test/image1/bin/bad-bin1
-rwxr-xr-xtest/rust-installer-v2/test/image1/bin/program1
-rwxr-xr-xtest/rust-installer-v2/test/image1/bin/program21
-rw-r--r--test/rust-installer-v2/test/image1/dir-to-install/foo0
-rw-r--r--test/rust-installer-v2/test/image1/dir-to-not-install/foo0
-rw-r--r--test/rust-installer-v2/test/image1/something-to-install0
-rw-r--r--test/rust-installer-v2/test/image1/something-to-not-install0
-rwxr-xr-xtest/rust-installer-v2/test/image2/bin/oldprogram1
-rw-r--r--test/rust-installer-v2/test/image2/dir-to-install/bar0
-rw-r--r--test/rust-installer-v2/test/image2/something-to-install0
-rwxr-xr-xtest/rust-installer-v2/test/image3/bin/cargo1
-rw-r--r--test/rust-installer-v2/test/image4/baz0
-rw-r--r--test/rust-installer-v2/test/image4/dir-to-install/qux/bar0
-rw-r--r--test/rust-installer-v2/test/image5/dir-to-install/foo0
-rw-r--r--test/rust-installer-v2/test/rust-installer-v1/.gitignore1
-rw-r--r--test/rust-installer-v2/test/rust-installer-v1/README.md30
-rwxr-xr-xtest/rust-installer-v2/test/rust-installer-v1/gen-install-script.sh253
-rwxr-xr-xtest/rust-installer-v2/test/rust-installer-v1/gen-installer.sh303
-rw-r--r--test/rust-installer-v2/test/rust-installer-v1/install-template.sh554
37 files changed, 4640 insertions, 18 deletions
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 6075db6..0000000
--- a/.gitmodules
+++ /dev/null
@@ -1,6 +0,0 @@
-[submodule "test/rust-installer-v1"]
- path = test/rust-installer-v1
- url = .
-[submodule "test/rust-installer-v2"]
- path = test/rust-installer-v2
- url = .
diff --git a/test/rust-installer-v1 b/test/rust-installer-v1
deleted file mode 160000
-Subproject aed73472416064642911af790b25d57c9390b6c
diff --git a/test/rust-installer-v1/.gitignore b/test/rust-installer-v1/.gitignore
new file mode 100644
index 0000000..e4e5f6c
--- /dev/null
+++ b/test/rust-installer-v1/.gitignore
@@ -0,0 +1 @@
+*~ \ No newline at end of file
diff --git a/test/rust-installer-v1/README.md b/test/rust-installer-v1/README.md
new file mode 100644
index 0000000..f541504
--- /dev/null
+++ b/test/rust-installer-v1/README.md
@@ -0,0 +1,30 @@
+A generator for the install.sh script commonly used to install Rust in
+Unix environments. It is used By Rust, Cargo, and is intended to be
+used by a future combined installer of Rust + Cargo.
+
+# Usage
+
+```
+./gen-installer.sh --product-name=Rust \
+ --verify-bin=rustc \
+ --rel-manifest-dir=rustlib \
+ --success-message=Rust-is-ready-to-roll. \
+ --image-dir=./install-image \
+ --work-dir=./temp \
+ --output-dir=./dist \
+ --non-installed-prefixes="foo,bin/bar,lib/baz" \
+ --package-name=rustc-nightly-i686-apple-darwin
+```
+
+Or, to just generate the script.
+
+```
+./gen-install-script.sh --product-name=Rust \
+ --verify-bin=rustc \
+ --rel-manifest-dir=rustlib \
+ --success-message=Rust-is-ready-to-roll. \
+ --output-script=install.sh
+```
+
+*Note: the dashes in `success-message` are converted to spaces. The
+script's argument handling is broken with spaces.* \ No newline at end of file
diff --git a/test/rust-installer-v1/gen-install-script.sh b/test/rust-installer-v1/gen-install-script.sh
new file mode 100755
index 0000000..4c7e327
--- /dev/null
+++ b/test/rust-installer-v1/gen-install-script.sh
@@ -0,0 +1,253 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "gen-install-script: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "gen-install-script: WARNING: $1"
+}
+
+err() {
+ echo "gen-install-script: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "gen-install-script: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "gen-install-script: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+msg "looking for install programs"
+msg
+
+need_cmd sed
+need_cmd chmod
+need_cmd cat
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+valopt product-name "Product" "The name of the product, for display"
+valopt verify-bin "program" "The command to run with --version to verify the install works"
+valopt rel-manifest-dir "${CFG_VERIFY_BIN}lib" "The directory under lib/ where the manifest lives"
+valopt success-message "Installed." "The string to print after successful installation"
+valopt output-script "${CFG_SRC_DIR}/install.sh" "The name of the output script"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+# Replace dashes in the success message with spaces (our arg handling botches spaces)
+CFG_SUCCESS_MESSAGE=`echo "$CFG_SUCCESS_MESSAGE" | sed "s/-/ /g"`
+
+SCRIPT_TEMPLATE=`cat "${CFG_SRC_DIR}/install-template.sh"`
+
+# Using /bin/echo because under sh emulation dash *seems* to escape \n, which screws up the template
+SCRIPT=`/bin/echo "${SCRIPT_TEMPLATE}"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_PRODUCT_NAME%%/${CFG_PRODUCT_NAME}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_VERIFY_BIN%%/${CFG_VERIFY_BIN}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_REL_MANIFEST_DIR%%/${CFG_REL_MANIFEST_DIR}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_SUCCESS_MESSAGE%%/\"${CFG_SUCCESS_MESSAGE}\"/"`
+
+/bin/echo "${SCRIPT}" > "${CFG_OUTPUT_SCRIPT}"
+need_ok "couldn't write script"
+chmod u+x "${CFG_OUTPUT_SCRIPT}"
+need_ok "couldn't chmod script"
diff --git a/test/rust-installer-v1/gen-installer.sh b/test/rust-installer-v1/gen-installer.sh
new file mode 100755
index 0000000..c88eebe
--- /dev/null
+++ b/test/rust-installer-v1/gen-installer.sh
@@ -0,0 +1,303 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "gen-installer: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "gen-installer: WARNING: $1"
+}
+
+err() {
+ echo "gen-installer: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "gen-installer: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "gen-installer: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+msg "looking for programs"
+msg
+
+need_cmd tar
+need_cmd cp
+need_cmd rm
+need_cmd mkdir
+need_cmd echo
+need_cmd tr
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+valopt product-name "Product" "The name of the product, for display"
+valopt package-name "package" "The name of the package, tarball"
+valopt verify-bin "program" "The command to run with --version to verify the install works"
+valopt rel-manifest-dir "${CFG_VERIFY_BIN}lib" "The directory under lib/ where the manifest lives"
+valopt success-message "Installed." "The string to print after successful installation"
+valopt non-installed-prefixes "" "Path prefixes that should be included but not installed"
+valopt image-dir "./install-image" "The directory containing the installation medium"
+valopt work-dir "./workdir" "The directory to do temporary work"
+valopt output-dir "./dist" "The location to put the final image and tarball"
+opt tarball 1 "Disable tarball generation, leaving output in the temp dir"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+GEN_INSTALL_SCRIPT="$CFG_SRC_DIR/gen-install-script.sh"
+
+if [ ! -d "$CFG_IMAGE_DIR" ]
+then
+ err "image dir $CFG_IMAGE_DIR does not exist"
+fi
+
+mkdir -p "$CFG_WORK_DIR"
+need_ok "couldn't create work dir"
+
+rm -Rf "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't delete work package dir"
+
+mkdir -p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't create work package dir"
+
+cp -r "$CFG_IMAGE_DIR/"* "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't copy source image"
+
+# Split non_installed_files into lines for later iteration
+NON_INSTALLED_PREFIXES=`echo "$CFG_NON_INSTALLED_PREFIXES" | tr "," "\n"`
+
+# Create the manifest
+MANIFEST=`(cd "$CFG_WORK_DIR/$CFG_PACKAGE_NAME" && find . -type f | sed 's/^\.\///') | sort`
+
+# Remove non-installed files from manifest
+NON_INSTALLED_PREFIXES=`echo "$CFG_NON_INSTALLED_PREFIXES" | tr "," " "`
+for prefix in $NON_INSTALLED_PREFIXES; do
+ MANIFEST=`echo "$MANIFEST" | sed /^$prefix/d`
+done
+
+MANIFEST_NAME="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/lib/$CFG_REL_MANIFEST_DIR/manifest.in"
+
+mkdir -p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/lib/$CFG_REL_MANIFEST_DIR"
+need_ok "couldn't create manifest dir"
+
+# Write the manifest
+echo "$MANIFEST" > "$MANIFEST_NAME"
+
+# Generate the install script
+"$CFG_SRC_DIR/gen-install-script.sh" \
+ --product-name="$CFG_PRODUCT_NAME" \
+ --verify-bin="$CFG_VERIFY_BIN" \
+ --rel-manifest-dir="$CFG_REL_MANIFEST_DIR" \
+ --success-message="$CFG_SUCCESS_MESSAGE" \
+ --output-script="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/install.sh"
+
+need_ok "failed to generate install script"
+
+mkdir -p "$CFG_OUTPUT_DIR"
+need_ok "couldn't create output dir"
+
+rm -Rf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz"
+need_ok "couldn't delete old tarball"
+
+# Make a tarball
+tar -czf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz" -C "$CFG_WORK_DIR" "$CFG_PACKAGE_NAME"
+need_ok "failed to tar"
diff --git a/test/rust-installer-v1/install-template.sh b/test/rust-installer-v1/install-template.sh
new file mode 100644
index 0000000..545de67
--- /dev/null
+++ b/test/rust-installer-v1/install-template.sh
@@ -0,0 +1,554 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "install: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "install: WARNING: $1"
+}
+
+err() {
+ echo "install: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "install: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "install: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+absolutify() {
+ FILE_PATH="${1}"
+ FILE_PATH_DIRNAME="$(dirname ${FILE_PATH})"
+ FILE_PATH_BASENAME="$(basename ${FILE_PATH})"
+ FILE_ABS_PATH="$(cd ${FILE_PATH_DIRNAME} && pwd)"
+ FILE_PATH="${FILE_ABS_PATH}/${FILE_PATH_BASENAME}"
+ # This is the return value
+ ABSOLUTIFIED="${FILE_PATH}"
+}
+
+msg "looking for install programs"
+msg
+
+need_cmd mkdir
+need_cmd printf
+need_cmd cut
+need_cmd grep
+need_cmd uname
+need_cmd tr
+need_cmd sed
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+# Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
+# This logic is duplicated from configure in order to get the correct libdir
+# for Windows installs.
+CFG_OSTYPE=$(uname -s)
+
+case $CFG_OSTYPE in
+
+ Linux)
+ CFG_OSTYPE=unknown-linux-gnu
+ ;;
+
+ FreeBSD)
+ CFG_OSTYPE=unknown-freebsd
+ ;;
+
+ DragonFly)
+ CFG_OSTYPE=unknown-dragonfly
+ ;;
+
+ Darwin)
+ CFG_OSTYPE=apple-darwin
+ ;;
+
+ MINGW*)
+ # msys' `uname` does not print gcc configuration, but prints msys
+ # configuration. so we cannot believe `uname -m`:
+ # msys1 is always i686 and msys2 is always x86_64.
+ # instead, msys defines $MSYSTEM which is MINGW32 on i686 and
+ # MINGW64 on x86_64.
+ CFG_CPUTYPE=i686
+ CFG_OSTYPE=pc-windows-gnu
+ if [ "$MSYSTEM" = MINGW64 ]
+ then
+ CFG_CPUTYPE=x86_64
+ fi
+ ;;
+
+ MSYS*)
+ CFG_OSTYPE=pc-windows-gnu
+ ;;
+
+# Thad's Cygwin identifers below
+
+# Vista 32 bit
+ CYGWIN_NT-6.0)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=i686
+ ;;
+
+# Vista 64 bit
+ CYGWIN_NT-6.0-WOW64)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=x86_64
+ ;;
+
+# Win 7 32 bit
+ CYGWIN_NT-6.1)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=i686
+ ;;
+
+# Win 7 64 bit
+ CYGWIN_NT-6.1-WOW64)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=x86_64
+ ;;
+esac
+
+OPTIONS=""
+BOOL_OPTIONS=""
+VAL_OPTIONS=""
+
+if [ "$CFG_OSTYPE" = "pc-windows-gnu" ]
+then
+ CFG_LD_PATH_VAR=PATH
+ CFG_OLD_LD_PATH_VAR=$PATH
+elif [ "$CFG_OSTYPE" = "apple-darwin" ]
+then
+ CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH
+ CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH
+else
+ CFG_LD_PATH_VAR=LD_LIBRARY_PATH
+ CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH
+fi
+
+flag uninstall "only uninstall from the installation prefix"
+valopt destdir "" "set installation root"
+opt verify 1 "verify that the installed binaries run correctly"
+valopt prefix "/usr/local" "set installation prefix"
+# NB This isn't quite the same definition as in `configure`.
+# just using 'lib' instead of configure's CFG_LIBDIR_RELATIVE
+valopt libdir "${CFG_DESTDIR}${CFG_PREFIX}/lib" "install libraries"
+valopt mandir "${CFG_DESTDIR}${CFG_PREFIX}/share/man" "install man pages in PATH"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+
+
+# Template configuration.
+# These names surrounded by '%%` are replaced by sed when generating install.sh
+
+# Rust or Cargo
+TEMPLATE_PRODUCT_NAME=%%TEMPLATE_PRODUCT_NAME%%
+# rustc or cargo
+TEMPLATE_VERIFY_BIN=%%TEMPLATE_VERIFY_BIN%%
+# rustlib or cargo
+TEMPLATE_REL_MANIFEST_DIR=%%TEMPLATE_REL_MANIFEST_DIR%%
+# 'Rust is ready to roll.' or 'Cargo is cool to cruise.'
+TEMPLATE_SUCCESS_MESSAGE=%%TEMPLATE_SUCCESS_MESSAGE%%
+
+# OK, let's get installing ...
+
+# Sanity check: can we run the binaries?
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ # Don't do this if uninstalling. Failure here won't help in any way.
+ if [ -z "${CFG_UNINSTALL}" ]
+ then
+ msg "verifying platform can run binaries"
+ export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib:$CFG_OLD_LD_PATH_VAR"
+ "${CFG_SRC_DIR}/bin/${TEMPLATE_VERIFY_BIN}" --version 2> /dev/null 1> /dev/null
+ if [ $? -ne 0 ]
+ then
+ err "can't execute rustc binary on this platform"
+ fi
+ export $CFG_LD_PATH_VAR="$CFG_OLD_LD_PATH_VAR"
+ fi
+fi
+
+# Sanity check: can we can write to the destination?
+msg "verifying destination is writable"
+umask 022 && mkdir -p "${CFG_LIBDIR}"
+need_ok "can't write to destination. consider \`sudo\`."
+touch "${CFG_LIBDIR}/rust-install-probe" > /dev/null
+if [ $? -ne 0 ]
+then
+ err "can't write to destination. consider \`sudo\`."
+fi
+rm -f "${CFG_LIBDIR}/rust-install-probe"
+need_ok "failed to remove install probe"
+
+# Sanity check: don't install to the directory containing the installer.
+# That would surely cause chaos.
+msg "verifying destination is not the same as source"
+INSTALLER_DIR="$(cd $(dirname $0) && pwd)"
+PREFIX_DIR="$(cd ${CFG_PREFIX} && pwd)"
+if [ "${INSTALLER_DIR}" = "${PREFIX_DIR}" ]
+then
+ err "can't install to same directory as installer"
+fi
+
+# Using an absolute path to libdir in a few places so that the status
+# messages are consistently using absolute paths.
+absolutify "${CFG_LIBDIR}"
+ABS_LIBDIR="${ABSOLUTIFIED}"
+
+# The file name of the manifest we're going to create during install
+INSTALLED_MANIFEST="${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}/manifest"
+
+# First, uninstall from the installation prefix.
+# Errors are warnings - try to rm everything in the manifest even if some fail.
+if [ -f "${INSTALLED_MANIFEST}" ]
+then
+ msg
+
+ # Iterate through installed manifest and remove files
+ while read p; do
+ # The installed manifest contains absolute paths
+ msg "removing $p"
+ if [ -f "$p" ]
+ then
+ rm -f "$p"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove $p"
+ fi
+ else
+ warn "supposedly installed file $p does not exist!"
+ fi
+ done < "${INSTALLED_MANIFEST}"
+
+ # If we fail to remove $TEMPLATE_REL_MANIFEST_DIR below, then the
+ # installed manifest will still be full; the installed manifest
+ # needs to be empty before install.
+ msg "removing ${INSTALLED_MANIFEST}"
+ rm -f "${INSTALLED_MANIFEST}"
+ # For the above reason, this is a hard error
+ need_ok "failed to remove installed manifest"
+
+ # Remove $TEMPLATE_REL_MANIFEST_DIR directory
+ msg "removing ${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+ rm -Rf "${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove ${TEMPLATE_REL_MANIFEST_DIR}"
+ fi
+else
+ # There's no manifest. If we were asked to uninstall, then that's a problem.
+ if [ -n "${CFG_UNINSTALL}" ]
+ then
+ err "unable to find installation manifest at ${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+ fi
+fi
+
+# If we're only uninstalling then exit
+if [ -n "${CFG_UNINSTALL}" ]
+then
+ echo
+ echo " ${TEMPLATE_PRODUCT_NAME} is uninstalled."
+ echo
+ exit 0
+fi
+
+# Create the installed manifest, which we will fill in with absolute file paths
+mkdir -p "${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+need_ok "failed to create ${TEMPLATE_REL_MANIFEST_DIR}"
+touch "${INSTALLED_MANIFEST}"
+need_ok "failed to create installed manifest"
+
+msg
+
+# Now install, iterate through the new manifest and copy files
+while read p; do
+
+ # Decide the destination of the file
+ FILE_INSTALL_PATH="${CFG_DESTDIR}${CFG_PREFIX}/$p"
+
+ if echo "$p" | grep "^lib/" > /dev/null
+ then
+ pp=`echo $p | sed 's/^lib\///'`
+ FILE_INSTALL_PATH="${CFG_LIBDIR}/$pp"
+ fi
+
+ if echo "$p" | grep "^share/man/" > /dev/null
+ then
+ pp=`echo $p | sed 's/^share\/man\///'`
+ FILE_INSTALL_PATH="${CFG_MANDIR}/$pp"
+ fi
+
+ # Make sure there's a directory for it
+ umask 022 && mkdir -p "$(dirname ${FILE_INSTALL_PATH})"
+ need_ok "directory creation failed"
+
+ # Make the path absolute so we can uninstall it later without
+ # starting from the installation cwd
+ absolutify "${FILE_INSTALL_PATH}"
+ FILE_INSTALL_PATH="${ABSOLUTIFIED}"
+
+ # Install the file
+ msg "installing ${FILE_INSTALL_PATH}"
+ if echo "$p" | grep "^bin/" > /dev/null
+ then
+ install -m755 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
+ else
+ install -m644 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
+ fi
+ need_ok "file creation failed"
+
+ # Update the manifest
+ echo "${FILE_INSTALL_PATH}" >> "${INSTALLED_MANIFEST}"
+ need_ok "failed to update manifest"
+
+# The manifest lists all files to install
+done < "${CFG_SRC_DIR}/lib/${TEMPLATE_REL_MANIFEST_DIR}/manifest.in"
+
+msg
+
+# Run ldconfig to make dynamic libraries available to the linker
+if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
+ then
+ ldconfig
+ if [ $? -ne 0 ]
+ then
+ warn "failed to run ldconfig."
+ warn "this may happen when not installing as root and may be fine"
+ fi
+fi
+
+# Sanity check: can we run the installed binaries?
+#
+# As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
+# is in place. Try first without this variable, and if that fails try again with
+# the variable. If the second time tries, print a hopefully helpful message to
+# add something to the appropriate environment variable.
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ msg "verifying installed binaries are executable"
+ "${CFG_PREFIX}/bin/${TEMPLATE_VERIFY_BIN}" --version 2> /dev/null 1> /dev/null
+ if [ $? -ne 0 ]
+ then
+ export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib:$CFG_OLD_LD_PATH_VAR"
+ "${CFG_PREFIX}/bin/${TEMPLATE_VERIFY_BIN}" --version > /dev/null
+ if [ $? -ne 0 ]
+ then
+ ERR="can't execute installed binaries. "
+ ERR="${ERR}installation may be broken. "
+ ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
+ ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
+ err "${ERR}"
+ else
+ echo
+ echo " Note: please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
+ fi
+ fi
+fi
+
+echo
+echo " ${TEMPLATE_SUCCESS_MESSAGE}"
+echo
+
+
diff --git a/test/rust-installer-v2 b/test/rust-installer-v2
deleted file mode 160000
-Subproject e577c97b494be2815b215e3042207d6d4b7c551
diff --git a/test/rust-installer-v2/.gitignore b/test/rust-installer-v2/.gitignore
new file mode 100644
index 0000000..31ed630
--- /dev/null
+++ b/test/rust-installer-v2/.gitignore
@@ -0,0 +1,2 @@
+*~
+tmp \ No newline at end of file
diff --git a/test/rust-installer-v2/.gitmodules b/test/rust-installer-v2/.gitmodules
new file mode 100644
index 0000000..7485a91
--- /dev/null
+++ b/test/rust-installer-v2/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "test/rust-installer-v1"]
+ path = test/rust-installer-v1
+ url = https://github.com/rust-lang/rust-installer
diff --git a/test/rust-installer-v2/.travis.yml b/test/rust-installer-v2/.travis.yml
new file mode 100644
index 0000000..7e34188
--- /dev/null
+++ b/test/rust-installer-v2/.travis.yml
@@ -0,0 +1,2 @@
+script:
+ - ./test.sh
diff --git a/test/rust-installer-v2/README.md b/test/rust-installer-v2/README.md
new file mode 100644
index 0000000..e2588f2
--- /dev/null
+++ b/test/rust-installer-v2/README.md
@@ -0,0 +1,74 @@
+[![Build Status](https://travis-ci.org/rust-lang/rust-installer.svg?branch=master)](https://travis-ci.org/rust-lang/rust-installer)
+
+A generator for the install.sh script commonly used to install Rust in
+Unix environments. It is used By Rust, Cargo, and is intended to be
+used by a future combined installer of Rust + Cargo.
+
+# Usage
+
+```
+./gen-installer.sh --product-name=Rust \
+ --verify-bin=rustc \
+ --rel-manifest-dir=rustlib \
+ --success-message=Rust-is-ready-to-roll. \
+ --image-dir=./install-image \
+ --work-dir=./temp \
+ --output-dir=./dist \
+ --non-installed-prefixes=foo,bin/bar,lib/baz \
+ --package-name=rustc-nightly-i686-apple-darwin \
+ --component-name=rustc \
+ --legacy-manifest-dirs=rustlib \
+ --bulk-dirs=share/doc
+```
+
+Or, to just generate the script.
+
+```
+./gen-install-script.sh --product-name=Rust \
+ --verify-bin=rustc \
+ --rel-manifest-dir=rustlib \
+ --success-message=Rust-is-ready-to-roll. \
+ --output-script=install.sh \
+ --legacy-manifest-dirs=rustlib
+```
+
+*Note: the dashes in `success-message` are converted to spaces. The
+script's argument handling is broken with spaces.*
+
+To combine installers.
+
+```
+./combine-installers.sh --product-name=Rust \
+ --verify-bin=rustc \
+ --rel-manifest-dir=rustlib \
+ --success-message=Rust-is-ready-to-roll. \
+ --work-dir=./temp \
+ --output-dir=./dist \
+ --non-installed-overlay=./overlay \
+ --package-name=rustc-nightly-i686-apple-darwin \
+ --legacy-manifest-dirs=rustlib \
+ --input-tarballs=./rustc.tar.gz,cargo.tar.gz
+```
+
+# Future work
+
+* Make install.sh not have to be customized, pull it's data from a
+ config file.
+* Install an uninstall.sh script.
+* Allow components to be selected during install.
+* Allow components to be modified from an existing install.
+* Be more resiliant to installation failures, particularly if the disk
+ is full.
+* Pre-install and post-uninstall scripts.
+* Make the verify-bin a per-component option.
+* Be more thoughtful about overwriting existing files.
+* Allow components to depend on or contradict other components.
+* Sanity check that expected destination dirs (bin, lib, share exist)?
+* Add --docdir flag. Is there a standard name for this?
+* Remove empty directories on uninstall.
+* Detect mismatches in --prefix, --mandir, etc. in follow-on
+ installs/uninstalls.
+* Fix argument handling for spaces.
+* Add --bindir.
+* Store components in their own directories for cases where they
+ contain the same files. \ No newline at end of file
diff --git a/test/rust-installer-v2/combine-installers.sh b/test/rust-installer-v2/combine-installers.sh
new file mode 100644
index 0000000..d135d2b
--- /dev/null
+++ b/test/rust-installer-v2/combine-installers.sh
@@ -0,0 +1,347 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "combine-installers: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "combine-installers: WARNING: $1"
+}
+
+err() {
+ echo "combine-installers: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "combine-installers: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "combine-installers: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+msg "looking for programs"
+msg
+
+need_cmd tar
+need_cmd cp
+need_cmd rm
+need_cmd mkdir
+need_cmd echo
+need_cmd tr
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+valopt product-name "Product" "The name of the product, for display"
+valopt package-name "package" "The name of the package, tarball"
+valopt verify-bin "" "The command to run with --version to verify the install works"
+valopt rel-manifest-dir "${CFG_PACKAGE_NAME}lib" "The directory under lib/ where the manifest lives"
+valopt success-message "Installed." "The string to print after successful installation"
+valopt legacy-manifest-dirs "" "Places to look for legacy manifests to uninstall"
+valopt input-tarballs "" "Installers to combine"
+valopt non-installed-overlay "" "Directory containing files that should not be installed"
+valopt work-dir "./workdir" "The directory to do temporary work and put the final image"
+valopt output-dir "./dist" "The location to put the final tarball"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+RUST_INSTALLER_VERSION=`cat "$CFG_SRC_DIR/rust-installer-version"`
+
+# Create the work directory for the new installer
+mkdir -p "$CFG_WORK_DIR"
+need_ok "couldn't create work dir"
+
+rm -Rf "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't delete work package dir"
+
+mkdir -p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't create work package dir"
+
+INPUT_TARBALLS=`echo "$CFG_INPUT_TARBALLS" | sed 's/,/ /g'`
+
+# Merge each installer into the work directory of the new installer
+for input_tarball in $INPUT_TARBALLS; do
+
+ # Extract the input tarballs
+ tar xzf $input_tarball -C "$CFG_WORK_DIR"
+ need_ok "failed to extract tarball"
+
+ # Verify the version number
+ PKG_NAME=`echo "$input_tarball" | sed s/\.tar\.gz//g`
+ PKG_NAME=`basename $PKG_NAME`
+ VERSION=`cat "$CFG_WORK_DIR/$PKG_NAME/rust-installer-version"`
+ if [ "$RUST_INSTALLER_VERSION" != "$VERSION" ]; then
+ err "incorrect installer version in $input_tarball"
+ fi
+
+ # Interpret the manifest to copy the contents to the new installer
+ COMPONENTS=`cat "$CFG_WORK_DIR/$PKG_NAME/components"`
+ for component in $COMPONENTS; do
+ while read directive; do
+ COMMAND=`echo $directive | cut -f1 -d:`
+ FILE=`echo $directive | cut -f2 -d:`
+
+ NEW_FILE_PATH="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$FILE"
+ mkdir -p "$(dirname $NEW_FILE_PATH)"
+
+ case "$COMMAND" in
+ file | dir)
+ if [ -e "$NEW_FILE_PATH" ]; then
+ err "file $NEW_FILE_PATH already exists"
+ fi
+ cp -R "$CFG_WORK_DIR/$PKG_NAME/$FILE" "$NEW_FILE_PATH"
+ need_ok "failed to copy file $FILE"
+ ;;
+
+ * )
+ err "unknown command"
+ ;;
+
+ esac
+ done < "$CFG_WORK_DIR/$PKG_NAME/manifest-$component.in"
+
+ # Copy the manifest
+ if [ -e "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/manifest-$component.in" ]; then
+ err "manifest for $component already exists"
+ fi
+ cp "$CFG_WORK_DIR/$PKG_NAME/manifest-$component.in" "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/manifest-$component.in"
+ need_ok "failed to copy manifest for $component"
+
+ # Merge the component name
+ echo "$component" >> "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/components"
+ need_ok "failed to merge component $component"
+ done
+done
+
+# Write the version number
+echo "$RUST_INSTALLER_VERSION" > "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/rust-installer-version"
+
+# Copy the overlay
+if [ -n "$CFG_NON_INSTALLED_OVERLAY" ]; then
+ OVERLAY_FILES=`(cd "$CFG_NON_INSTALLED_OVERLAY" && find . -type f)`
+ for f in $OVERLAY_FILES; do
+ if [ -e "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$f" ]; then err "overlay $f exists"; fi
+
+ cp "$CFG_NON_INSTALLED_OVERLAY/$f" "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$f"
+ need_ok "failed to copy overlay $f"
+ done
+fi
+
+# Generate the install script
+"$CFG_SRC_DIR/gen-install-script.sh" \
+ --product-name="$CFG_PRODUCT_NAME" \
+ --verify-bin="$CFG_VERIFY_BIN" \
+ --rel-manifest-dir="$CFG_REL_MANIFEST_DIR" \
+ --success-message="$CFG_SUCCESS_MESSAGE" \
+ --legacy-manifest-dirs="$CFG_LEGACY_MANIFEST_DIRS" \
+ --output-script="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/install.sh"
+
+need_ok "failed to generate install script"
+
+mkdir -p "$CFG_OUTPUT_DIR"
+need_ok "couldn't create output dir"
+
+rm -Rf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz"
+need_ok "couldn't delete old tarball"
+
+# Make a tarball
+tar -czf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz" -C "$CFG_WORK_DIR" "$CFG_PACKAGE_NAME"
+need_ok "failed to tar"
diff --git a/test/rust-installer-v2/gen-install-script.sh b/test/rust-installer-v2/gen-install-script.sh
new file mode 100755
index 0000000..e00185e
--- /dev/null
+++ b/test/rust-installer-v2/gen-install-script.sh
@@ -0,0 +1,261 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "gen-install-script: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "gen-install-script: WARNING: $1"
+}
+
+err() {
+ echo "gen-install-script: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "gen-install-script: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "gen-install-script: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+msg "looking for install programs"
+msg
+
+need_cmd sed
+need_cmd chmod
+need_cmd cat
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+valopt product-name "Product" "The name of the product, for display"
+valopt verify-bin "" "The command to run with --version to verify the install works"
+valopt rel-manifest-dir "${CFG_VERIFY_BIN}lib" "The directory under lib/ where the manifest lives"
+valopt success-message "Installed." "The string to print after successful installation"
+valopt output-script "${CFG_SRC_DIR}/install.sh" "The name of the output script"
+valopt legacy-manifest-dirs "" "Places to look for legacy manifests to uninstall"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+RUST_INSTALLER_VERSION=`cat "$CFG_SRC_DIR/rust-installer-version"`
+
+# Replace dashes in the success message with spaces (our arg handling botches spaces)
+CFG_PRODUCT_NAME=`echo "$CFG_PRODUCT_NAME" | sed "s/-/ /g"`
+
+# Replace dashes in the success message with spaces (our arg handling botches spaces)
+CFG_SUCCESS_MESSAGE=`echo "$CFG_SUCCESS_MESSAGE" | sed "s/-/ /g"`
+
+SCRIPT_TEMPLATE=`cat "${CFG_SRC_DIR}/install-template.sh"`
+
+# Using /bin/echo because under sh emulation dash *seems* to escape \n, which screws up the template
+SCRIPT=`/bin/echo "${SCRIPT_TEMPLATE}"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_PRODUCT_NAME%%/\"${CFG_PRODUCT_NAME}\"/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_VERIFY_BIN%%/${CFG_VERIFY_BIN}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_REL_MANIFEST_DIR%%/${CFG_REL_MANIFEST_DIR}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_SUCCESS_MESSAGE%%/\"${CFG_SUCCESS_MESSAGE}\"/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_LEGACY_MANIFEST_DIRS%%/\"${CFG_LEGACY_MANIFEST_DIRS}\"/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_RUST_INSTALLER_VERSION%%/\"$RUST_INSTALLER_VERSION\"/"`
+
+/bin/echo "${SCRIPT}" > "${CFG_OUTPUT_SCRIPT}"
+need_ok "couldn't write script"
+chmod u+x "${CFG_OUTPUT_SCRIPT}"
+need_ok "couldn't chmod script"
diff --git a/test/rust-installer-v2/gen-installer.sh b/test/rust-installer-v2/gen-installer.sh
new file mode 100755
index 0000000..67eaf39
--- /dev/null
+++ b/test/rust-installer-v2/gen-installer.sh
@@ -0,0 +1,332 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "gen-installer: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "gen-installer: WARNING: $1"
+}
+
+err() {
+ echo "gen-installer: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "gen-installer: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "gen-installer: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+msg "looking for programs"
+msg
+
+need_cmd tar
+need_cmd cp
+need_cmd rm
+need_cmd mkdir
+need_cmd echo
+need_cmd tr
+need_cmd awk
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+valopt product-name "Product" "The name of the product, for display"
+valopt component-name "component" "The name of the component, distinct from other installed components"
+valopt package-name "package" "The name of the package, tarball"
+valopt verify-bin "" "The command to run with --version to verify the install works"
+valopt rel-manifest-dir "${CFG_PACKAGE_NAME}lib" "The directory under lib/ where the manifest lives"
+valopt success-message "Installed." "The string to print after successful installation"
+valopt legacy-manifest-dirs "" "Places to look for legacy manifests to uninstall"
+valopt non-installed-prefixes "" "Path prefixes that should be included but not installed"
+valopt bulk-dirs "" "Path prefixes of directories that should be installed/uninstalled in bulk"
+valopt image-dir "./install-image" "The directory containing the installation medium"
+valopt work-dir "./workdir" "The directory to do temporary work"
+valopt output-dir "./dist" "The location to put the final image and tarball"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+RUST_INSTALLER_VERSION=`cat "$CFG_SRC_DIR/rust-installer-version"`
+
+if [ ! -d "$CFG_IMAGE_DIR" ]
+then
+ err "image dir $CFG_IMAGE_DIR does not exist"
+fi
+
+mkdir -p "$CFG_WORK_DIR"
+need_ok "couldn't create work dir"
+
+rm -Rf "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't delete work package dir"
+
+mkdir -p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't create work package dir"
+
+cp -r "$CFG_IMAGE_DIR/"* "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't copy source image"
+
+# Create the manifest
+MANIFEST=`(cd "$CFG_WORK_DIR/$CFG_PACKAGE_NAME" && find . -type f | sed 's/^\.\///') | sort`
+
+# Remove non-installed files from manifest
+NON_INSTALLED_PREFIXES=`echo "$CFG_NON_INSTALLED_PREFIXES" | tr "," " "`
+for prefix in $NON_INSTALLED_PREFIXES; do
+ # This adds the escapes to '/' in paths to make them '\/' so sed doesn't puke.
+ # I figured this out by adding backslashes until it worked. Holy shit.
+ prefix=`echo "$prefix" | sed s/\\\//\\\\\\\\\\\//g`
+ MANIFEST=`echo "$MANIFEST" | sed /^$prefix/d`
+done
+
+# Remove files in bulk dirs
+BULK_DIRS=`echo "$CFG_BULK_DIRS" | tr "," " "`
+for bulk_dir in $BULK_DIRS; do
+ bulk_dir=`echo "$bulk_dir" | sed s/\\\//\\\\\\\\\\\//g`
+ MANIFEST=`echo "$MANIFEST" | sed /^$bulk_dir/d`
+done
+
+# Add 'file:' installation directives.
+# The -n prevents adding a blank file: if the manifest is empty
+MANIFEST=`/bin/echo -n "$MANIFEST" | sed s/^/file:/`
+
+# Add 'dir:' directives
+for bulk_dir in $BULK_DIRS; do
+ MANIFEST=`echo "$MANIFEST" && echo "dir:$bulk_dir"`
+done
+
+# The above step may have left a leading empty line if there were only
+# bulk dirs. Remove it.
+MANIFEST=`echo "$MANIFEST" | sed /^$/d`
+
+MANIFEST_FILE="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/manifest-$CFG_COMPONENT_NAME.in"
+COMPONENT_FILE="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/components"
+VERSION_FILE="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/rust-installer-version"
+
+# Write the manifest
+echo "$MANIFEST" > "$MANIFEST_FILE"
+
+# Write the component name
+echo "$CFG_COMPONENT_NAME" > "$COMPONENT_FILE"
+
+# Write the installer version (only used by combine-installers.sh)
+echo "$RUST_INSTALLER_VERSION" > "$VERSION_FILE"
+
+# Generate the install script
+"$CFG_SRC_DIR/gen-install-script.sh" \
+ --product-name="$CFG_PRODUCT_NAME" \
+ --verify-bin="$CFG_VERIFY_BIN" \
+ --rel-manifest-dir="$CFG_REL_MANIFEST_DIR" \
+ --success-message="$CFG_SUCCESS_MESSAGE" \
+ --legacy-manifest-dirs="$CFG_LEGACY_MANIFEST_DIRS" \
+ --output-script="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/install.sh"
+
+need_ok "failed to generate install script"
+
+mkdir -p "$CFG_OUTPUT_DIR"
+need_ok "couldn't create output dir"
+
+rm -Rf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz"
+need_ok "couldn't delete old tarball"
+
+# Make a tarball
+tar -czf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz" -C "$CFG_WORK_DIR" "$CFG_PACKAGE_NAME"
+need_ok "failed to tar"
diff --git a/test/rust-installer-v2/install-template.sh b/test/rust-installer-v2/install-template.sh
new file mode 100644
index 0000000..98d449a
--- /dev/null
+++ b/test/rust-installer-v2/install-template.sh
@@ -0,0 +1,743 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "install: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "install: WARNING: $1"
+}
+
+err() {
+ echo "install: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "install: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "install: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+absolutify() {
+ FILE_PATH="${1}"
+ FILE_PATH_DIRNAME="$(dirname ${FILE_PATH})"
+ FILE_PATH_BASENAME="$(basename ${FILE_PATH})"
+ FILE_ABS_PATH="$(cd ${FILE_PATH_DIRNAME} && pwd)"
+ FILE_PATH="${FILE_ABS_PATH}/${FILE_PATH_BASENAME}"
+ # This is the return value
+ ABSOLUTIFIED="${FILE_PATH}"
+}
+
+msg "looking for install programs"
+msg
+
+need_cmd mkdir
+need_cmd printf
+need_cmd cut
+need_cmd grep
+need_cmd uname
+need_cmd tr
+need_cmd sed
+need_cmd chmod
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+# Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
+# This logic is duplicated from configure in order to get the correct libdir
+# for Windows installs.
+CFG_OSTYPE=$(uname -s)
+
+case $CFG_OSTYPE in
+
+ Linux)
+ CFG_OSTYPE=unknown-linux-gnu
+ ;;
+
+ FreeBSD)
+ CFG_OSTYPE=unknown-freebsd
+ ;;
+
+ DragonFly)
+ CFG_OSTYPE=unknown-dragonfly
+ ;;
+
+ Darwin)
+ CFG_OSTYPE=apple-darwin
+ ;;
+
+ MINGW*)
+ # msys' `uname` does not print gcc configuration, but prints msys
+ # configuration. so we cannot believe `uname -m`:
+ # msys1 is always i686 and msys2 is always x86_64.
+ # instead, msys defines $MSYSTEM which is MINGW32 on i686 and
+ # MINGW64 on x86_64.
+ CFG_CPUTYPE=i686
+ CFG_OSTYPE=pc-windows-gnu
+ if [ "$MSYSTEM" = MINGW64 ]
+ then
+ CFG_CPUTYPE=x86_64
+ fi
+ ;;
+
+ MSYS*)
+ CFG_OSTYPE=pc-windows-gnu
+ ;;
+
+# Thad's Cygwin identifers below
+
+# Vista 32 bit
+ CYGWIN_NT-6.0)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=i686
+ ;;
+
+# Vista 64 bit
+ CYGWIN_NT-6.0-WOW64)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=x86_64
+ ;;
+
+# Win 7 32 bit
+ CYGWIN_NT-6.1)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=i686
+ ;;
+
+# Win 7 64 bit
+ CYGWIN_NT-6.1-WOW64)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=x86_64
+ ;;
+esac
+
+OPTIONS=""
+BOOL_OPTIONS=""
+VAL_OPTIONS=""
+
+if [ "$CFG_OSTYPE" = "pc-windows-gnu" ]
+then
+ CFG_LD_PATH_VAR=PATH
+ CFG_OLD_LD_PATH_VAR=$PATH
+elif [ "$CFG_OSTYPE" = "apple-darwin" ]
+then
+ CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH
+ CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH
+else
+ CFG_LD_PATH_VAR=LD_LIBRARY_PATH
+ CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH
+fi
+
+flag uninstall "only uninstall from the installation prefix"
+valopt destdir "" "set installation root"
+opt verify 1 "verify that the installed binaries run correctly"
+valopt prefix "/usr/local" "set installation prefix"
+# NB This isn't quite the same definition as in `configure`.
+# just using 'lib' instead of configure's CFG_LIBDIR_RELATIVE
+valopt libdir "${CFG_DESTDIR}${CFG_PREFIX}/lib" "install libraries"
+valopt mandir "${CFG_DESTDIR}${CFG_PREFIX}/share/man" "install man pages in PATH"
+opt ldconfig 1 "run ldconfig after installation (Linux only)"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+# Template configuration.
+# These names surrounded by '%%` are replaced by sed when generating install.sh
+# FIXME: Might want to consider loading this from a file and not generating install.sh
+
+# Rust or Cargo
+TEMPLATE_PRODUCT_NAME=%%TEMPLATE_PRODUCT_NAME%%
+# rustc or cargo
+TEMPLATE_VERIFY_BIN=%%TEMPLATE_VERIFY_BIN%%
+# rustlib or cargo
+TEMPLATE_REL_MANIFEST_DIR=%%TEMPLATE_REL_MANIFEST_DIR%%
+# 'Rust is ready to roll.' or 'Cargo is cool to cruise.'
+TEMPLATE_SUCCESS_MESSAGE=%%TEMPLATE_SUCCESS_MESSAGE%%
+# Locations to look for directories containing legacy, pre-versioned manifests
+TEMPLATE_LEGACY_MANIFEST_DIRS=%%TEMPLATE_LEGACY_MANIFEST_DIRS%%
+# The installer version
+TEMPLATE_RUST_INSTALLER_VERSION=%%TEMPLATE_RUST_INSTALLER_VERSION%%
+
+# OK, let's get installing ...
+
+# If we don't have a verify bin then disable verify
+if [ -z "$TEMPLATE_VERIFY_BIN" ]; then
+ CFG_DISABLE_VERIFY=1
+fi
+
+# Sanity check: can we run the binaries?
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ # Don't do this if uninstalling. Failure here won't help in any way.
+ if [ -z "${CFG_UNINSTALL}" ]
+ then
+ msg "verifying platform can run binaries"
+ export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib:$CFG_OLD_LD_PATH_VAR"
+ "${CFG_SRC_DIR}/bin/${TEMPLATE_VERIFY_BIN}" --version 2> /dev/null 1> /dev/null
+ if [ $? -ne 0 ]
+ then
+ err "can't execute binaries on this platform"
+ fi
+ export $CFG_LD_PATH_VAR="$CFG_OLD_LD_PATH_VAR"
+ fi
+fi
+
+# Sanity check: can we can write to the destination?
+msg "verifying destination is writable"
+umask 022 && mkdir -p "${CFG_LIBDIR}"
+need_ok "can't write to destination. consider \`sudo\`."
+touch "${CFG_LIBDIR}/rust-install-probe" > /dev/null
+if [ $? -ne 0 ]
+then
+ err "can't write to destination. consider \`sudo\`."
+fi
+rm -f "${CFG_LIBDIR}/rust-install-probe"
+need_ok "failed to remove install probe"
+
+# Sanity check: don't install to the directory containing the installer.
+# That would surely cause chaos.
+msg "verifying destination is not the same as source"
+INSTALLER_DIR="$(cd $(dirname $0) && pwd)"
+PREFIX_DIR="$(cd ${CFG_PREFIX} && pwd)"
+if [ "${INSTALLER_DIR}" = "${PREFIX_DIR}" ]
+then
+ err "can't install to same directory as installer"
+fi
+
+# Open the components file to get the list of components to install
+COMPONENTS=`cat "$CFG_SRC_DIR/components"`
+
+# Sanity check: do we have components?
+if [ ! -n "$COMPONENTS" ]; then
+ err "unable to find installation components"
+fi
+
+# Using an absolute path to libdir in a few places so that the status
+# messages are consistently using absolute paths.
+absolutify "${CFG_LIBDIR}"
+ABS_LIBDIR="${ABSOLUTIFIED}"
+
+# Replace commas in legacy manifest list with spaces
+LEGACY_MANIFEST_DIRS=`echo "$TEMPLATE_LEGACY_MANIFEST_DIRS" | sed "s/,/ /g"`
+
+# Uninstall from legacy manifests
+for md in $LEGACY_MANIFEST_DIRS; do
+ # First, uninstall from the installation prefix.
+ # Errors are warnings - try to rm everything in the manifest even if some fail.
+ if [ -f "$ABS_LIBDIR/$md/manifest" ]
+ then
+
+ # Iterate through installed manifest and remove files
+ while read p; do
+ # The installed manifest contains absolute paths
+ msg "removing legacy file $p"
+ if [ -f "$p" ]
+ then
+ rm -f "$p"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove $p"
+ fi
+ else
+ warn "supposedly installed file $p does not exist!"
+ fi
+ done < "$ABS_LIBDIR/$md/manifest"
+
+ # If we fail to remove $md below, then the
+ # installed manifest will still be full; the installed manifest
+ # needs to be empty before install.
+ msg "removing legacy manifest $ABS_LIBDIR/$md/manifest"
+ rm -f "$ABS_LIBDIR/$md/manifest"
+ # For the above reason, this is a hard error
+ need_ok "failed to remove installed manifest"
+
+ # Remove $TEMPLATE_REL_MANIFEST_DIR directory
+ msg "removing legacy manifest dir ${ABS_LIBDIR}/$md"
+ rm -Rf "${ABS_LIBDIR}/$md"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove $md"
+ fi
+
+ UNINSTALLED_SOMETHING=1
+ fi
+done
+
+# Load the version of the installed installer
+if [ -f "$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version" ]; then
+ INSTALLED_VERSION=`cat "$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version"`
+
+ # Sanity check
+ if [ ! -n "$INSTALLED_VERSION" ]; then err "rust installer version is empty"; fi
+fi
+
+# If there's something installed, then uninstall
+if [ -n "$INSTALLED_VERSION" ]; then
+ # Check the version of the installed installer
+ case "$INSTALLED_VERSION" in
+
+ # TODO: If this is a previous version, then upgrade in place to the
+ # current version before uninstalling. No need to do this yet because
+ # there is no prior version (only the legacy 'unversioned' installer
+ # which we've already dealt with).
+
+ # This is the current version. Nothing need to be done except uninstall.
+ "$TEMPLATE_RUST_INSTALLER_VERSION")
+ ;;
+
+ # TODO: If this is an unknown (future) version then bail.
+ *)
+ echo "The copy of $TEMPLATE_PRODUCT_NAME at $CFG_PREFIX was installed using an"
+ echo "unknown version ($INSTALLED_VERSION) of rust-installer."
+ echo "Uninstall it first with the installer used for the original installation"
+ echo "before continuing."
+ exit 1
+ ;;
+ esac
+
+ MD="$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR"
+ INSTALLED_COMPONENTS=`cat $MD/components`
+
+ # Uninstall (our components only) before reinstalling
+ for available_component in $COMPONENTS; do
+ for installed_component in $INSTALLED_COMPONENTS; do
+ if [ "$available_component" = "$installed_component" ]; then
+ COMPONENT_MANIFEST="$MD/manifest-$installed_component"
+
+ # Sanity check: there should be a component manifest
+ if [ ! -f "$COMPONENT_MANIFEST" ]; then
+ err "installed component '$installed_component' has no manifest"
+ fi
+
+ # Iterate through installed component manifest and remove files
+ while read directive; do
+
+ COMMAND=`echo $directive | cut -f1 -d:`
+ FILE=`echo $directive | cut -f2 -d:`
+
+ # Sanity checks
+ if [ ! -n "$COMMAND" ]; then err "malformed installation directive"; fi
+ if [ ! -n "$FILE" ]; then err "malformed installation directive"; fi
+
+ case "$COMMAND" in
+ file)
+ msg "removing file $FILE"
+ if [ -f "$FILE" ]; then
+ rm -f "$FILE"
+ if [ $? -ne 0 ]; then
+ warn "failed to remove $FILE"
+ fi
+ else
+ warn "supposedly installed file $FILE does not exist!"
+ fi
+ ;;
+
+ dir)
+ msg "removing directory $FILE"
+ rm -Rf "$FILE"
+ if [ $? -ne 0 ]; then
+ warn "unable to remove directory $FILE"
+ fi
+ ;;
+
+ *)
+ err "unknown installation directive"
+ ;;
+ esac
+
+ done < "$COMPONENT_MANIFEST"
+
+ # Remove the installed component manifest
+ msg "removing component manifest $COMPONENT_MANIFEST"
+ rm -f "$COMPONENT_MANIFEST"
+ # This is a hard error because the installation is unrecoverable
+ need_ok "failed to remove installed manifest for component '$installed_component'"
+
+ # Update the installed component list
+ MODIFIED_COMPONENTS=`sed /^$installed_component\$/d $MD/components`
+ echo "$MODIFIED_COMPONENTS" > "$MD/components"
+ need_ok "failed to update installed component list"
+ fi
+ done
+ done
+
+ # If there are no remaining components delete the manifest directory
+ REMAINING_COMPONENTS=`cat $MD/components`
+ if [ ! -n "$REMAINING_COMPONENTS" ]; then
+ msg "removing manifest directory $MD"
+ rm -Rf "$MD"
+ if [ $? -ne 0 ]; then
+ warn "failed to remove $MD"
+ fi
+ fi
+
+ UNINSTALLED_SOMETHING=1
+fi
+
+# There's no installed version. If we were asked to uninstall, then that's a problem.
+if [ -n "${CFG_UNINSTALL}" -a ! -n "$UNINSTALLED_SOMETHING" ]
+then
+ err "unable to find installation manifest at ${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+fi
+
+# If we're only uninstalling then exit
+if [ -n "${CFG_UNINSTALL}" ]
+then
+ echo
+ echo " ${TEMPLATE_PRODUCT_NAME} is uninstalled."
+ echo
+ exit 0
+fi
+
+# Create the directory to contain the manifests
+mkdir -p "${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+need_ok "failed to create ${TEMPLATE_REL_MANIFEST_DIR}"
+
+# Install each component
+for component in $COMPONENTS; do
+
+ # The file name of the manifest we're installing from
+ INPUT_MANIFEST="${CFG_SRC_DIR}/manifest-$component.in"
+
+ # The installed manifest directory
+ MD="$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR"
+
+ # The file name of the manifest we're going to create during install
+ INSTALLED_MANIFEST="$MD/manifest-$component"
+
+ # Create the installed manifest, which we will fill in with absolute file paths
+ touch "${INSTALLED_MANIFEST}"
+ need_ok "failed to create installed manifest"
+
+ # Sanity check: do we have our input manifests?
+ if [ ! -f "$INPUT_MANIFEST" ]; then
+ err "manifest for $component does not exist at $INPUT_MANIFEST"
+ fi
+
+ # Now install, iterate through the new manifest and copy files
+ while read directive; do
+
+ COMMAND=`echo $directive | cut -f1 -d:`
+ FILE=`echo $directive | cut -f2 -d:`
+
+ # Sanity checks
+ if [ ! -n "$COMMAND" ]; then err "malformed installation directive"; fi
+ if [ ! -n "$FILE" ]; then err "malformed installation directive"; fi
+
+ # Decide the destination of the file
+ FILE_INSTALL_PATH="${CFG_DESTDIR}${CFG_PREFIX}/$FILE"
+
+ if echo "$FILE" | grep "^lib/" > /dev/null
+ then
+ f=`echo $FILE | sed 's/^lib\///'`
+ FILE_INSTALL_PATH="${CFG_LIBDIR}/$f"
+ fi
+
+ if echo "$FILE" | grep "^share/man/" > /dev/null
+ then
+ f=`echo $FILE | sed 's/^share\/man\///'`
+ FILE_INSTALL_PATH="${CFG_MANDIR}/$f"
+ fi
+
+ # Make sure there's a directory for it
+ umask 022 && mkdir -p "$(dirname ${FILE_INSTALL_PATH})"
+ need_ok "directory creation failed"
+
+ # Make the path absolute so we can uninstall it later without
+ # starting from the installation cwd
+ absolutify "${FILE_INSTALL_PATH}"
+ FILE_INSTALL_PATH="${ABSOLUTIFIED}"
+
+ case "$COMMAND" in
+ file)
+
+ # Install the file
+ msg "copying file $FILE_INSTALL_PATH"
+ if echo "$FILE" | grep "^bin/" > /dev/null
+ then
+ install -m755 "${CFG_SRC_DIR}/$FILE" "${FILE_INSTALL_PATH}"
+ else
+ install -m644 "${CFG_SRC_DIR}/$FILE" "${FILE_INSTALL_PATH}"
+ fi
+ need_ok "file creation failed"
+
+ # Update the manifest
+ echo "file:${FILE_INSTALL_PATH}" >> "${INSTALLED_MANIFEST}"
+ need_ok "failed to update manifest"
+
+ ;;
+
+ dir)
+
+ # Copy the dir
+ msg "copying directory $FILE_INSTALL_PATH"
+
+ # Sanity check: bulk dirs are supposed to be uniquely ours and should not exist
+ if [ -e "$FILE_INSTALL_PATH" ]; then
+ err "$FILE_INSTALL_PATH already exists"
+ fi
+
+ cp -R "$CFG_SRC_DIR/$FILE" "$FILE_INSTALL_PATH"
+ need_ok "failed to copy directory"
+
+ # Set permissions. 0755 for dirs, 644 for files
+ chmod -R u+rwX,go+rX,go-w "$FILE_INSTALL_PATH"
+ need_ok "failed to set permissions on directory"
+
+ # Update the manifest
+ echo "dir:$FILE_INSTALL_PATH" >> "$INSTALLED_MANIFEST"
+ need_ok "failed to update manifest"
+ ;;
+
+ *)
+ err "unknown installation directive"
+ ;;
+ esac
+ done < "$INPUT_MANIFEST"
+
+ # Update the components
+ echo "$component" >> "$MD/components"
+ need_ok "failed to update components list for $component"
+
+done
+
+# Drop the version number into the manifest dir
+echo "$TEMPLATE_RUST_INSTALLER_VERSION" > "${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}/rust-installer-version"
+
+# Run ldconfig to make dynamic libraries available to the linker
+if [ "$CFG_OSTYPE" = "unknown-linux-gnu" -a ! -n "$CFG_DISABLE_LDCONFIG" ]; then
+ msg "running ldconfig"
+ ldconfig
+ if [ $? -ne 0 ]
+ then
+ warn "failed to run ldconfig."
+ warn "this may happen when not installing as root and may be fine"
+ fi
+fi
+
+# Sanity check: can we run the installed binaries?
+#
+# As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
+# is in place. Try first without this variable, and if that fails try again with
+# the variable. If the second time tries, print a hopefully helpful message to
+# add something to the appropriate environment variable.
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib:$CFG_OLD_LD_PATH_VAR"
+ "${CFG_PREFIX}/bin/${TEMPLATE_VERIFY_BIN}" --version > /dev/null
+ if [ $? -ne 0 ]
+ then
+ ERR="can't execute installed binaries. "
+ ERR="${ERR}installation may be broken. "
+ ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
+ ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
+ err "${ERR}"
+ else
+ echo
+ echo " Note: please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
+ fi
+fi
+
+echo
+echo " ${TEMPLATE_SUCCESS_MESSAGE}"
+echo
+
+
diff --git a/test/rust-installer-v2/rust-installer-version b/test/rust-installer-v2/rust-installer-version
new file mode 100644
index 0000000..d8263ee
--- /dev/null
+++ b/test/rust-installer-v2/rust-installer-version
@@ -0,0 +1 @@
+2 \ No newline at end of file
diff --git a/test/rust-installer-v2/test.sh b/test/rust-installer-v2/test.sh
new file mode 100755
index 0000000..87dcdcb
--- /dev/null
+++ b/test/rust-installer-v2/test.sh
@@ -0,0 +1,588 @@
+#!/bin/sh
+
+S="$(cd $(dirname $0) && pwd)"
+
+TEST_DIR="$S/test"
+TMP_DIR="$S/tmp"
+WORK_DIR="$TMP_DIR/workdir"
+OUT_DIR="$TMP_DIR/outdir"
+PREFIX_DIR="$TMP_DIR/prefix"
+
+case $(uname -s) in
+
+ MINGW* | MSYS*)
+ WINDOWS=1
+ ;;
+esac
+
+pre() {
+ echo
+ echo "test: $1"
+ echo
+ rm -Rf "$WORK_DIR"
+ rm -Rf "$OUT_DIR"
+ rm -Rf "$PREFIX_DIR"
+ mkdir -p "$WORK_DIR"
+ mkdir -p "$OUT_DIR"
+ mkdir -p "$PREFIX_DIR"
+}
+
+post() {
+ rm -Rf "$WORK_DIR"
+ rm -Rf "$OUT_DIR"
+ rm -Rf "$PREFIX_DIR"
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ echo
+ echo "TEST FAILED!"
+ echo
+ exit 1
+ fi
+}
+
+try() {
+ cmd="$@"
+ echo \$ "$cmd"
+ OUTPUT=`$@`
+ if [ $? -ne 0 ]; then
+ echo
+ # Using /bin/echo to avoid escaping
+ /bin/echo "$OUTPUT"
+ echo
+ echo "TEST FAILED!"
+ echo
+ exit 1
+ fi
+}
+
+expect_fail() {
+ cmd="$@"
+ echo \$ "$cmd"
+ OUTPUT=`$@`
+ if [ $? -eq 0 ]; then
+ echo
+ # Using /bin/echo to avoid escaping
+ /bin/echo "$OUTPUT"
+ echo
+ echo "TEST FAILED!"
+ echo
+ exit 1
+ fi
+}
+
+# Installation tests
+
+pre "basic install"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+post
+
+pre "basic uninstall"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try "$WORK_DIR/package/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try test ! -e "$PREFIX_DIR/lib/packagelib"
+post
+
+pre "not installed files"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --non-installed-prefixes=something-to-not-install,dir-to-not-install
+try test -e "$WORK_DIR/package/something-to-not-install"
+try test -e "$WORK_DIR/package/dir-to-not-install"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-not-install"
+try test ! -e "$PREFIX_DIR/dir-to-not-install"
+post
+
+pre "verify override"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --verify-bin=program2
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+post
+
+pre "tarball with package name"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rustc-nightly
+try "$WORK_DIR/rustc-nightly/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$OUT_DIR/rustc-nightly.tar.gz"
+post
+
+pre "bulk directory"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --bulk-dirs=dir-to-install
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR" --uninstall
+try test ! -e "$PREFIX_DIR/dir-to-install"
+post
+
+pre "nested bulk directory"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image4" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --bulk-dirs=dir-to-install/qux
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/dir-to-install/qux/bar"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR" --uninstall
+try test ! -e "$PREFIX_DIR/dir-to-install/qux"
+post
+
+pre "only bulk directory, no files"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image5" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --bulk-dirs=dir-to-install
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR" --uninstall
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+post
+
+pre "nested not installed files"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image4" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --non-installed-prefixes=dir-to-install/qux/bar
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/dir-to-install/qux/bar"
+post
+
+# Upgrade tests
+
+pre "upgrade v1 -> v2"
+mkdir "$WORK_DIR/v1"
+try sh "$S/test/rust-installer-v1/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image2" \
+ --work-dir="$WORK_DIR/v1" \
+ --output-dir="$OUT_DIR/v1" \
+ --verify-bin=oldprogram \
+ --rel-manifest-dir=packagelib
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --rel-manifest-dir=packagelib \
+ --legacy-manifest-dirs=packagelib
+try "$WORK_DIR/v1/package/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/bar"
+try test -e "$PREFIX_DIR/bin/oldprogram"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/dir-to-install/bar"
+try test ! -e "$PREFIX_DIR/bin/oldprogram"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try "$WORK_DIR/package/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try test ! -e "$PREFIX_DIR/lib/packagelib"
+post
+
+pre "upgrade v1 -> v2 with multiple legacy manifests"
+mkdir "$WORK_DIR/v1"
+try sh "$S/test/rust-installer-v1/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image2" \
+ --work-dir="$WORK_DIR/v1" \
+ --output-dir="$OUT_DIR/v1" \
+ --verify-bin=oldprogram \
+ --rel-manifest-dir=rustlib
+try sh "$S/test/rust-installer-v1/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR/v1b" \
+ --output-dir="$OUT_DIR/v1b" \
+ --verify-bin=cargo \
+ --rel-manifest-dir=cargo
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --rel-manifest-dir=packagelib \
+ --legacy-manifest-dirs=rustlib,cargo
+try "$WORK_DIR/v1/package/install.sh" --prefix="$PREFIX_DIR"
+try "$WORK_DIR/v1b/package/install.sh" --prefix="$PREFIX_DIR"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/dir-to-install/bar"
+try test ! -e "$PREFIX_DIR/bin/oldprogram"
+try test ! -e "$PREFIX_DIR/bin/cargo"
+try test ! -e "$PREFIX_DIR/lib/cargo"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try "$WORK_DIR/package/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try test ! -e "$PREFIX_DIR/lib/packagelib"
+post
+
+pre "multiple components"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR/c1" \
+ --output-dir="$OUT_DIR/c1" \
+ --component-name=rustc
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR/c2" \
+ --output-dir="$OUT_DIR/c2" \
+ --verify-bin=cargo \
+ --component-name=cargo
+try "$WORK_DIR/c1/package/install.sh" --prefix="$PREFIX_DIR"
+try "$WORK_DIR/c2/package/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try test -e "$PREFIX_DIR/bin/cargo"
+try "$WORK_DIR/c1/package/install.sh" --prefix="$PREFIX_DIR" --uninstall
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try "$WORK_DIR/c2/package/install.sh" --prefix="$PREFIX_DIR" --uninstall
+try test ! -e "$PREFIX_DIR/bin/cargo"
+try test ! -e "$PREFIX_DIR/lib/packagelib"
+post
+
+# Combined installer tests
+
+pre "combine installers"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rustc \
+ --component-name=rustc
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --verify-bin=cargo \
+ --package-name=cargo \
+ --component-name=cargo
+try sh "$S/combine-installers.sh" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rust \
+ --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz"
+try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try test -e "$PREFIX_DIR/bin/cargo"
+try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try test ! -e "$PREFIX_DIR/bin/cargo"
+try test ! -e "$PREFIX_DIR/lib/packagelib"
+post
+
+pre "combine three installers"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rustc \
+ --component-name=rustc
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --verify-bin=cargo \
+ --package-name=cargo \
+ --component-name=cargo
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image4" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rust-docs \
+ --component-name=rust-docs
+try sh "$S/combine-installers.sh" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rust \
+ --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz,$OUT_DIR/rust-docs.tar.gz"
+try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try test -e "$PREFIX_DIR/bin/cargo"
+try test -e "$PREFIX_DIR/dir-to-install/qux/bar"
+try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try test ! -e "$PREFIX_DIR/bin/cargo"
+try test ! -e "$PREFIX_DIR/lib/packagelib"
+try test ! -e "$PREFIX_DIR/dir-to-install/qux/bar"
+post
+
+pre "combine installers with overlay"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rustc \
+ --component-name=rustc
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --verify-bin=cargo \
+ --package-name=cargo \
+ --component-name=cargo
+mkdir -p "$WORK_DIR/overlay"
+touch "$WORK_DIR/overlay/README"
+try sh "$S/combine-installers.sh" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rust \
+ --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz" \
+ --non-installed-overlay="$WORK_DIR/overlay"
+try test -e "$WORK_DIR/rust/README"
+try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/README"
+post
+
+pre "combined with bulk dirs"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rustc \
+ --component-name=rustc \
+ --bulk-dirs=dir-to-install
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --verify-bin=cargo \
+ --package-name=cargo \
+ --component-name=cargo
+try sh "$S/combine-installers.sh" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rust \
+ --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz"
+try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/dir-to-install"
+post
+
+pre "combine install with separate uninstall"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rustc \
+ --component-name=rustc \
+ --rel-manifest-dir=rustlib
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --verify-bin=cargo \
+ --package-name=cargo \
+ --component-name=cargo \
+ --rel-manifest-dir=rustlib
+try sh "$S/combine-installers.sh" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rust \
+ --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz" \
+ --rel-manifest-dir=rustlib
+try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try test -e "$PREFIX_DIR/bin/cargo"
+try "$WORK_DIR/rustc/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try "$WORK_DIR/cargo/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/bin/cargo"
+try test ! -e "$PREFIX_DIR/lib/packagelib"
+post
+
+pre "combined v1 -> v2 upgrade"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rustc \
+ --component-name=rustc \
+ --rel-manifest-dir=rustlib
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --verify-bin=cargo \
+ --package-name=cargo \
+ --component-name=cargo \
+ --rel-manifest-dir=rustlib
+try sh "$S/combine-installers.sh" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=rust \
+ --input-tarballs="$OUT_DIR/rustc.tar.gz,$OUT_DIR/cargo.tar.gz" \
+ --rel-manifest-dir=rustlib \
+ --legacy-manifest-dirs=cargo,rustlib
+try sh "$S/test/rust-installer-v1/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image2" \
+ --work-dir="$WORK_DIR/v1" \
+ --output-dir="$OUT_DIR/v1" \
+ --verify-bin=oldprogram \
+ --rel-manifest-dir=rustlib
+try sh "$S/test/rust-installer-v1/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image3" \
+ --work-dir="$WORK_DIR/v1b" \
+ --output-dir="$OUT_DIR/v1b" \
+ --verify-bin=cargo \
+ --rel-manifest-dir=cargo
+try "$WORK_DIR/v1/package//install.sh" --prefix="$PREFIX_DIR"
+try "$WORK_DIR/v1b/package//install.sh" --prefix="$PREFIX_DIR"
+try "$WORK_DIR/rust/install.sh" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/dir-to-install/bar"
+try test ! -e "$PREFIX_DIR/bin/oldprogram"
+try test ! -e "$PREFIX_DIR/lib/cargo"
+try test -e "$PREFIX_DIR/something-to-install"
+try test -e "$PREFIX_DIR/dir-to-install/foo"
+try test -e "$PREFIX_DIR/bin/program"
+try test -e "$PREFIX_DIR/bin/program2"
+try test -e "$PREFIX_DIR/bin/bad-bin"
+try test -e "$PREFIX_DIR/bin/cargo"
+try test -e "$PREFIX_DIR/lib/rustlib"
+try "$WORK_DIR/rust/install.sh --uninstall" --prefix="$PREFIX_DIR"
+try test ! -e "$PREFIX_DIR/something-to-install"
+try test ! -e "$PREFIX_DIR/dir-to-install/foo"
+try test ! -e "$PREFIX_DIR/bin/program"
+try test ! -e "$PREFIX_DIR/bin/program2"
+try test ! -e "$PREFIX_DIR/bin/bad-bin"
+try test ! -e "$PREFIX_DIR/bin/cargo"
+try test ! -e "$PREFIX_DIR/lib/rustlib"
+post
+
+# Smoke tests
+
+pre "can't run bins error"
+try sh "$S/gen-installer.sh" \
+ --verify-bin=bad-bin \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR"
+expect_fail "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+post
+
+if [ ! -n "$WINDOWS" ]; then
+ # chmod doesn't work on windows
+ pre "can't write error"
+ try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR"
+ chmod u-w "$PREFIX_DIR"
+ expect_fail "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+ chmod u+w "$PREFIX_DIR"
+ post
+fi
+
+pre "can't install to installer"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --package-name=my-package
+expect_fail "$WORK_DIR/my-package/install.sh" --prefix="$WORK_DIR/my-package"
+post
+
+pre "upgrade from future installer error"
+try sh "$S/gen-installer.sh" \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR" \
+ --rel-manifest-dir=rustlib
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+echo 100 > "$PREFIX_DIR/lib/rustlib/rust-installer-version"
+expect_fail "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR"
+post
+
+pre "disable-verify"
+try sh "$S/gen-installer.sh" \
+ --verify-bin=bad-bin \
+ --image-dir="$TEST_DIR/image1" \
+ --work-dir="$WORK_DIR" \
+ --output-dir="$OUT_DIR"
+try "$WORK_DIR/package/install.sh" --prefix="$PREFIX_DIR" --disable-verify
+post
+
+# TODO: DESTDIR
+# TODO: mandir/libdir/bindir, etc.
+
+echo
+echo "TOTAL SUCCESS!"
+echo
diff --git a/test/rust-installer-v2/test/image1/bin/bad-bin b/test/rust-installer-v2/test/image1/bin/bad-bin
new file mode 100644
index 0000000..b5b0e32
--- /dev/null
+++ b/test/rust-installer-v2/test/image1/bin/bad-bin
@@ -0,0 +1 @@
+#!/bin/bogus \ No newline at end of file
diff --git a/test/rust-installer-v2/test/image1/bin/program b/test/rust-installer-v2/test/image1/bin/program
new file mode 100755
index 0000000..96b4b06
--- /dev/null
+++ b/test/rust-installer-v2/test/image1/bin/program
@@ -0,0 +1 @@
+#!/bin/sh \ No newline at end of file
diff --git a/test/rust-installer-v2/test/image1/bin/program2 b/test/rust-installer-v2/test/image1/bin/program2
new file mode 100755
index 0000000..96b4b06
--- /dev/null
+++ b/test/rust-installer-v2/test/image1/bin/program2
@@ -0,0 +1 @@
+#!/bin/sh \ No newline at end of file
diff --git a/test/rust-installer-v2/test/image1/dir-to-install/foo b/test/rust-installer-v2/test/image1/dir-to-install/foo
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image1/dir-to-install/foo
diff --git a/test/rust-installer-v2/test/image1/dir-to-not-install/foo b/test/rust-installer-v2/test/image1/dir-to-not-install/foo
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image1/dir-to-not-install/foo
diff --git a/test/rust-installer-v2/test/image1/something-to-install b/test/rust-installer-v2/test/image1/something-to-install
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image1/something-to-install
diff --git a/test/rust-installer-v2/test/image1/something-to-not-install b/test/rust-installer-v2/test/image1/something-to-not-install
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image1/something-to-not-install
diff --git a/test/rust-installer-v2/test/image2/bin/oldprogram b/test/rust-installer-v2/test/image2/bin/oldprogram
new file mode 100755
index 0000000..96b4b06
--- /dev/null
+++ b/test/rust-installer-v2/test/image2/bin/oldprogram
@@ -0,0 +1 @@
+#!/bin/sh \ No newline at end of file
diff --git a/test/rust-installer-v2/test/image2/dir-to-install/bar b/test/rust-installer-v2/test/image2/dir-to-install/bar
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image2/dir-to-install/bar
diff --git a/test/rust-installer-v2/test/image2/something-to-install b/test/rust-installer-v2/test/image2/something-to-install
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image2/something-to-install
diff --git a/test/rust-installer-v2/test/image3/bin/cargo b/test/rust-installer-v2/test/image3/bin/cargo
new file mode 100755
index 0000000..96b4b06
--- /dev/null
+++ b/test/rust-installer-v2/test/image3/bin/cargo
@@ -0,0 +1 @@
+#!/bin/sh \ No newline at end of file
diff --git a/test/rust-installer-v2/test/image4/baz b/test/rust-installer-v2/test/image4/baz
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image4/baz
diff --git a/test/rust-installer-v2/test/image4/dir-to-install/qux/bar b/test/rust-installer-v2/test/image4/dir-to-install/qux/bar
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image4/dir-to-install/qux/bar
diff --git a/test/rust-installer-v2/test/image5/dir-to-install/foo b/test/rust-installer-v2/test/image5/dir-to-install/foo
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/rust-installer-v2/test/image5/dir-to-install/foo
diff --git a/test/rust-installer-v2/test/rust-installer-v1/.gitignore b/test/rust-installer-v2/test/rust-installer-v1/.gitignore
new file mode 100644
index 0000000..e4e5f6c
--- /dev/null
+++ b/test/rust-installer-v2/test/rust-installer-v1/.gitignore
@@ -0,0 +1 @@
+*~ \ No newline at end of file
diff --git a/test/rust-installer-v2/test/rust-installer-v1/README.md b/test/rust-installer-v2/test/rust-installer-v1/README.md
new file mode 100644
index 0000000..f541504
--- /dev/null
+++ b/test/rust-installer-v2/test/rust-installer-v1/README.md
@@ -0,0 +1,30 @@
+A generator for the install.sh script commonly used to install Rust in
+Unix environments. It is used By Rust, Cargo, and is intended to be
+used by a future combined installer of Rust + Cargo.
+
+# Usage
+
+```
+./gen-installer.sh --product-name=Rust \
+ --verify-bin=rustc \
+ --rel-manifest-dir=rustlib \
+ --success-message=Rust-is-ready-to-roll. \
+ --image-dir=./install-image \
+ --work-dir=./temp \
+ --output-dir=./dist \
+ --non-installed-prefixes="foo,bin/bar,lib/baz" \
+ --package-name=rustc-nightly-i686-apple-darwin
+```
+
+Or, to just generate the script.
+
+```
+./gen-install-script.sh --product-name=Rust \
+ --verify-bin=rustc \
+ --rel-manifest-dir=rustlib \
+ --success-message=Rust-is-ready-to-roll. \
+ --output-script=install.sh
+```
+
+*Note: the dashes in `success-message` are converted to spaces. The
+script's argument handling is broken with spaces.* \ No newline at end of file
diff --git a/test/rust-installer-v2/test/rust-installer-v1/gen-install-script.sh b/test/rust-installer-v2/test/rust-installer-v1/gen-install-script.sh
new file mode 100755
index 0000000..4c7e327
--- /dev/null
+++ b/test/rust-installer-v2/test/rust-installer-v1/gen-install-script.sh
@@ -0,0 +1,253 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "gen-install-script: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "gen-install-script: WARNING: $1"
+}
+
+err() {
+ echo "gen-install-script: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "gen-install-script: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "gen-install-script: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+msg "looking for install programs"
+msg
+
+need_cmd sed
+need_cmd chmod
+need_cmd cat
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+valopt product-name "Product" "The name of the product, for display"
+valopt verify-bin "program" "The command to run with --version to verify the install works"
+valopt rel-manifest-dir "${CFG_VERIFY_BIN}lib" "The directory under lib/ where the manifest lives"
+valopt success-message "Installed." "The string to print after successful installation"
+valopt output-script "${CFG_SRC_DIR}/install.sh" "The name of the output script"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+# Replace dashes in the success message with spaces (our arg handling botches spaces)
+CFG_SUCCESS_MESSAGE=`echo "$CFG_SUCCESS_MESSAGE" | sed "s/-/ /g"`
+
+SCRIPT_TEMPLATE=`cat "${CFG_SRC_DIR}/install-template.sh"`
+
+# Using /bin/echo because under sh emulation dash *seems* to escape \n, which screws up the template
+SCRIPT=`/bin/echo "${SCRIPT_TEMPLATE}"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_PRODUCT_NAME%%/${CFG_PRODUCT_NAME}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_VERIFY_BIN%%/${CFG_VERIFY_BIN}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_REL_MANIFEST_DIR%%/${CFG_REL_MANIFEST_DIR}/"`
+SCRIPT=`/bin/echo "${SCRIPT}" | sed "s/%%TEMPLATE_SUCCESS_MESSAGE%%/\"${CFG_SUCCESS_MESSAGE}\"/"`
+
+/bin/echo "${SCRIPT}" > "${CFG_OUTPUT_SCRIPT}"
+need_ok "couldn't write script"
+chmod u+x "${CFG_OUTPUT_SCRIPT}"
+need_ok "couldn't chmod script"
diff --git a/test/rust-installer-v2/test/rust-installer-v1/gen-installer.sh b/test/rust-installer-v2/test/rust-installer-v1/gen-installer.sh
new file mode 100755
index 0000000..c88eebe
--- /dev/null
+++ b/test/rust-installer-v2/test/rust-installer-v1/gen-installer.sh
@@ -0,0 +1,303 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "gen-installer: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "gen-installer: WARNING: $1"
+}
+
+err() {
+ echo "gen-installer: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "gen-installer: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "gen-installer: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+msg "looking for programs"
+msg
+
+need_cmd tar
+need_cmd cp
+need_cmd rm
+need_cmd mkdir
+need_cmd echo
+need_cmd tr
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+valopt product-name "Product" "The name of the product, for display"
+valopt package-name "package" "The name of the package, tarball"
+valopt verify-bin "program" "The command to run with --version to verify the install works"
+valopt rel-manifest-dir "${CFG_VERIFY_BIN}lib" "The directory under lib/ where the manifest lives"
+valopt success-message "Installed." "The string to print after successful installation"
+valopt non-installed-prefixes "" "Path prefixes that should be included but not installed"
+valopt image-dir "./install-image" "The directory containing the installation medium"
+valopt work-dir "./workdir" "The directory to do temporary work"
+valopt output-dir "./dist" "The location to put the final image and tarball"
+opt tarball 1 "Disable tarball generation, leaving output in the temp dir"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+GEN_INSTALL_SCRIPT="$CFG_SRC_DIR/gen-install-script.sh"
+
+if [ ! -d "$CFG_IMAGE_DIR" ]
+then
+ err "image dir $CFG_IMAGE_DIR does not exist"
+fi
+
+mkdir -p "$CFG_WORK_DIR"
+need_ok "couldn't create work dir"
+
+rm -Rf "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't delete work package dir"
+
+mkdir -p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't create work package dir"
+
+cp -r "$CFG_IMAGE_DIR/"* "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
+need_ok "couldn't copy source image"
+
+# Split non_installed_files into lines for later iteration
+NON_INSTALLED_PREFIXES=`echo "$CFG_NON_INSTALLED_PREFIXES" | tr "," "\n"`
+
+# Create the manifest
+MANIFEST=`(cd "$CFG_WORK_DIR/$CFG_PACKAGE_NAME" && find . -type f | sed 's/^\.\///') | sort`
+
+# Remove non-installed files from manifest
+NON_INSTALLED_PREFIXES=`echo "$CFG_NON_INSTALLED_PREFIXES" | tr "," " "`
+for prefix in $NON_INSTALLED_PREFIXES; do
+ MANIFEST=`echo "$MANIFEST" | sed /^$prefix/d`
+done
+
+MANIFEST_NAME="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/lib/$CFG_REL_MANIFEST_DIR/manifest.in"
+
+mkdir -p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/lib/$CFG_REL_MANIFEST_DIR"
+need_ok "couldn't create manifest dir"
+
+# Write the manifest
+echo "$MANIFEST" > "$MANIFEST_NAME"
+
+# Generate the install script
+"$CFG_SRC_DIR/gen-install-script.sh" \
+ --product-name="$CFG_PRODUCT_NAME" \
+ --verify-bin="$CFG_VERIFY_BIN" \
+ --rel-manifest-dir="$CFG_REL_MANIFEST_DIR" \
+ --success-message="$CFG_SUCCESS_MESSAGE" \
+ --output-script="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/install.sh"
+
+need_ok "failed to generate install script"
+
+mkdir -p "$CFG_OUTPUT_DIR"
+need_ok "couldn't create output dir"
+
+rm -Rf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz"
+need_ok "couldn't delete old tarball"
+
+# Make a tarball
+tar -czf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz" -C "$CFG_WORK_DIR" "$CFG_PACKAGE_NAME"
+need_ok "failed to tar"
diff --git a/test/rust-installer-v2/test/rust-installer-v1/install-template.sh b/test/rust-installer-v2/test/rust-installer-v1/install-template.sh
new file mode 100644
index 0000000..545de67
--- /dev/null
+++ b/test/rust-installer-v2/test/rust-installer-v1/install-template.sh
@@ -0,0 +1,554 @@
+#!/bin/sh
+# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+msg() {
+ echo "install: $1"
+}
+
+step_msg() {
+ msg
+ msg "$1"
+ msg
+}
+
+warn() {
+ echo "install: WARNING: $1"
+}
+
+err() {
+ echo "install: error: $1"
+ exit 1
+}
+
+need_ok() {
+ if [ $? -ne 0 ]
+ then
+ err "$1"
+ fi
+}
+
+need_cmd() {
+ if command -v $1 >/dev/null 2>&1
+ then msg "found $1"
+ else err "need $1"
+ fi
+}
+
+putvar() {
+ local T
+ eval T=\$$1
+ eval TLEN=\${#$1}
+ if [ $TLEN -gt 35 ]
+ then
+ printf "install: %-20s := %.35s ...\n" $1 "$T"
+ else
+ printf "install: %-20s := %s %s\n" $1 "$T" "$2"
+ fi
+}
+
+valopt() {
+ VAL_OPTIONS="$VAL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ if [ $HELP -eq 0 ]
+ then
+ local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
+ local V="CFG_${UOP}"
+ eval $V="$DEFAULT"
+ for arg in $CFG_ARGS
+ do
+ if echo "$arg" | grep -q -- "--$OP="
+ then
+ val=$(echo "$arg" | cut -f2 -d=)
+ eval $V=$val
+ fi
+ done
+ putvar $V
+ else
+ if [ -z "$DEFAULT" ]
+ then
+ DEFAULT="<none>"
+ fi
+ OP="${OP}=[${DEFAULT}]"
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+opt() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ local DEFAULT=$2
+ shift
+ shift
+ local DOC="$*"
+ local FLAG=""
+
+ if [ $DEFAULT -eq 0 ]
+ then
+ FLAG="enable"
+ else
+ FLAG="disable"
+ DOC="don't $DOC"
+ fi
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${FLAG}-${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
+ local V="CFG_${FLAG}_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
+ fi
+}
+
+flag() {
+ BOOL_OPTIONS="$BOOL_OPTIONS $1"
+
+ local OP=$1
+ shift
+ local DOC="$*"
+
+ if [ $HELP -eq 0 ]
+ then
+ for arg in $CFG_ARGS
+ do
+ if [ "$arg" = "--${OP}" ]
+ then
+ OP=$(echo $OP | tr 'a-z-' 'A-Z_')
+ local V="CFG_${OP}"
+ eval $V=1
+ putvar $V
+ fi
+ done
+ else
+ if [ ! -z "$META" ]
+ then
+ OP="$OP=<$META>"
+ fi
+ printf " --%-30s %s\n" "$OP" "$DOC"
+ fi
+}
+
+validate_opt () {
+ for arg in $CFG_ARGS
+ do
+ isArgValid=0
+ for option in $BOOL_OPTIONS
+ do
+ if test --disable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --enable-$option = $arg
+ then
+ isArgValid=1
+ fi
+ if test --$option = $arg
+ then
+ isArgValid=1
+ fi
+ done
+ for option in $VAL_OPTIONS
+ do
+ if echo "$arg" | grep -q -- "--$option="
+ then
+ isArgValid=1
+ fi
+ done
+ if [ "$arg" = "--help" ]
+ then
+ echo
+ echo "No more help available for Configure options,"
+ echo "check the Wiki or join our IRC channel"
+ break
+ else
+ if test $isArgValid -eq 0
+ then
+ err "Option '$arg' is not recognized"
+ fi
+ fi
+ done
+}
+
+absolutify() {
+ FILE_PATH="${1}"
+ FILE_PATH_DIRNAME="$(dirname ${FILE_PATH})"
+ FILE_PATH_BASENAME="$(basename ${FILE_PATH})"
+ FILE_ABS_PATH="$(cd ${FILE_PATH_DIRNAME} && pwd)"
+ FILE_PATH="${FILE_ABS_PATH}/${FILE_PATH_BASENAME}"
+ # This is the return value
+ ABSOLUTIFIED="${FILE_PATH}"
+}
+
+msg "looking for install programs"
+msg
+
+need_cmd mkdir
+need_cmd printf
+need_cmd cut
+need_cmd grep
+need_cmd uname
+need_cmd tr
+need_cmd sed
+
+CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
+CFG_SELF="$0"
+CFG_ARGS="$@"
+
+HELP=0
+if [ "$1" = "--help" ]
+then
+ HELP=1
+ shift
+ echo
+ echo "Usage: $CFG_SELF [options]"
+ echo
+ echo "Options:"
+ echo
+else
+ step_msg "processing $CFG_SELF args"
+fi
+
+# Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
+# This logic is duplicated from configure in order to get the correct libdir
+# for Windows installs.
+CFG_OSTYPE=$(uname -s)
+
+case $CFG_OSTYPE in
+
+ Linux)
+ CFG_OSTYPE=unknown-linux-gnu
+ ;;
+
+ FreeBSD)
+ CFG_OSTYPE=unknown-freebsd
+ ;;
+
+ DragonFly)
+ CFG_OSTYPE=unknown-dragonfly
+ ;;
+
+ Darwin)
+ CFG_OSTYPE=apple-darwin
+ ;;
+
+ MINGW*)
+ # msys' `uname` does not print gcc configuration, but prints msys
+ # configuration. so we cannot believe `uname -m`:
+ # msys1 is always i686 and msys2 is always x86_64.
+ # instead, msys defines $MSYSTEM which is MINGW32 on i686 and
+ # MINGW64 on x86_64.
+ CFG_CPUTYPE=i686
+ CFG_OSTYPE=pc-windows-gnu
+ if [ "$MSYSTEM" = MINGW64 ]
+ then
+ CFG_CPUTYPE=x86_64
+ fi
+ ;;
+
+ MSYS*)
+ CFG_OSTYPE=pc-windows-gnu
+ ;;
+
+# Thad's Cygwin identifers below
+
+# Vista 32 bit
+ CYGWIN_NT-6.0)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=i686
+ ;;
+
+# Vista 64 bit
+ CYGWIN_NT-6.0-WOW64)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=x86_64
+ ;;
+
+# Win 7 32 bit
+ CYGWIN_NT-6.1)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=i686
+ ;;
+
+# Win 7 64 bit
+ CYGWIN_NT-6.1-WOW64)
+ CFG_OSTYPE=pc-windows-gnu
+ CFG_CPUTYPE=x86_64
+ ;;
+esac
+
+OPTIONS=""
+BOOL_OPTIONS=""
+VAL_OPTIONS=""
+
+if [ "$CFG_OSTYPE" = "pc-windows-gnu" ]
+then
+ CFG_LD_PATH_VAR=PATH
+ CFG_OLD_LD_PATH_VAR=$PATH
+elif [ "$CFG_OSTYPE" = "apple-darwin" ]
+then
+ CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH
+ CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH
+else
+ CFG_LD_PATH_VAR=LD_LIBRARY_PATH
+ CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH
+fi
+
+flag uninstall "only uninstall from the installation prefix"
+valopt destdir "" "set installation root"
+opt verify 1 "verify that the installed binaries run correctly"
+valopt prefix "/usr/local" "set installation prefix"
+# NB This isn't quite the same definition as in `configure`.
+# just using 'lib' instead of configure's CFG_LIBDIR_RELATIVE
+valopt libdir "${CFG_DESTDIR}${CFG_PREFIX}/lib" "install libraries"
+valopt mandir "${CFG_DESTDIR}${CFG_PREFIX}/share/man" "install man pages in PATH"
+
+if [ $HELP -eq 1 ]
+then
+ echo
+ exit 0
+fi
+
+step_msg "validating $CFG_SELF args"
+validate_opt
+
+
+
+# Template configuration.
+# These names surrounded by '%%` are replaced by sed when generating install.sh
+
+# Rust or Cargo
+TEMPLATE_PRODUCT_NAME=%%TEMPLATE_PRODUCT_NAME%%
+# rustc or cargo
+TEMPLATE_VERIFY_BIN=%%TEMPLATE_VERIFY_BIN%%
+# rustlib or cargo
+TEMPLATE_REL_MANIFEST_DIR=%%TEMPLATE_REL_MANIFEST_DIR%%
+# 'Rust is ready to roll.' or 'Cargo is cool to cruise.'
+TEMPLATE_SUCCESS_MESSAGE=%%TEMPLATE_SUCCESS_MESSAGE%%
+
+# OK, let's get installing ...
+
+# Sanity check: can we run the binaries?
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ # Don't do this if uninstalling. Failure here won't help in any way.
+ if [ -z "${CFG_UNINSTALL}" ]
+ then
+ msg "verifying platform can run binaries"
+ export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib:$CFG_OLD_LD_PATH_VAR"
+ "${CFG_SRC_DIR}/bin/${TEMPLATE_VERIFY_BIN}" --version 2> /dev/null 1> /dev/null
+ if [ $? -ne 0 ]
+ then
+ err "can't execute rustc binary on this platform"
+ fi
+ export $CFG_LD_PATH_VAR="$CFG_OLD_LD_PATH_VAR"
+ fi
+fi
+
+# Sanity check: can we can write to the destination?
+msg "verifying destination is writable"
+umask 022 && mkdir -p "${CFG_LIBDIR}"
+need_ok "can't write to destination. consider \`sudo\`."
+touch "${CFG_LIBDIR}/rust-install-probe" > /dev/null
+if [ $? -ne 0 ]
+then
+ err "can't write to destination. consider \`sudo\`."
+fi
+rm -f "${CFG_LIBDIR}/rust-install-probe"
+need_ok "failed to remove install probe"
+
+# Sanity check: don't install to the directory containing the installer.
+# That would surely cause chaos.
+msg "verifying destination is not the same as source"
+INSTALLER_DIR="$(cd $(dirname $0) && pwd)"
+PREFIX_DIR="$(cd ${CFG_PREFIX} && pwd)"
+if [ "${INSTALLER_DIR}" = "${PREFIX_DIR}" ]
+then
+ err "can't install to same directory as installer"
+fi
+
+# Using an absolute path to libdir in a few places so that the status
+# messages are consistently using absolute paths.
+absolutify "${CFG_LIBDIR}"
+ABS_LIBDIR="${ABSOLUTIFIED}"
+
+# The file name of the manifest we're going to create during install
+INSTALLED_MANIFEST="${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}/manifest"
+
+# First, uninstall from the installation prefix.
+# Errors are warnings - try to rm everything in the manifest even if some fail.
+if [ -f "${INSTALLED_MANIFEST}" ]
+then
+ msg
+
+ # Iterate through installed manifest and remove files
+ while read p; do
+ # The installed manifest contains absolute paths
+ msg "removing $p"
+ if [ -f "$p" ]
+ then
+ rm -f "$p"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove $p"
+ fi
+ else
+ warn "supposedly installed file $p does not exist!"
+ fi
+ done < "${INSTALLED_MANIFEST}"
+
+ # If we fail to remove $TEMPLATE_REL_MANIFEST_DIR below, then the
+ # installed manifest will still be full; the installed manifest
+ # needs to be empty before install.
+ msg "removing ${INSTALLED_MANIFEST}"
+ rm -f "${INSTALLED_MANIFEST}"
+ # For the above reason, this is a hard error
+ need_ok "failed to remove installed manifest"
+
+ # Remove $TEMPLATE_REL_MANIFEST_DIR directory
+ msg "removing ${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+ rm -Rf "${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+ if [ $? -ne 0 ]
+ then
+ warn "failed to remove ${TEMPLATE_REL_MANIFEST_DIR}"
+ fi
+else
+ # There's no manifest. If we were asked to uninstall, then that's a problem.
+ if [ -n "${CFG_UNINSTALL}" ]
+ then
+ err "unable to find installation manifest at ${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+ fi
+fi
+
+# If we're only uninstalling then exit
+if [ -n "${CFG_UNINSTALL}" ]
+then
+ echo
+ echo " ${TEMPLATE_PRODUCT_NAME} is uninstalled."
+ echo
+ exit 0
+fi
+
+# Create the installed manifest, which we will fill in with absolute file paths
+mkdir -p "${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
+need_ok "failed to create ${TEMPLATE_REL_MANIFEST_DIR}"
+touch "${INSTALLED_MANIFEST}"
+need_ok "failed to create installed manifest"
+
+msg
+
+# Now install, iterate through the new manifest and copy files
+while read p; do
+
+ # Decide the destination of the file
+ FILE_INSTALL_PATH="${CFG_DESTDIR}${CFG_PREFIX}/$p"
+
+ if echo "$p" | grep "^lib/" > /dev/null
+ then
+ pp=`echo $p | sed 's/^lib\///'`
+ FILE_INSTALL_PATH="${CFG_LIBDIR}/$pp"
+ fi
+
+ if echo "$p" | grep "^share/man/" > /dev/null
+ then
+ pp=`echo $p | sed 's/^share\/man\///'`
+ FILE_INSTALL_PATH="${CFG_MANDIR}/$pp"
+ fi
+
+ # Make sure there's a directory for it
+ umask 022 && mkdir -p "$(dirname ${FILE_INSTALL_PATH})"
+ need_ok "directory creation failed"
+
+ # Make the path absolute so we can uninstall it later without
+ # starting from the installation cwd
+ absolutify "${FILE_INSTALL_PATH}"
+ FILE_INSTALL_PATH="${ABSOLUTIFIED}"
+
+ # Install the file
+ msg "installing ${FILE_INSTALL_PATH}"
+ if echo "$p" | grep "^bin/" > /dev/null
+ then
+ install -m755 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
+ else
+ install -m644 "${CFG_SRC_DIR}/$p" "${FILE_INSTALL_PATH}"
+ fi
+ need_ok "file creation failed"
+
+ # Update the manifest
+ echo "${FILE_INSTALL_PATH}" >> "${INSTALLED_MANIFEST}"
+ need_ok "failed to update manifest"
+
+# The manifest lists all files to install
+done < "${CFG_SRC_DIR}/lib/${TEMPLATE_REL_MANIFEST_DIR}/manifest.in"
+
+msg
+
+# Run ldconfig to make dynamic libraries available to the linker
+if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
+ then
+ ldconfig
+ if [ $? -ne 0 ]
+ then
+ warn "failed to run ldconfig."
+ warn "this may happen when not installing as root and may be fine"
+ fi
+fi
+
+# Sanity check: can we run the installed binaries?
+#
+# As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
+# is in place. Try first without this variable, and if that fails try again with
+# the variable. If the second time tries, print a hopefully helpful message to
+# add something to the appropriate environment variable.
+if [ -z "${CFG_DISABLE_VERIFY}" ]
+then
+ msg "verifying installed binaries are executable"
+ "${CFG_PREFIX}/bin/${TEMPLATE_VERIFY_BIN}" --version 2> /dev/null 1> /dev/null
+ if [ $? -ne 0 ]
+ then
+ export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib:$CFG_OLD_LD_PATH_VAR"
+ "${CFG_PREFIX}/bin/${TEMPLATE_VERIFY_BIN}" --version > /dev/null
+ if [ $? -ne 0 ]
+ then
+ ERR="can't execute installed binaries. "
+ ERR="${ERR}installation may be broken. "
+ ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
+ ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
+ err "${ERR}"
+ else
+ echo
+ echo " Note: please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
+ fi
+ fi
+fi
+
+echo
+echo " ${TEMPLATE_SUCCESS_MESSAGE}"
+echo
+
+