mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
install: Verify that installed compiler runs
Another sanity check. Can be disabled in `install.sh` via `--disable-verify` and `configure` with `--disable-verify-install`.
This commit is contained in:
parent
42e1003e4a
commit
01d823b4de
1
configure
vendored
1
configure
vendored
@ -384,6 +384,7 @@ opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-
|
||||
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
|
||||
opt rpath 1 "build rpaths into rustc itself"
|
||||
opt nightly 0 "build nightly packages"
|
||||
opt verify-install 1 "verify installed binaries work"
|
||||
valopt prefix "/usr/local" "set installation prefix"
|
||||
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
|
||||
valopt llvm-root "" "set LLVM root"
|
||||
|
@ -8,14 +8,21 @@
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
ifdef CFG_DISABLE_VERIFY_INSTALL
|
||||
MAYBE_DISABLE_VERIFY=--disable-verify
|
||||
else
|
||||
MAYBE_DISABLE_VERIFY=
|
||||
endif
|
||||
|
||||
install: dist-install-dir-$(CFG_BUILD)
|
||||
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(CFG_PREFIX)" --libdir="$(CFG_LIBDIR)" --mandir="$(CFG_MANDIR)"
|
||||
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(CFG_PREFIX)" --libdir="$(CFG_LIBDIR)" --mandir="$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
|
||||
# Remove tmp files while we can because they may have been created under sudo
|
||||
$(Q)rm -R tmp/dist/$(PKG_NAME)-$(CFG_BUILD)
|
||||
|
||||
uninstall: dist-install-dir-$(CFG_BUILD)
|
||||
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(CFG_PREFIX)" --libdir="$(CFG_LIBDIR)" --mandir="$(CFG_MANDIR)"
|
||||
# Remove tmp files while we can because they may have been created under sudo
|
||||
$(Q)rm -R tmp/dist/$(PKG_NAME)-$(CFG_BUILD)
|
||||
|
||||
|
||||
######################################################################
|
||||
|
@ -212,6 +212,7 @@ BOOL_OPTIONS=""
|
||||
VAL_OPTIONS=""
|
||||
|
||||
flag uninstall "only uninstall from the installation prefix"
|
||||
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 CFG_LIBDIR_RELATIVE
|
||||
@ -230,19 +231,36 @@ validate_opt
|
||||
|
||||
# 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"
|
||||
"${CFG_SRC_DIR}/bin/rustc" --version > /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
err "can't execute rustc binary on this platform"
|
||||
fi
|
||||
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" 2> /dev/null
|
||||
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'."
|
||||
err "can't write to destination. consider \`sudo\`."
|
||||
fi
|
||||
rm "${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}" ]
|
||||
@ -273,6 +291,10 @@ then
|
||||
fi
|
||||
done < "${INSTALLED_MANIFEST}"
|
||||
|
||||
# TODO: Remove the manifest.
|
||||
# If we fail to remove rustlib below, then the installed manifest will
|
||||
# still be full; the installed manifest needs to be empty before install.
|
||||
|
||||
# Remove 'rustlib' directory
|
||||
rm -r "${CFG_LIBDIR}/rustlib"
|
||||
if [ $? -ne 0 ]
|
||||
@ -346,6 +368,20 @@ while read p; do
|
||||
# The manifest lists all files to install
|
||||
done < "${CFG_SRC_DIR}/lib/rustlib/manifest.in"
|
||||
|
||||
# Sanity check: can we run the installed binaries?
|
||||
if [ -z "${CFG_DISABLE_VERIFY}" ]
|
||||
then
|
||||
msg "verifying installed binaries are executable"
|
||||
"${CFG_PREFIX}/bin/rustc" --version > /dev/null
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
err "can't execute installed rustc binary. installation may be broken. " \
|
||||
"if this is expected then rerun install.sh with \`--disable-verify\` " \
|
||||
"or \`make install\` with \`--disable-verify-install\`"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo
|
||||
echo " Rust is ready to roll."
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user