]> git.proxmox.com Git - rustc.git/blob - src/tools/rust-installer/test/rust-installer-v2/install-template.sh
New upstream version 1.24.1+dfsg1
[rustc.git] / src / tools / rust-installer / test / rust-installer-v2 / install-template.sh
1 #!/bin/sh
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.
5 #
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.
11
12 msg() {
13 echo "install: $1"
14 }
15
16 step_msg() {
17 msg
18 msg "$1"
19 msg
20 }
21
22 warn() {
23 echo "install: WARNING: $1"
24 }
25
26 err() {
27 echo "install: error: $1"
28 exit 1
29 }
30
31 need_ok() {
32 if [ $? -ne 0 ]
33 then
34 err "$1"
35 fi
36 }
37
38 need_cmd() {
39 if command -v $1 >/dev/null 2>&1
40 then msg "found $1"
41 else err "need $1"
42 fi
43 }
44
45 putvar() {
46 local T
47 eval T=\$$1
48 eval TLEN=\${#$1}
49 if [ $TLEN -gt 35 ]
50 then
51 printf "install: %-20s := %.35s ...\n" $1 "$T"
52 else
53 printf "install: %-20s := %s %s\n" $1 "$T" "$2"
54 fi
55 }
56
57 valopt() {
58 VAL_OPTIONS="$VAL_OPTIONS $1"
59
60 local OP=$1
61 local DEFAULT=$2
62 shift
63 shift
64 local DOC="$*"
65 if [ $HELP -eq 0 ]
66 then
67 local UOP=$(echo $OP | tr '[:lower:]' '[:upper:]' | tr '\-' '\_')
68 local V="CFG_${UOP}"
69 eval $V="$DEFAULT"
70 for arg in $CFG_ARGS
71 do
72 if echo "$arg" | grep -q -- "--$OP="
73 then
74 val=$(echo "$arg" | cut -f2 -d=)
75 eval $V=$val
76 fi
77 done
78 putvar $V
79 else
80 if [ -z "$DEFAULT" ]
81 then
82 DEFAULT="<none>"
83 fi
84 OP="${OP}=[${DEFAULT}]"
85 printf " --%-30s %s\n" "$OP" "$DOC"
86 fi
87 }
88
89 opt() {
90 BOOL_OPTIONS="$BOOL_OPTIONS $1"
91
92 local OP=$1
93 local DEFAULT=$2
94 shift
95 shift
96 local DOC="$*"
97 local FLAG=""
98
99 if [ $DEFAULT -eq 0 ]
100 then
101 FLAG="enable"
102 else
103 FLAG="disable"
104 DOC="don't $DOC"
105 fi
106
107 if [ $HELP -eq 0 ]
108 then
109 for arg in $CFG_ARGS
110 do
111 if [ "$arg" = "--${FLAG}-${OP}" ]
112 then
113 OP=$(echo $OP | tr 'a-z-' 'A-Z_')
114 FLAG=$(echo $FLAG | tr 'a-z' 'A-Z')
115 local V="CFG_${FLAG}_${OP}"
116 eval $V=1
117 putvar $V
118 fi
119 done
120 else
121 if [ ! -z "$META" ]
122 then
123 OP="$OP=<$META>"
124 fi
125 printf " --%-30s %s\n" "$FLAG-$OP" "$DOC"
126 fi
127 }
128
129 flag() {
130 BOOL_OPTIONS="$BOOL_OPTIONS $1"
131
132 local OP=$1
133 shift
134 local DOC="$*"
135
136 if [ $HELP -eq 0 ]
137 then
138 for arg in $CFG_ARGS
139 do
140 if [ "$arg" = "--${OP}" ]
141 then
142 OP=$(echo $OP | tr 'a-z-' 'A-Z_')
143 local V="CFG_${OP}"
144 eval $V=1
145 putvar $V
146 fi
147 done
148 else
149 if [ ! -z "$META" ]
150 then
151 OP="$OP=<$META>"
152 fi
153 printf " --%-30s %s\n" "$OP" "$DOC"
154 fi
155 }
156
157 validate_opt () {
158 for arg in $CFG_ARGS
159 do
160 isArgValid=0
161 for option in $BOOL_OPTIONS
162 do
163 if test --disable-$option = $arg
164 then
165 isArgValid=1
166 fi
167 if test --enable-$option = $arg
168 then
169 isArgValid=1
170 fi
171 if test --$option = $arg
172 then
173 isArgValid=1
174 fi
175 done
176 for option in $VAL_OPTIONS
177 do
178 if echo "$arg" | grep -q -- "--$option="
179 then
180 isArgValid=1
181 fi
182 done
183 if [ "$arg" = "--help" ]
184 then
185 echo
186 echo "No more help available for Configure options,"
187 echo "check the Wiki or join our IRC channel"
188 break
189 else
190 if test $isArgValid -eq 0
191 then
192 err "Option '$arg' is not recognized"
193 fi
194 fi
195 done
196 }
197
198 absolutify() {
199 FILE_PATH="${1}"
200 FILE_PATH_DIRNAME="$(dirname ${FILE_PATH})"
201 FILE_PATH_BASENAME="$(basename ${FILE_PATH})"
202 FILE_ABS_PATH="$(cd ${FILE_PATH_DIRNAME} && pwd)"
203 FILE_PATH="${FILE_ABS_PATH}/${FILE_PATH_BASENAME}"
204 # This is the return value
205 ABSOLUTIFIED="${FILE_PATH}"
206 }
207
208 msg "looking for install programs"
209 msg
210
211 need_cmd mkdir
212 need_cmd printf
213 need_cmd cut
214 need_cmd grep
215 need_cmd uname
216 need_cmd tr
217 need_cmd sed
218 need_cmd chmod
219
220 CFG_SRC_DIR="$(cd $(dirname $0) && pwd)"
221 CFG_SELF="$0"
222 CFG_ARGS="$@"
223
224 HELP=0
225 if [ "$1" = "--help" ]
226 then
227 HELP=1
228 shift
229 echo
230 echo "Usage: $CFG_SELF [options]"
231 echo
232 echo "Options:"
233 echo
234 else
235 step_msg "processing $CFG_SELF args"
236 fi
237
238 # Check for mingw or cygwin in order to special case $CFG_LIBDIR_RELATIVE.
239 # This logic is duplicated from configure in order to get the correct libdir
240 # for Windows installs.
241 CFG_OSTYPE=$(uname -s)
242
243 case $CFG_OSTYPE in
244
245 Linux)
246 CFG_OSTYPE=unknown-linux-gnu
247 ;;
248
249 FreeBSD)
250 CFG_OSTYPE=unknown-freebsd
251 ;;
252
253 DragonFly)
254 CFG_OSTYPE=unknown-dragonfly
255 ;;
256
257 Darwin)
258 CFG_OSTYPE=apple-darwin
259 ;;
260
261 MINGW*)
262 # msys' `uname` does not print gcc configuration, but prints msys
263 # configuration. so we cannot believe `uname -m`:
264 # msys1 is always i686 and msys2 is always x86_64.
265 # instead, msys defines $MSYSTEM which is MINGW32 on i686 and
266 # MINGW64 on x86_64.
267 CFG_CPUTYPE=i686
268 CFG_OSTYPE=pc-windows-gnu
269 if [ "$MSYSTEM" = MINGW64 ]
270 then
271 CFG_CPUTYPE=x86_64
272 fi
273 ;;
274
275 MSYS*)
276 CFG_OSTYPE=pc-windows-gnu
277 ;;
278
279 # Thad's Cygwin identifers below
280
281 # Vista 32 bit
282 CYGWIN_NT-6.0)
283 CFG_OSTYPE=pc-windows-gnu
284 CFG_CPUTYPE=i686
285 ;;
286
287 # Vista 64 bit
288 CYGWIN_NT-6.0-WOW64)
289 CFG_OSTYPE=pc-windows-gnu
290 CFG_CPUTYPE=x86_64
291 ;;
292
293 # Win 7 32 bit
294 CYGWIN_NT-6.1)
295 CFG_OSTYPE=pc-windows-gnu
296 CFG_CPUTYPE=i686
297 ;;
298
299 # Win 7 64 bit
300 CYGWIN_NT-6.1-WOW64)
301 CFG_OSTYPE=pc-windows-gnu
302 CFG_CPUTYPE=x86_64
303 ;;
304 esac
305
306 OPTIONS=""
307 BOOL_OPTIONS=""
308 VAL_OPTIONS=""
309
310 if [ "$CFG_OSTYPE" = "pc-windows-gnu" ]
311 then
312 CFG_LD_PATH_VAR=PATH
313 CFG_OLD_LD_PATH_VAR=$PATH
314 elif [ "$CFG_OSTYPE" = "apple-darwin" ]
315 then
316 CFG_LD_PATH_VAR=DYLD_LIBRARY_PATH
317 CFG_OLD_LD_PATH_VAR=$DYLD_LIBRARY_PATH
318 else
319 CFG_LD_PATH_VAR=LD_LIBRARY_PATH
320 CFG_OLD_LD_PATH_VAR=$LD_LIBRARY_PATH
321 fi
322
323 flag uninstall "only uninstall from the installation prefix"
324 valopt destdir "" "set installation root"
325 opt verify 1 "verify that the installed binaries run correctly"
326 valopt prefix "/usr/local" "set installation prefix"
327 # NB This isn't quite the same definition as in `configure`.
328 # just using 'lib' instead of configure's CFG_LIBDIR_RELATIVE
329 valopt libdir "${CFG_DESTDIR}${CFG_PREFIX}/lib" "install libraries"
330 valopt mandir "${CFG_DESTDIR}${CFG_PREFIX}/share/man" "install man pages in PATH"
331 opt ldconfig 1 "run ldconfig after installation (Linux only)"
332
333 if [ $HELP -eq 1 ]
334 then
335 echo
336 exit 0
337 fi
338
339 step_msg "validating $CFG_SELF args"
340 validate_opt
341
342 # Template configuration.
343 # These names surrounded by '%%` are replaced by sed when generating install.sh
344 # FIXME: Might want to consider loading this from a file and not generating install.sh
345
346 # Rust or Cargo
347 TEMPLATE_PRODUCT_NAME=%%TEMPLATE_PRODUCT_NAME%%
348 # rustc or cargo
349 TEMPLATE_VERIFY_BIN=%%TEMPLATE_VERIFY_BIN%%
350 # rustlib or cargo
351 TEMPLATE_REL_MANIFEST_DIR=%%TEMPLATE_REL_MANIFEST_DIR%%
352 # 'Rust is ready to roll.' or 'Cargo is cool to cruise.'
353 TEMPLATE_SUCCESS_MESSAGE=%%TEMPLATE_SUCCESS_MESSAGE%%
354 # Locations to look for directories containing legacy, pre-versioned manifests
355 TEMPLATE_LEGACY_MANIFEST_DIRS=%%TEMPLATE_LEGACY_MANIFEST_DIRS%%
356 # The installer version
357 TEMPLATE_RUST_INSTALLER_VERSION=%%TEMPLATE_RUST_INSTALLER_VERSION%%
358
359 # OK, let's get installing ...
360
361 # If we don't have a verify bin then disable verify
362 if [ -z "$TEMPLATE_VERIFY_BIN" ]; then
363 CFG_DISABLE_VERIFY=1
364 fi
365
366 # Sanity check: can we run the binaries?
367 if [ -z "${CFG_DISABLE_VERIFY}" ]
368 then
369 # Don't do this if uninstalling. Failure here won't help in any way.
370 if [ -z "${CFG_UNINSTALL}" ]
371 then
372 msg "verifying platform can run binaries"
373 export $CFG_LD_PATH_VAR="${CFG_SRC_DIR}/lib:$CFG_OLD_LD_PATH_VAR"
374 "${CFG_SRC_DIR}/bin/${TEMPLATE_VERIFY_BIN}" --version 2> /dev/null 1> /dev/null
375 if [ $? -ne 0 ]
376 then
377 err "can't execute binaries on this platform"
378 fi
379 export $CFG_LD_PATH_VAR="$CFG_OLD_LD_PATH_VAR"
380 fi
381 fi
382
383 # Sanity check: can we can write to the destination?
384 msg "verifying destination is writable"
385 umask 022 && mkdir -p "${CFG_LIBDIR}"
386 need_ok "can't write to destination. consider \`sudo\`."
387 touch "${CFG_LIBDIR}/rust-install-probe" > /dev/null
388 if [ $? -ne 0 ]
389 then
390 err "can't write to destination. consider \`sudo\`."
391 fi
392 rm -f "${CFG_LIBDIR}/rust-install-probe"
393 need_ok "failed to remove install probe"
394
395 # Sanity check: don't install to the directory containing the installer.
396 # That would surely cause chaos.
397 msg "verifying destination is not the same as source"
398 INSTALLER_DIR="$(cd $(dirname $0) && pwd)"
399 PREFIX_DIR="$(cd ${CFG_PREFIX} && pwd)"
400 if [ "${INSTALLER_DIR}" = "${PREFIX_DIR}" ]
401 then
402 err "can't install to same directory as installer"
403 fi
404
405 # Open the components file to get the list of components to install
406 COMPONENTS=`cat "$CFG_SRC_DIR/components"`
407
408 # Sanity check: do we have components?
409 if [ ! -n "$COMPONENTS" ]; then
410 err "unable to find installation components"
411 fi
412
413 # Using an absolute path to libdir in a few places so that the status
414 # messages are consistently using absolute paths.
415 absolutify "${CFG_LIBDIR}"
416 ABS_LIBDIR="${ABSOLUTIFIED}"
417
418 # Replace commas in legacy manifest list with spaces
419 LEGACY_MANIFEST_DIRS=`echo "$TEMPLATE_LEGACY_MANIFEST_DIRS" | sed "s/,/ /g"`
420
421 # Uninstall from legacy manifests
422 for md in $LEGACY_MANIFEST_DIRS; do
423 # First, uninstall from the installation prefix.
424 # Errors are warnings - try to rm everything in the manifest even if some fail.
425 if [ -f "$ABS_LIBDIR/$md/manifest" ]
426 then
427
428 # Iterate through installed manifest and remove files
429 while read p; do
430 # The installed manifest contains absolute paths
431 msg "removing legacy file $p"
432 if [ -f "$p" ]
433 then
434 rm -f "$p"
435 if [ $? -ne 0 ]
436 then
437 warn "failed to remove $p"
438 fi
439 else
440 warn "supposedly installed file $p does not exist!"
441 fi
442 done < "$ABS_LIBDIR/$md/manifest"
443
444 # If we fail to remove $md below, then the
445 # installed manifest will still be full; the installed manifest
446 # needs to be empty before install.
447 msg "removing legacy manifest $ABS_LIBDIR/$md/manifest"
448 rm -f "$ABS_LIBDIR/$md/manifest"
449 # For the above reason, this is a hard error
450 need_ok "failed to remove installed manifest"
451
452 # Remove $TEMPLATE_REL_MANIFEST_DIR directory
453 msg "removing legacy manifest dir ${ABS_LIBDIR}/$md"
454 rm -Rf "${ABS_LIBDIR}/$md"
455 if [ $? -ne 0 ]
456 then
457 warn "failed to remove $md"
458 fi
459
460 UNINSTALLED_SOMETHING=1
461 fi
462 done
463
464 # Load the version of the installed installer
465 if [ -f "$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version" ]; then
466 INSTALLED_VERSION=`cat "$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version"`
467
468 # Sanity check
469 if [ ! -n "$INSTALLED_VERSION" ]; then err "rust installer version is empty"; fi
470 fi
471
472 # If there's something installed, then uninstall
473 if [ -n "$INSTALLED_VERSION" ]; then
474 # Check the version of the installed installer
475 case "$INSTALLED_VERSION" in
476
477 # TODO: If this is a previous version, then upgrade in place to the
478 # current version before uninstalling. No need to do this yet because
479 # there is no prior version (only the legacy 'unversioned' installer
480 # which we've already dealt with).
481
482 # This is the current version. Nothing need to be done except uninstall.
483 "$TEMPLATE_RUST_INSTALLER_VERSION")
484 ;;
485
486 # TODO: If this is an unknown (future) version then bail.
487 *)
488 echo "The copy of $TEMPLATE_PRODUCT_NAME at $CFG_PREFIX was installed using an"
489 echo "unknown version ($INSTALLED_VERSION) of rust-installer."
490 echo "Uninstall it first with the installer used for the original installation"
491 echo "before continuing."
492 exit 1
493 ;;
494 esac
495
496 MD="$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR"
497 INSTALLED_COMPONENTS=`cat $MD/components`
498
499 # Uninstall (our components only) before reinstalling
500 for available_component in $COMPONENTS; do
501 for installed_component in $INSTALLED_COMPONENTS; do
502 if [ "$available_component" = "$installed_component" ]; then
503 COMPONENT_MANIFEST="$MD/manifest-$installed_component"
504
505 # Sanity check: there should be a component manifest
506 if [ ! -f "$COMPONENT_MANIFEST" ]; then
507 err "installed component '$installed_component' has no manifest"
508 fi
509
510 # Iterate through installed component manifest and remove files
511 while read directive; do
512
513 COMMAND=`echo $directive | cut -f1 -d:`
514 FILE=`echo $directive | cut -f2 -d:`
515
516 # Sanity checks
517 if [ ! -n "$COMMAND" ]; then err "malformed installation directive"; fi
518 if [ ! -n "$FILE" ]; then err "malformed installation directive"; fi
519
520 case "$COMMAND" in
521 file)
522 msg "removing file $FILE"
523 if [ -f "$FILE" ]; then
524 rm -f "$FILE"
525 if [ $? -ne 0 ]; then
526 warn "failed to remove $FILE"
527 fi
528 else
529 warn "supposedly installed file $FILE does not exist!"
530 fi
531 ;;
532
533 dir)
534 msg "removing directory $FILE"
535 rm -Rf "$FILE"
536 if [ $? -ne 0 ]; then
537 warn "unable to remove directory $FILE"
538 fi
539 ;;
540
541 *)
542 err "unknown installation directive"
543 ;;
544 esac
545
546 done < "$COMPONENT_MANIFEST"
547
548 # Remove the installed component manifest
549 msg "removing component manifest $COMPONENT_MANIFEST"
550 rm -f "$COMPONENT_MANIFEST"
551 # This is a hard error because the installation is unrecoverable
552 need_ok "failed to remove installed manifest for component '$installed_component'"
553
554 # Update the installed component list
555 MODIFIED_COMPONENTS=`sed /^$installed_component\$/d $MD/components`
556 echo "$MODIFIED_COMPONENTS" > "$MD/components"
557 need_ok "failed to update installed component list"
558 fi
559 done
560 done
561
562 # If there are no remaining components delete the manifest directory
563 REMAINING_COMPONENTS=`cat $MD/components`
564 if [ ! -n "$REMAINING_COMPONENTS" ]; then
565 msg "removing manifest directory $MD"
566 rm -Rf "$MD"
567 if [ $? -ne 0 ]; then
568 warn "failed to remove $MD"
569 fi
570 fi
571
572 UNINSTALLED_SOMETHING=1
573 fi
574
575 # There's no installed version. If we were asked to uninstall, then that's a problem.
576 if [ -n "${CFG_UNINSTALL}" -a ! -n "$UNINSTALLED_SOMETHING" ]
577 then
578 err "unable to find installation manifest at ${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
579 fi
580
581 # If we're only uninstalling then exit
582 if [ -n "${CFG_UNINSTALL}" ]
583 then
584 echo
585 echo " ${TEMPLATE_PRODUCT_NAME} is uninstalled."
586 echo
587 exit 0
588 fi
589
590 # Create the directory to contain the manifests
591 mkdir -p "${CFG_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}"
592 need_ok "failed to create ${TEMPLATE_REL_MANIFEST_DIR}"
593
594 # Install each component
595 for component in $COMPONENTS; do
596
597 # The file name of the manifest we're installing from
598 INPUT_MANIFEST="${CFG_SRC_DIR}/manifest-$component.in"
599
600 # The installed manifest directory
601 MD="$ABS_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR"
602
603 # The file name of the manifest we're going to create during install
604 INSTALLED_MANIFEST="$MD/manifest-$component"
605
606 # Create the installed manifest, which we will fill in with absolute file paths
607 touch "${INSTALLED_MANIFEST}"
608 need_ok "failed to create installed manifest"
609
610 # Sanity check: do we have our input manifests?
611 if [ ! -f "$INPUT_MANIFEST" ]; then
612 err "manifest for $component does not exist at $INPUT_MANIFEST"
613 fi
614
615 # Now install, iterate through the new manifest and copy files
616 while read directive; do
617
618 COMMAND=`echo $directive | cut -f1 -d:`
619 FILE=`echo $directive | cut -f2 -d:`
620
621 # Sanity checks
622 if [ ! -n "$COMMAND" ]; then err "malformed installation directive"; fi
623 if [ ! -n "$FILE" ]; then err "malformed installation directive"; fi
624
625 # Decide the destination of the file
626 FILE_INSTALL_PATH="${CFG_DESTDIR}${CFG_PREFIX}/$FILE"
627
628 if echo "$FILE" | grep "^lib/" > /dev/null
629 then
630 f=`echo $FILE | sed 's/^lib\///'`
631 FILE_INSTALL_PATH="${CFG_LIBDIR}/$f"
632 fi
633
634 if echo "$FILE" | grep "^share/man/" > /dev/null
635 then
636 f=`echo $FILE | sed 's/^share\/man\///'`
637 FILE_INSTALL_PATH="${CFG_MANDIR}/$f"
638 fi
639
640 # Make sure there's a directory for it
641 umask 022 && mkdir -p "$(dirname ${FILE_INSTALL_PATH})"
642 need_ok "directory creation failed"
643
644 # Make the path absolute so we can uninstall it later without
645 # starting from the installation cwd
646 absolutify "${FILE_INSTALL_PATH}"
647 FILE_INSTALL_PATH="${ABSOLUTIFIED}"
648
649 case "$COMMAND" in
650 file)
651
652 # Install the file
653 msg "copying file $FILE_INSTALL_PATH"
654 if echo "$FILE" | grep "^bin/" > /dev/null
655 then
656 install -m755 "${CFG_SRC_DIR}/$FILE" "${FILE_INSTALL_PATH}"
657 else
658 install -m644 "${CFG_SRC_DIR}/$FILE" "${FILE_INSTALL_PATH}"
659 fi
660 need_ok "file creation failed"
661
662 # Update the manifest
663 echo "file:${FILE_INSTALL_PATH}" >> "${INSTALLED_MANIFEST}"
664 need_ok "failed to update manifest"
665
666 ;;
667
668 dir)
669
670 # Copy the dir
671 msg "copying directory $FILE_INSTALL_PATH"
672
673 # Sanity check: bulk dirs are supposed to be uniquely ours and should not exist
674 if [ -e "$FILE_INSTALL_PATH" ]; then
675 err "$FILE_INSTALL_PATH already exists"
676 fi
677
678 cp -R "$CFG_SRC_DIR/$FILE" "$FILE_INSTALL_PATH"
679 need_ok "failed to copy directory"
680
681 # Set permissions. 0755 for dirs, 644 for files
682 chmod -R u+rwX,go+rX,go-w "$FILE_INSTALL_PATH"
683 need_ok "failed to set permissions on directory"
684
685 # Update the manifest
686 echo "dir:$FILE_INSTALL_PATH" >> "$INSTALLED_MANIFEST"
687 need_ok "failed to update manifest"
688 ;;
689
690 *)
691 err "unknown installation directive"
692 ;;
693 esac
694 done < "$INPUT_MANIFEST"
695
696 # Update the components
697 echo "$component" >> "$MD/components"
698 need_ok "failed to update components list for $component"
699
700 done
701
702 # Drop the version number into the manifest dir
703 echo "$TEMPLATE_RUST_INSTALLER_VERSION" > "${ABS_LIBDIR}/${TEMPLATE_REL_MANIFEST_DIR}/rust-installer-version"
704
705 # Run ldconfig to make dynamic libraries available to the linker
706 if [ "$CFG_OSTYPE" = "unknown-linux-gnu" -a ! -n "$CFG_DISABLE_LDCONFIG" ]; then
707 msg "running ldconfig"
708 ldconfig
709 if [ $? -ne 0 ]
710 then
711 warn "failed to run ldconfig."
712 warn "this may happen when not installing as root and may be fine"
713 fi
714 fi
715
716 # Sanity check: can we run the installed binaries?
717 #
718 # As with the verification above, make sure the right LD_LIBRARY_PATH-equivalent
719 # is in place. Try first without this variable, and if that fails try again with
720 # the variable. If the second time tries, print a hopefully helpful message to
721 # add something to the appropriate environment variable.
722 if [ -z "${CFG_DISABLE_VERIFY}" ]
723 then
724 export $CFG_LD_PATH_VAR="${CFG_PREFIX}/lib:$CFG_OLD_LD_PATH_VAR"
725 "${CFG_PREFIX}/bin/${TEMPLATE_VERIFY_BIN}" --version > /dev/null
726 if [ $? -ne 0 ]
727 then
728 ERR="can't execute installed binaries. "
729 ERR="${ERR}installation may be broken. "
730 ERR="${ERR}if this is expected then rerun install.sh with \`--disable-verify\` "
731 ERR="${ERR}or \`make install\` with \`--disable-verify-install\`"
732 err "${ERR}"
733 else
734 echo
735 echo " Note: please ensure '${CFG_PREFIX}/lib' is added to ${CFG_LD_PATH_VAR}"
736 fi
737 fi
738
739 echo
740 echo " ${TEMPLATE_SUCCESS_MESSAGE}"
741 echo
742
743