2 # Copyright 2014 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
13 echo "gen-installer: $1"
23 echo "gen-installer: WARNING: $1"
27 echo "gen-installer: error: $1"
39 if command -v $1 >/dev
/null
2>&1
51 printf "gen-installer: %-20s := %.35s ...\n" $1 "$T"
53 printf "gen-installer: %-20s := %s %s\n" $1 "$T" "$2"
58 VAL_OPTIONS
="$VAL_OPTIONS $1"
67 local UOP
=$
(echo $OP |
tr '[:lower:]' '[:upper:]' |
tr '\-' '\_')
72 if echo "$arg" |
grep -q -- "--$OP="
74 val
=$
(echo "$arg" | cut
-f2 -d=)
84 OP
="${OP}=[${DEFAULT}]"
85 printf " --%-30s %s\n" "$OP" "$DOC"
90 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
111 if [ "$arg" = "--${FLAG}-${OP}" ]
113 OP
=$
(echo $OP |
tr 'a-z-' 'A-Z_')
114 FLAG
=$
(echo $FLAG |
tr 'a-z' 'A-Z')
115 local V
="CFG_${FLAG}_${OP}"
125 printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
130 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
140 if [ "$arg" = "--${OP}" ]
142 OP
=$
(echo $OP |
tr 'a-z-' 'A-Z_')
153 printf " --%-30s %s\n" "$OP" "$DOC"
161 for option
in $BOOL_OPTIONS
163 if test --disable-$option = $arg
167 if test --enable-$option = $arg
171 if test --$option = $arg
176 for option
in $VAL_OPTIONS
178 if echo "$arg" |
grep -q -- "--$option="
183 if [ "$arg" = "--help" ]
186 echo "No more help available for Configure options,"
187 echo "check the Wiki or join our IRC channel"
190 if test $isArgValid -eq 0
192 err
"Option '$arg' is not recognized"
198 msg
"looking for programs"
209 CFG_SRC_DIR
="$(cd $(dirname $0) && pwd)"
214 if [ "$1" = "--help" ]
219 echo "Usage: $CFG_SELF [options]"
224 step_msg
"processing $CFG_SELF args"
227 valopt product-name
"Product" "The name of the product, for display"
228 valopt component-name
"component" "The name of the component, distinct from other installed components"
229 valopt package-name
"package" "The name of the package, tarball"
230 valopt verify-bin
"" "The command to run with --version to verify the install works"
231 valopt rel-manifest-dir
"${CFG_PACKAGE_NAME}lib" "The directory under lib/ where the manifest lives"
232 valopt success-message
"Installed." "The string to print after successful installation"
233 valopt legacy-manifest-dirs
"" "Places to look for legacy manifests to uninstall"
234 valopt non-installed-prefixes
"" "Path prefixes that should be included but not installed"
235 valopt bulk-dirs
"" "Path prefixes of directories that should be installed/uninstalled in bulk"
236 valopt image-dir
"./install-image" "The directory containing the installation medium"
237 valopt work-dir
"./workdir" "The directory to do temporary work"
238 valopt output-dir
"./dist" "The location to put the final image and tarball"
246 step_msg
"validating $CFG_SELF args"
249 RUST_INSTALLER_VERSION
=`cat "$CFG_SRC_DIR/rust-installer-version"`
251 if [ ! -d "$CFG_IMAGE_DIR" ]
253 err
"image dir $CFG_IMAGE_DIR does not exist"
256 mkdir
-p "$CFG_WORK_DIR"
257 need_ok
"couldn't create work dir"
259 rm -Rf "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
260 need_ok
"couldn't delete work package dir"
262 mkdir
-p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
263 need_ok
"couldn't create work package dir"
265 cp -r "$CFG_IMAGE_DIR/"* "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
266 need_ok
"couldn't copy source image"
268 # Create the manifest
269 MANIFEST
=`(cd "$CFG_WORK_DIR/$CFG_PACKAGE_NAME" && find . -type f | sed 's/^\.\///') | sort`
271 # Remove non-installed files from manifest
272 NON_INSTALLED_PREFIXES
=`echo "$CFG_NON_INSTALLED_PREFIXES" | tr "," " "`
273 for prefix
in $NON_INSTALLED_PREFIXES; do
274 # This adds the escapes to '/' in paths to make them '\/' so sed doesn't puke.
275 # I figured this out by adding backslashes until it worked. Holy shit.
276 prefix
=`echo "$prefix" | sed s/\\\//\\\\\\\\\\\//g`
277 MANIFEST
=`echo "$MANIFEST" | sed /^$prefix/d`
280 # Remove files in bulk dirs
281 BULK_DIRS
=`echo "$CFG_BULK_DIRS" | tr "," " "`
282 for bulk_dir
in $BULK_DIRS; do
283 bulk_dir
=`echo "$bulk_dir" | sed s/\\\//\\\\\\\\\\\//g`
284 MANIFEST
=`echo "$MANIFEST" | sed /^$bulk_dir/d`
287 # Add 'file:' installation directives.
288 # The -n prevents adding a blank file: if the manifest is empty
289 MANIFEST
=`/bin/echo -n "$MANIFEST" | sed s/^/file:/`
291 # Add 'dir:' directives
292 for bulk_dir
in $BULK_DIRS; do
293 MANIFEST
=`echo "$MANIFEST" && echo "dir:$bulk_dir"`
296 # The above step may have left a leading empty line if there were only
297 # bulk dirs. Remove it.
298 MANIFEST
=`echo "$MANIFEST" | sed /^$/d`
300 MANIFEST_FILE
="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/manifest-$CFG_COMPONENT_NAME.in"
301 COMPONENT_FILE
="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/components"
302 VERSION_FILE
="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/rust-installer-version"
305 echo "$MANIFEST" > "$MANIFEST_FILE"
307 # Write the component name
308 echo "$CFG_COMPONENT_NAME" > "$COMPONENT_FILE"
310 # Write the installer version (only used by combine-installers.sh)
311 echo "$RUST_INSTALLER_VERSION" > "$VERSION_FILE"
313 # Generate the install script
314 "$CFG_SRC_DIR/gen-install-script.sh" \
315 --product-name="$CFG_PRODUCT_NAME" \
316 --verify-bin="$CFG_VERIFY_BIN" \
317 --rel-manifest-dir="$CFG_REL_MANIFEST_DIR" \
318 --success-message="$CFG_SUCCESS_MESSAGE" \
319 --legacy-manifest-dirs="$CFG_LEGACY_MANIFEST_DIRS" \
320 --output-script="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/install.sh"
322 need_ok
"failed to generate install script"
324 mkdir
-p "$CFG_OUTPUT_DIR"
325 need_ok
"couldn't create output dir"
327 rm -Rf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz"
328 need_ok
"couldn't delete old tarball"
331 tar -czf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz" -C "$CFG_WORK_DIR" "$CFG_PACKAGE_NAME"
332 need_ok
"failed to tar"