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.
14 if [ -x /bin
/echo ]; then
21 echo "gen-installer: ${1-}"
31 echo "gen-installer: WARNING: $1" >&2
35 echo "gen-installer: error: $1" >&2
47 if command -v $1 >/dev
/null
2>&1
60 printf "gen-installer: %-20s := %.35s ...\n" $1 "$t"
62 printf "gen-installer: %-20s := %s %s\n" $1 "$t"
67 VAL_OPTIONS
="$VAL_OPTIONS $1"
76 local uop
=$
(echo $op |
tr '[:lower:]' '[:upper:]' |
tr '\-' '\_')
81 if echo "$arg" |
grep -q -- "--$op="
83 local val
=$
(echo "$arg" | cut
-f2 -d=)
93 op
="${default}=[${default}]"
94 printf " --%-30s %s\n" "$op" "$doc"
99 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
108 if [ $default -eq 0 ]
120 if [ "$arg" = "--${flag}-${op}" ]
122 op
=$
(echo $op |
tr 'a-z-' 'A-Z_')
123 flag
=$
(echo $flag |
tr 'a-z' 'A-Z')
124 local v
="CFG_${flag}_${op}"
134 printf " --%-30s %s\n" "$flag-$op" "$doc"
139 BOOL_OPTIONS
="$BOOL_OPTIONS $1"
149 if [ "$arg" = "--${op}" ]
151 op
=$
(echo $op |
tr 'a-z-' 'A-Z_')
162 printf " --%-30s %s\n" "$op" "$doc"
170 for option
in $BOOL_OPTIONS
172 if test --disable-$option = $arg
176 if test --enable-$option = $arg
180 if test --$option = $arg
185 for option
in $VAL_OPTIONS
187 if echo "$arg" |
grep -q -- "--$option="
192 if [ "$arg" = "--help" ]
195 echo "No more help available for Configure options,"
196 echo "check the Wiki or join our IRC channel"
199 if test $is_arg_valid -eq 0
201 err
"Option '$arg' is not recognized"
207 msg
"looking for programs"
221 if [ "$1" = "--help" ]
226 echo "Usage: $0 [options]"
231 step_msg
"processing arguments"
238 valopt product-name
"Product" "The name of the product, for display"
239 valopt component-name
"component" "The name of the component, distinct from other installed components"
240 valopt package-name
"package" "The name of the package, tarball"
241 valopt rel-manifest-dir
"${CFG_PACKAGE_NAME}lib" "The directory under lib/ where the manifest lives"
242 valopt success-message
"Installed." "The string to print after successful installation"
243 valopt legacy-manifest-dirs
"" "Places to look for legacy manifests to uninstall"
244 valopt non-installed-overlay
"" "Directory containing files that should not be installed"
245 valopt bulk-dirs
"" "Path prefixes of directories that should be installed/uninstalled in bulk"
246 valopt image-dir
"./install-image" "The directory containing the installation medium"
247 valopt work-dir
"./workdir" "The directory to do temporary work"
248 valopt output-dir
"./dist" "The location to put the final image and tarball"
256 step_msg
"validating arguments"
259 src_dir
="$(cd $(dirname "$0") && pwd)"
261 rust_installer_version
=`cat "$src_dir/rust-installer-version"`
263 if [ ! -d "$CFG_IMAGE_DIR" ]
265 err
"image dir $CFG_IMAGE_DIR does not exist"
268 mkdir
-p "$CFG_WORK_DIR"
269 need_ok
"couldn't create work dir"
271 rm -Rf "$CFG_WORK_DIR/$CFG_PACKAGE_NAME"
272 need_ok
"couldn't delete work package dir"
274 mkdir
-p "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$CFG_COMPONENT_NAME"
275 need_ok
"couldn't create work package dir"
277 cp -r "$CFG_IMAGE_DIR/"* "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$CFG_COMPONENT_NAME"
278 need_ok
"couldn't copy source image"
280 # Create the manifest
281 manifest
=`(cd "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$CFG_COMPONENT_NAME" && find . -type f | sed 's/^\.\///') | sort`
283 # Remove files in bulk dirs
284 bulk_dirs
=`echo "$CFG_BULK_DIRS" | tr "," " "`
285 for bulk_dir
in $bulk_dirs; do
286 bulk_dir
=`echo "$bulk_dir" | sed s/\\\//\\\\\\\\\\\//g`
287 manifest
=`echo "$manifest" | sed /^$bulk_dir/d`
290 # Add 'file:' installation directives.
291 # The -n prevents adding a blank file: if the manifest is empty
292 manifest
=`$ECHO -n "$manifest" | sed s/^/file:/`
294 # Add 'dir:' directives
295 for bulk_dir
in $bulk_dirs; do
296 manifest
=`echo "$manifest" && echo "dir:$bulk_dir"`
299 # The above step may have left a leading empty line if there were only
300 # bulk dirs. Remove it.
301 manifest
=`echo "$manifest" | sed /^$/d`
303 manifest_file
="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$CFG_COMPONENT_NAME/manifest.in"
304 component_file
="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/components"
305 version_file
="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/rust-installer-version"
308 echo "$manifest" > "$manifest_file"
310 # Write the component name
311 echo "$CFG_COMPONENT_NAME" > "$component_file"
313 # Write the installer version (only used by combine-installers.sh)
314 echo "$rust_installer_version" > "$version_file"
317 if [ -n "$CFG_NON_INSTALLED_OVERLAY" ]; then
318 overlay_files
=`(cd "$CFG_NON_INSTALLED_OVERLAY" && find . -type f)`
319 for f
in $overlay_files; do
320 if [ -e "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$f" ]; then err
"overlay $f exists"; fi
322 cp "$CFG_NON_INSTALLED_OVERLAY/$f" "$CFG_WORK_DIR/$CFG_PACKAGE_NAME/$f"
323 need_ok
"failed to copy overlay $f"
327 # Generate the install script
328 "$src_dir/gen-install-script.sh" \
329 --product-name="$CFG_PRODUCT_NAME" \
330 --rel-manifest-dir="$CFG_REL_MANIFEST_DIR" \
331 --success-message="$CFG_SUCCESS_MESSAGE" \
332 --legacy-manifest-dirs="$CFG_LEGACY_MANIFEST_DIRS" \
333 --output-script="$CFG_WORK_DIR/$CFG_PACKAGE_NAME/install.sh"
335 need_ok
"failed to generate install script"
337 mkdir
-p "$CFG_OUTPUT_DIR"
338 need_ok
"couldn't create output dir"
340 rm -Rf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz"
341 need_ok
"couldn't delete old tarball"
344 tar -czf "$CFG_OUTPUT_DIR/$CFG_PACKAGE_NAME.tar.gz" -C "$CFG_WORK_DIR" "$CFG_PACKAGE_NAME"
345 need_ok
"failed to tar"