1
Fork 0

Rollup merge of #113010 - klensy:ri-rls-fmt, r=ozkanonur

rust-installer & rls: remove exclusion from rustfmt & tidy

<strike>based on #112884</strike>

`rust-installer` and `rls` no longer submodules, but not removed from exclude list for rustfmt and tidy, preventing running fmt and lints on them.
This commit is contained in:
Michael Goulet 2023-07-05 08:45:42 -07:00 committed by GitHub
commit 1cb958a225
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 834 additions and 841 deletions

View file

@ -16,6 +16,8 @@ ignore = [
"tests", "tests",
# do not format submodules # do not format submodules
# FIXME: sync submodule list with tidy/bootstrap/etc
# tidy/src/walk.rs:filter_dirs
"library/backtrace", "library/backtrace",
"library/portable-simd", "library/portable-simd",
"library/stdarch", "library/stdarch",
@ -31,10 +33,8 @@ ignore = [
"src/tools/cargo", "src/tools/cargo",
"src/tools/clippy", "src/tools/clippy",
"src/tools/miri", "src/tools/miri",
"src/tools/rls",
"src/tools/rust-analyzer", "src/tools/rust-analyzer",
"src/tools/rustfmt", "src/tools/rustfmt",
"src/tools/rust-installer",
# these are ignored by a standard cargo fmt run # these are ignored by a standard cargo fmt run
"compiler/rustc_codegen_cranelift/y.rs", # running rustfmt breaks this file "compiler/rustc_codegen_cranelift/y.rs", # running rustfmt breaks this file

View file

@ -289,7 +289,7 @@ bootstrap_tool!(
Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true, allow_features = "test"; Compiletest, "src/tools/compiletest", "compiletest", is_unstable_tool = true, allow_features = "test";
BuildManifest, "src/tools/build-manifest", "build-manifest"; BuildManifest, "src/tools/build-manifest", "build-manifest";
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client"; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client";
RustInstaller, "src/tools/rust-installer", "rust-installer", is_external_tool = true; RustInstaller, "src/tools/rust-installer", "rust-installer";
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes"; RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes";
ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors"; ExpandYamlAnchors, "src/tools/expand-yaml-anchors", "expand-yaml-anchors";
LintDocs, "src/tools/lint-docs", "lint-docs"; LintDocs, "src/tools/lint-docs", "lint-docs";

View file

@ -17,8 +17,8 @@ log_line() {
local _line="$1" local _line="$1"
if [ -n "${LOGFILE-}" -a -e "${LOGFILE-}" ]; then if [ -n "${LOGFILE-}" -a -e "${LOGFILE-}" ]; then
echo "$_line" >> "$LOGFILE" echo "$_line" >> "$LOGFILE"
# Ignore errors, which may happen e.g. after the manifest dir is deleted # Ignore errors, which may happen e.g. after the manifest dir is deleted
fi fi
} }
@ -30,9 +30,9 @@ msg() {
verbose_msg() { verbose_msg() {
if [ -n "${CFG_VERBOSE-}" ]; then if [ -n "${CFG_VERBOSE-}" ]; then
msg "${1-}" msg "${1-}"
else else
log_line "install: ${1-}" log_line "install: ${1-}"
fi fi
} }
@ -44,13 +44,13 @@ step_msg() {
verbose_step_msg() { verbose_step_msg() {
if [ -n "${CFG_VERBOSE-}" ]; then if [ -n "${CFG_VERBOSE-}" ]; then
msg msg
msg "$1" msg "$1"
msg msg
else else
log_line "" log_line ""
log_line "install: $1" log_line "install: $1"
log_line "" log_line ""
fi fi
} }
@ -91,7 +91,7 @@ critical_need_ok() {
want_ok() { want_ok() {
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
warn "$1" warn "$1"
fi fi
} }
@ -321,40 +321,40 @@ uninstall_legacy() {
# Uninstall from legacy manifests # Uninstall from legacy manifests
local _md local _md
for _md in $_legacy_manifest_dirs; do for _md in $_legacy_manifest_dirs; do
# First, uninstall from the installation prefix. # First, uninstall from the installation prefix.
# Errors are warnings - try to rm everything in the manifest even if some fail. # Errors are warnings - try to rm everything in the manifest even if some fail.
if [ -f "$_abs_libdir/$_md/manifest" ] if [ -f "$_abs_libdir/$_md/manifest" ]
then then
# iterate through installed manifest and remove files # iterate through installed manifest and remove files
local _p; local _p;
while read _p; do while read _p; do
# the installed manifest contains absolute paths # the installed manifest contains absolute paths
msg "removing legacy file $_p" msg "removing legacy file $_p"
if [ -f "$_p" ] if [ -f "$_p" ]
then then
run rm -f "$_p" run rm -f "$_p"
want_ok "failed to remove $_p" want_ok "failed to remove $_p"
else else
warn "supposedly installed file $_p does not exist!" warn "supposedly installed file $_p does not exist!"
fi fi
done < "$_abs_libdir/$_md/manifest" done < "$_abs_libdir/$_md/manifest"
# If we fail to remove $md below, then the # If we fail to remove $md below, then the
# installed manifest will still be full; the installed manifest # installed manifest will still be full; the installed manifest
# needs to be empty before install. # needs to be empty before install.
msg "removing legacy manifest $_abs_libdir/$_md/manifest" msg "removing legacy manifest $_abs_libdir/$_md/manifest"
run rm -f "$_abs_libdir/$_md/manifest" run rm -f "$_abs_libdir/$_md/manifest"
# For the above reason, this is a hard error # For the above reason, this is a hard error
need_ok "failed to remove installed manifest" need_ok "failed to remove installed manifest"
# Remove $template_rel_manifest_dir directory # Remove $template_rel_manifest_dir directory
msg "removing legacy manifest dir $_abs_libdir/$_md" msg "removing legacy manifest dir $_abs_libdir/$_md"
run rm -R "$_abs_libdir/$_md" run rm -R "$_abs_libdir/$_md"
want_ok "failed to remove $_md" want_ok "failed to remove $_md"
_uninstalled_something=true _uninstalled_something=true
fi fi
done done
RETVAL="$_uninstalled_something" RETVAL="$_uninstalled_something"
@ -373,133 +373,134 @@ uninstall_components() {
uninstall_legacy "$_abs_libdir" uninstall_legacy "$_abs_libdir"
assert_nz "$RETVAL", "RETVAL" assert_nz "$RETVAL", "RETVAL"
if [ "$RETVAL" = true ]; then if [ "$RETVAL" = true ]; then
_uninstalled_something=true; _uninstalled_something=true;
fi fi
# Load the version of the installed installer # Load the version of the installed installer
local _installed_version= local _installed_version=
if [ -f "$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version" ]; then if [ -f "$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version" ]; then
_installed_version=`cat "$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version"` _installed_version=`cat "$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version"`
# Sanity check # Sanity check
if [ ! -n "$_installed_version" ]; then critical_err "rust installer version is empty"; fi if [ ! -n "$_installed_version" ]; then critical_err "rust installer version is empty"; fi
fi fi
# If there's something installed, then uninstall # If there's something installed, then uninstall
if [ -n "$_installed_version" ]; then if [ -n "$_installed_version" ]; then
# Check the version of the installed installer # Check the version of the installed installer
case "$_installed_version" in case "$_installed_version" in
# If this is a previous version, then upgrade in place to the # If this is a previous version, then upgrade in place to the
# current version before uninstalling. # current version before uninstalling.
2 ) 2 )
# The only change between version 2 -> 3 is that components are placed # The only change between version 2 -> 3 is that components are placed
# in subdirectories of the installer tarball. There are no changes # in subdirectories of the installer tarball. There are no changes
# to the installed data format, so nothing to do. # to the installed data format, so nothing to do.
;; ;;
# This is the current version. Nothing need to be done except uninstall. # This is the current version. Nothing need to be done except uninstall.
"$TEMPLATE_RUST_INSTALLER_VERSION") "$TEMPLATE_RUST_INSTALLER_VERSION")
;; ;;
# If this is an unknown (future) version then bail. # If this is an unknown (future) version then bail.
* ) * )
echo "The copy of $TEMPLATE_PRODUCT_NAME at $_dest_prefix was installed using an" echo "The copy of $TEMPLATE_PRODUCT_NAME at $_dest_prefix was installed using an"
echo "unknown version ($_installed_version) of rust-installer." echo "unknown version ($_installed_version) of rust-installer."
echo "Uninstall it first with the installer used for the original installation" echo "Uninstall it first with the installer used for the original installation"
echo "before continuing." echo "before continuing."
exit 1 exit 1
;; ;;
esac esac
local _md="$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR" local _md="$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR"
local _installed_components="$(cat "$_md/components")" local _installed_components="$(cat "$_md/components")"
# Uninstall (our components only) before reinstalling # Uninstall (our components only) before reinstalling
local _available_component local _available_component
for _available_component in $_components; do for _available_component in $_components; do
local _installed_component local _installed_component
for _installed_component in $_installed_components; do for _installed_component in $_installed_components; do
if [ "$_available_component" = "$_installed_component" ]; then if [ "$_available_component" = "$_installed_component" ]; then
msg "uninstalling component '$_available_component'" msg "uninstalling component '$_available_component'"
local _component_manifest="$_md/manifest-$_installed_component" local _component_manifest="$_md/manifest-$_installed_component"
# Sanity check: there should be a component manifest # Sanity check: there should be a component manifest
if [ ! -f "$_component_manifest" ]; then if [ ! -f "$_component_manifest" ]; then
critical_err "installed component '$_installed_component' has no manifest" critical_err "installed component '$_installed_component' has no manifest"
fi fi
# Iterate through installed component manifest and remove files # Iterate through installed component manifest and remove files
local _directive local _directive
while read _directive; do while read _directive; do
local _command=`echo $_directive | cut -f1 -d:` local _command=`echo $_directive | cut -f1 -d:`
local _file=`echo $_directive | cut -f2 -d:` local _file=`echo $_directive | cut -f2 -d:`
# Sanity checks # Sanity checks
if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi
if [ ! -n "$_file" ]; then critical_err "malformed installation directive"; fi if [ ! -n "$_file" ]; then critical_err "malformed installation directive"; fi
case "$_command" in case "$_command" in
file) file)
verbose_msg "removing file $_file" verbose_msg "removing file $_file"
if [ -f "$_file" ]; then if [ -f "$_file" ]; then
run rm -f "$_file" run rm -f "$_file"
want_ok "failed to remove $_file" want_ok "failed to remove $_file"
else else
warn "supposedly installed file $_file does not exist!" warn "supposedly installed file $_file does not exist!"
fi fi
;; ;;
dir) dir)
verbose_msg "removing directory $_file" verbose_msg "removing directory $_file"
run rm -r "$_file" run rm -r "$_file"
want_ok "unable to remove directory $_file" want_ok "unable to remove directory $_file"
;; ;;
*) *)
critical_err "unknown installation directive" critical_err "unknown installation directive"
;; ;;
esac esac
done < "$_component_manifest" done < "$_component_manifest"
# Remove the installed component manifest # Remove the installed component manifest
verbose_msg "removing component manifest $_component_manifest" verbose_msg "removing component manifest $_component_manifest"
run rm "$_component_manifest" run rm "$_component_manifest"
# This is a hard error because the installation is unrecoverable # This is a hard error because the installation is unrecoverable
critical_need_ok "failed to remove installed manifest for component '$_installed_component'" local _err_cant_r_manifest="failed to remove installed manifest for component"
critical_need_ok "$_err_cant_r_manifest '$_installed_component'"
# Update the installed component list # Update the installed component list
local _modified_components="$(sed "/^$_installed_component\$/d" "$_md/components")" local _modified_components="$(sed "/^$_installed_component\$/d" "$_md/components")"
write_to_file "$_modified_components" "$_md/components" write_to_file "$_modified_components" "$_md/components"
critical_need_ok "failed to update installed component list" critical_need_ok "failed to update installed component list"
fi fi
done done
done done
# If there are no remaining components delete the manifest directory, # If there are no remaining components delete the manifest directory,
# but only if we're doing an uninstall - if we're doing an install, # but only if we're doing an uninstall - if we're doing an install,
# then leave the manifest directory around to hang onto the logs, # then leave the manifest directory around to hang onto the logs,
# and any files not managed by the installer. # and any files not managed by the installer.
if [ -n "${CFG_UNINSTALL-}" ]; then if [ -n "${CFG_UNINSTALL-}" ]; then
local _remaining_components="$(cat "$_md/components")" local _remaining_components="$(cat "$_md/components")"
if [ ! -n "$_remaining_components" ]; then if [ ! -n "$_remaining_components" ]; then
verbose_msg "removing manifest directory $_md" verbose_msg "removing manifest directory $_md"
run rm -r "$_md" run rm -r "$_md"
want_ok "failed to remove $_md" want_ok "failed to remove $_md"
maybe_unconfigure_ld maybe_unconfigure_ld
fi fi
fi fi
_uninstalled_something=true _uninstalled_something=true
fi fi
# There's no installed version. If we were asked to uninstall, then that's a problem. # There's no installed version. If we were asked to uninstall, then that's a problem.
if [ -n "${CFG_UNINSTALL-}" -a "$_uninstalled_something" = false ] if [ -n "${CFG_UNINSTALL-}" -a "$_uninstalled_something" = false ]
then then
err "unable to find installation manifest at $CFG_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR" err "unable to find installation manifest at $CFG_LIBDIR/$TEMPLATE_REL_MANIFEST_DIR"
fi fi
} }
@ -512,73 +513,73 @@ install_components() {
local _component local _component
for _component in $_components; do for _component in $_components; do
msg "installing component '$_component'" msg "installing component '$_component'"
# The file name of the manifest we're installing from # The file name of the manifest we're installing from
local _input_manifest="$_src_dir/$_component/manifest.in" local _input_manifest="$_src_dir/$_component/manifest.in"
# Sanity check: do we have our input manifests? # Sanity check: do we have our input manifests?
if [ ! -f "$_input_manifest" ]; then if [ ! -f "$_input_manifest" ]; then
critical_err "manifest for $_component does not exist at $_input_manifest" critical_err "manifest for $_component does not exist at $_input_manifest"
fi fi
# The installed manifest directory # The installed manifest directory
local _md="$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR" local _md="$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR"
# The file name of the manifest we're going to create during install # The file name of the manifest we're going to create during install
local _installed_manifest="$_md/manifest-$_component" local _installed_manifest="$_md/manifest-$_component"
# Create the installed manifest, which we will fill in with absolute file paths # Create the installed manifest, which we will fill in with absolute file paths
touch "$_installed_manifest" touch "$_installed_manifest"
critical_need_ok "failed to create installed manifest" critical_need_ok "failed to create installed manifest"
# Add this component to the installed component list # Add this component to the installed component list
append_to_file "$_component" "$_md/components" append_to_file "$_component" "$_md/components"
critical_need_ok "failed to update components list for $_component" critical_need_ok "failed to update components list for $_component"
# Now install, iterate through the new manifest and copy files # Now install, iterate through the new manifest and copy files
local _directive local _directive
while read _directive; do while read _directive; do
local _command=`echo $_directive | cut -f1 -d:` local _command=`echo $_directive | cut -f1 -d:`
local _file=`echo $_directive | cut -f2 -d:` local _file=`echo $_directive | cut -f2 -d:`
# Sanity checks # Sanity checks
if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi
if [ ! -n "$_file" ]; then critical_err "malformed installation directive"; fi if [ ! -n "$_file" ]; then critical_err "malformed installation directive"; fi
# Decide the destination of the file # Decide the destination of the file
local _file_install_path="$_dest_prefix/$_file" local _file_install_path="$_dest_prefix/$_file"
if echo "$_file" | grep "^etc/" > /dev/null if echo "$_file" | grep "^etc/" > /dev/null
then then
local _f="$(echo "$_file" | sed 's/^etc\///')" local _f="$(echo "$_file" | sed 's/^etc\///')"
_file_install_path="$CFG_SYSCONFDIR/$_f" _file_install_path="$CFG_SYSCONFDIR/$_f"
fi fi
if echo "$_file" | grep "^bin/" > /dev/null if echo "$_file" | grep "^bin/" > /dev/null
then then
local _f="$(echo "$_file" | sed 's/^bin\///')" local _f="$(echo "$_file" | sed 's/^bin\///')"
_file_install_path="$CFG_BINDIR/$_f" _file_install_path="$CFG_BINDIR/$_f"
fi fi
if echo "$_file" | grep "^lib/" > /dev/null if echo "$_file" | grep "^lib/" > /dev/null
then then
local _f="$(echo "$_file" | sed 's/^lib\///')" local _f="$(echo "$_file" | sed 's/^lib\///')"
_file_install_path="$CFG_LIBDIR/$_f" _file_install_path="$CFG_LIBDIR/$_f"
fi fi
if echo "$_file" | grep "^share" > /dev/null if echo "$_file" | grep "^share" > /dev/null
then then
local _f="$(echo "$_file" | sed 's/^share\///')" local _f="$(echo "$_file" | sed 's/^share\///')"
_file_install_path="$CFG_DATADIR/$_f" _file_install_path="$CFG_DATADIR/$_f"
fi fi
if echo "$_file" | grep "^share/man/" > /dev/null if echo "$_file" | grep "^share/man/" > /dev/null
then then
local _f="$(echo "$_file" | sed 's/^share\/man\///')" local _f="$(echo "$_file" | sed 's/^share\/man\///')"
_file_install_path="$CFG_MANDIR/$_f" _file_install_path="$CFG_MANDIR/$_f"
fi fi
# HACK: Try to support overriding --docdir. Paths with the form # HACK: Try to support overriding --docdir. Paths with the form
# "share/doc/$product/" can be redirected to a single --docdir # "share/doc/$product/" can be redirected to a single --docdir
@ -592,69 +593,69 @@ install_components() {
# this problem to be a big deal in practice. # this problem to be a big deal in practice.
if [ "$CFG_DOCDIR" != "<default>" ] if [ "$CFG_DOCDIR" != "<default>" ]
then then
if echo "$_file" | grep "^share/doc/" > /dev/null if echo "$_file" | grep "^share/doc/" > /dev/null
then then
local _f="$(echo "$_file" | sed 's/^share\/doc\/[^/]*\///')" local _f="$(echo "$_file" | sed 's/^share\/doc\/[^/]*\///')"
_file_install_path="$CFG_DOCDIR/$_f" _file_install_path="$CFG_DOCDIR/$_f"
fi fi
fi fi
# Make sure there's a directory for it # Make sure there's a directory for it
make_dir_recursive "$(dirname "$_file_install_path")" make_dir_recursive "$(dirname "$_file_install_path")"
critical_need_ok "directory creation failed" critical_need_ok "directory creation failed"
# Make the path absolute so we can uninstall it later without # Make the path absolute so we can uninstall it later without
# starting from the installation cwd # starting from the installation cwd
absolutify "$_file_install_path" absolutify "$_file_install_path"
_file_install_path="$RETVAL" _file_install_path="$RETVAL"
assert_nz "$_file_install_path" "file_install_path" assert_nz "$_file_install_path" "file_install_path"
case "$_command" in case "$_command" in
file ) file )
verbose_msg "copying file $_file_install_path" verbose_msg "copying file $_file_install_path"
maybe_backup_path "$_file_install_path" maybe_backup_path "$_file_install_path"
if echo "$_file" | grep "^bin/" > /dev/null || test -x "$_src_dir/$_component/$_file" if echo "$_file" | grep "^bin/" > /dev/null || test -x "$_src_dir/$_component/$_file"
then then
run cp "$_src_dir/$_component/$_file" "$_file_install_path" run cp "$_src_dir/$_component/$_file" "$_file_install_path"
run chmod 755 "$_file_install_path" run chmod 755 "$_file_install_path"
else else
run cp "$_src_dir/$_component/$_file" "$_file_install_path" run cp "$_src_dir/$_component/$_file" "$_file_install_path"
run chmod 644 "$_file_install_path" run chmod 644 "$_file_install_path"
fi fi
critical_need_ok "file creation failed" critical_need_ok "file creation failed"
# Update the manifest # Update the manifest
append_to_file "file:$_file_install_path" "$_installed_manifest" append_to_file "file:$_file_install_path" "$_installed_manifest"
critical_need_ok "failed to update manifest" critical_need_ok "failed to update manifest"
;; ;;
dir ) dir )
verbose_msg "copying directory $_file_install_path" verbose_msg "copying directory $_file_install_path"
maybe_backup_path "$_file_install_path" maybe_backup_path "$_file_install_path"
run cp -R "$_src_dir/$_component/$_file" "$_file_install_path" run cp -R "$_src_dir/$_component/$_file" "$_file_install_path"
critical_need_ok "failed to copy directory" critical_need_ok "failed to copy directory"
# Set permissions. 0755 for dirs, 644 for files # Set permissions. 0755 for dirs, 644 for files
run chmod -R u+rwX,go+rX,go-w "$_file_install_path" run chmod -R u+rwX,go+rX,go-w "$_file_install_path"
critical_need_ok "failed to set permissions on directory" critical_need_ok "failed to set permissions on directory"
# Update the manifest # Update the manifest
append_to_file "dir:$_file_install_path" "$_installed_manifest" append_to_file "dir:$_file_install_path" "$_installed_manifest"
critical_need_ok "failed to update manifest" critical_need_ok "failed to update manifest"
;; ;;
*) *)
critical_err "unknown installation directive" critical_err "unknown installation directive"
;; ;;
esac esac
done < "$_input_manifest" done < "$_input_manifest"
done done
} }
@ -667,33 +668,35 @@ maybe_configure_ld() {
if [ "$_ostype" = "Linux" -a ! -n "${CFG_DISABLE_LDCONFIG-}" ]; then if [ "$_ostype" = "Linux" -a ! -n "${CFG_DISABLE_LDCONFIG-}" ]; then
# Fedora-based systems do not configure the dynamic linker to look # Fedora-based systems do not configure the dynamic linker to look
# /usr/local/lib, which is our default installation directory. To # /usr/local/lib, which is our default installation directory. To
# make things just work, try to put that directory in # make things just work, try to put that directory in
# /etc/ld.so.conf.d/rust-installer-v1 so ldconfig picks it up. # /etc/ld.so.conf.d/rust-installer-v1 so ldconfig picks it up.
# Issue #30. # Issue #30.
# #
# This will get rm'd when the last component is uninstalled in # This will get rm'd when the last component is uninstalled in
# maybe_unconfigure_ld. # maybe_unconfigure_ld.
if [ "$_abs_libdir" = "/usr/local/lib" -a -d "/etc/ld.so.conf.d" ]; then if [ "$_abs_libdir" = "/usr/local/lib" -a -d "/etc/ld.so.conf.d" ]; then
echo "$_abs_libdir" > "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf" echo "$_abs_libdir" > "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# This shouldn't happen if we've gotten this far # This shouldn't happen if we've gotten this far
# installing to /usr/local # installing to /usr/local
warn "failed to update /etc/ld.so.conf.d. this is unexpected" warn "failed to update /etc/ld.so.conf.d. this is unexpected"
fi fi
fi fi
verbose_msg "running ldconfig" verbose_msg "running ldconfig"
if [ -n "${CFG_VERBOSE-}" ]; then if [ -n "${CFG_VERBOSE-}" ]; then
ldconfig ldconfig
else else
ldconfig 2> /dev/null ldconfig 2> /dev/null
fi fi
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
warn "failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error" local _warn_s="failed to run ldconfig. this may happen when \
fi not installing as root. run with --verbose to see the error"
warn "$_warn_s"
fi
fi fi
} }
@ -702,7 +705,7 @@ maybe_unconfigure_ld() {
assert_nz "$_ostype" "ostype" assert_nz "$_ostype" "ostype"
if [ "$_ostype" != "Linux" ]; then if [ "$_ostype" != "Linux" ]; then
return 0 return 0
fi fi
rm "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf" 2> /dev/null rm "/etc/ld.so.conf.d/rust-installer-v1-$TEMPLATE_REL_MANIFEST_DIR.conf" 2> /dev/null
@ -714,9 +717,9 @@ maybe_backup_path() {
local _file_install_path="$1" local _file_install_path="$1"
if [ -e "$_file_install_path" ]; then if [ -e "$_file_install_path" ]; then
msg "backing up existing file at $_file_install_path" msg "backing up existing file at $_file_install_path"
run mv -f "$_file_install_path" "$_file_install_path.old" run mv -f "$_file_install_path" "$_file_install_path.old"
critical_need_ok "failed to back up $_file_install_path" critical_need_ok "failed to back up $_file_install_path"
fi fi
} }
@ -742,7 +745,7 @@ do_preflight_sanity_checks() {
touch "$CFG_LIBDIR/rust-install-probe" > /dev/null touch "$CFG_LIBDIR/rust-install-probe" > /dev/null
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
err "can't write to destination. consider \`sudo\`." err "can't write to destination. consider \`sudo\`."
fi fi
rm "$CFG_LIBDIR/rust-install-probe" rm "$CFG_LIBDIR/rust-install-probe"
need_ok "failed to remove install probe" need_ok "failed to remove install probe"
@ -752,7 +755,7 @@ do_preflight_sanity_checks() {
verbose_msg "verifying destination is not the same as source" verbose_msg "verifying destination is not the same as source"
local _prefix_dir="$(abs_path "$dest_prefix")" local _prefix_dir="$(abs_path "$dest_prefix")"
if [ "$_src_dir" = "$_dest_prefix" -a "${CFG_UNINSTALL-}" != 1 ]; then if [ "$_src_dir" = "$_dest_prefix" -a "${CFG_UNINSTALL-}" != 1 ]; then
err "cannot install to same directory as installer" err "cannot install to same directory as installer"
fi fi
} }
@ -857,8 +860,8 @@ src_basename="$(basename "$0")"
# which just means 'uninstall my components'. # which just means 'uninstall my components'.
if [ "$src_basename" = "uninstall.sh" ]; then if [ "$src_basename" = "uninstall.sh" ]; then
if [ "${*:-}" != "" ]; then if [ "${*:-}" != "" ]; then
# Currently don't know what to do with arguments in this mode # Currently don't know what to do with arguments in this mode
err "uninstall.sh does not take any arguments" err "uninstall.sh does not take any arguments"
fi fi
CFG_UNINSTALL=1 CFG_UNINSTALL=1
CFG_DESTDIR_PREFIX="$(abs_path "$src_dir/../../")" CFG_DESTDIR_PREFIX="$(abs_path "$src_dir/../../")"
@ -885,7 +888,7 @@ if [ -n "${CFG_LIST_COMPONENTS-}" ]; then
echo "# Available components" echo "# Available components"
echo echo
for component in $components; do for component in $components; do
echo "* $component" echo "* $component"
done done
echo echo
exit 0 exit 0
@ -897,15 +900,15 @@ if [ -n "$CFG_COMPONENTS" ]; then
# Remove commas # Remove commas
user_components="$(echo "$CFG_COMPONENTS" | sed "s/,/ /g")" user_components="$(echo "$CFG_COMPONENTS" | sed "s/,/ /g")"
for user_component in $user_components; do for user_component in $user_components; do
found=false found=false
for my_component in $components; do for my_component in $components; do
if [ "$user_component" = "$my_component" ]; then if [ "$user_component" = "$my_component" ]; then
found=true found=true
fi fi
done done
if [ "$found" = false ]; then if [ "$found" = false ]; then
err "unknown component: $user_component" err "unknown component: $user_component"
fi fi
done done
components="$user_components" components="$user_components"
fi fi
@ -937,9 +940,9 @@ fi
if [ -z "$components" ]; then if [ -z "$components" ]; then
if [ -z "${CFG_UNINSTALL-}" ]; then if [ -z "${CFG_UNINSTALL-}" ]; then
err "no components selected for installation" err "no components selected for installation"
else else
err "no components selected for uninstallation" err "no components selected for uninstallation"
fi fi
fi fi
@ -977,7 +980,9 @@ make_dir_recursive "$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR"
need_ok "failed to create $TEMPLATE_REL_MANIFEST_DIR" need_ok "failed to create $TEMPLATE_REL_MANIFEST_DIR"
# Drop the version number into the manifest dir # Drop the version number into the manifest dir
write_to_file "$TEMPLATE_RUST_INSTALLER_VERSION" "$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version" write_to_file "$TEMPLATE_RUST_INSTALLER_VERSION" \
"$abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/rust-installer-version"
critical_need_ok "failed to write installer version" critical_need_ok "failed to write installer version"
# Install the uninstaller # Install the uninstaller
@ -992,5 +997,3 @@ maybe_configure_ld "$abs_libdir"
echo echo
echo " $TEMPLATE_SUCCESS_MESSAGE" echo " $TEMPLATE_SUCCESS_MESSAGE"
echo echo

View file

@ -71,25 +71,16 @@ impl Combiner {
// Merge each installer into the work directory of the new installer. // Merge each installer into the work directory of the new installer.
let components = create_new_file(package_dir.join("components"))?; let components = create_new_file(package_dir.join("components"))?;
for input_tarball in self for input_tarball in self.input_tarballs.split(',').map(str::trim).filter(|s| !s.is_empty())
.input_tarballs
.split(',')
.map(str::trim)
.filter(|s| !s.is_empty())
{ {
// Extract the input tarballs // Extract the input tarballs
let compression = let compression =
CompressionFormat::detect_from_path(input_tarball).ok_or_else(|| { CompressionFormat::detect_from_path(input_tarball).ok_or_else(|| {
anyhow::anyhow!("couldn't figure out the format of {}", input_tarball) anyhow::anyhow!("couldn't figure out the format of {}", input_tarball)
})?; })?;
Archive::new(compression.decode(input_tarball)?) Archive::new(compression.decode(input_tarball)?).unpack(&self.work_dir).with_context(
.unpack(&self.work_dir) || format!("unable to extract '{}' into '{}'", &input_tarball, self.work_dir),
.with_context(|| { )?;
format!(
"unable to extract '{}' into '{}'",
&input_tarball, self.work_dir
)
})?;
let pkg_name = let pkg_name =
input_tarball.trim_end_matches(&format!(".tar.{}", compression.extension())); input_tarball.trim_end_matches(&format!(".tar.{}", compression.extension()));
@ -126,12 +117,8 @@ impl Combiner {
// Write the installer version. // Write the installer version.
let version = package_dir.join("rust-installer-version"); let version = package_dir.join("rust-installer-version");
writeln!( writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
create_new_file(version)?, .context("failed to write new installer version")?;
"{}",
crate::RUST_INSTALLER_VERSION
)
.context("failed to write new installer version")?;
// Copy the overlay. // Copy the overlay.
if !self.non_installed_overlay.is_empty() { if !self.non_installed_overlay.is_empty() {

View file

@ -86,12 +86,8 @@ impl Generator {
// Write the installer version (only used by combine-installers.sh) // Write the installer version (only used by combine-installers.sh)
let version = package_dir.join("rust-installer-version"); let version = package_dir.join("rust-installer-version");
writeln!( writeln!(create_new_file(version)?, "{}", crate::RUST_INSTALLER_VERSION)
create_new_file(version)?, .context("failed to write new installer version")?;
"{}",
crate::RUST_INSTALLER_VERSION
)
.context("failed to write new installer version")?;
// Copy the overlay // Copy the overlay
if !self.non_installed_overlay.is_empty() { if !self.non_installed_overlay.is_empty() {
@ -128,33 +124,19 @@ impl Generator {
/// Copies the `src` directory recursively to `dst`, writing `manifest.in` too. /// Copies the `src` directory recursively to `dst`, writing `manifest.in` too.
fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> { fn copy_and_manifest(src: &Path, dst: &Path, bulk_dirs: &str) -> Result<()> {
let mut manifest = create_new_file(dst.join("manifest.in"))?; let mut manifest = create_new_file(dst.join("manifest.in"))?;
let bulk_dirs: Vec<_> = bulk_dirs let bulk_dirs: Vec<_> = bulk_dirs.split(',').filter(|s| !s.is_empty()).map(Path::new).collect();
.split(',')
.filter(|s| !s.is_empty())
.map(Path::new)
.collect();
let mut paths = BTreeSet::new(); let mut paths = BTreeSet::new();
copy_with_callback(src, dst, |path, file_type| { copy_with_callback(src, dst, |path, file_type| {
// We need paths to be compatible with both Unix and Windows. // We need paths to be compatible with both Unix and Windows.
if path if path.components().filter_map(|c| c.as_os_str().to_str()).any(|s| s.contains('\\')) {
.components() bail!("rust-installer doesn't support '\\' in path components: {:?}", path);
.filter_map(|c| c.as_os_str().to_str())
.any(|s| s.contains('\\'))
{
bail!(
"rust-installer doesn't support '\\' in path components: {:?}",
path
);
} }
// Normalize to Unix-style path separators. // Normalize to Unix-style path separators.
let normalized_string; let normalized_string;
let mut string = path.to_str().ok_or_else(|| { let mut string = path.to_str().ok_or_else(|| {
format_err!( format_err!("rust-installer doesn't support non-Unicode paths: {:?}", path)
"rust-installer doesn't support non-Unicode paths: {:?}",
path
)
})?; })?;
if string.contains('\\') { if string.contains('\\') {
normalized_string = string.replace('\\', "/"); normalized_string = string.replace('\\', "/");

View file

@ -19,8 +19,12 @@ fn main() -> Result<()> {
let command_line = CommandLine::parse(); let command_line = CommandLine::parse();
match command_line.command { match command_line.command {
Subcommand::Combine(combiner) => combiner.run().context("failed to combine installers")?, Subcommand::Combine(combiner) => combiner.run().context("failed to combine installers")?,
Subcommand::Generate(generator) => generator.run().context("failed to generate installer")?, Subcommand::Generate(generator) => {
Subcommand::Script(scripter) => scripter.run().context("failed to generate installation script")?, generator.run().context("failed to generate installer")?
}
Subcommand::Script(scripter) => {
scripter.run().context("failed to generate installation script")?
}
Subcommand::Tarball(tarballer) => tarballer.run().context("failed to generate tarballs")?, Subcommand::Tarball(tarballer) => tarballer.run().context("failed to generate tarballs")?,
} }
Ok(()) Ok(())

View file

@ -32,22 +32,19 @@ actor! {
impl Scripter { impl Scripter {
/// Generates the actual installer script /// Generates the actual installer script
pub fn run(self) -> Result<()> { pub fn run(self) -> Result<()> {
// Replace dashes in the success message with spaces (our arg handling botches spaces) // Replace dashes in the product name with spaces (our arg handling botches spaces)
// TODO: still needed? Kept for compatibility for now. // FIXME: still needed? Kept for compatibility for now.
let product_name = self.product_name.replace('-', " "); let product_name = self.product_name.replace('-', " ");
// Replace dashes in the success message with spaces (our arg handling botches spaces) // Replace dashes in the success message with spaces (our arg handling botches spaces)
// TODO: still needed? Kept for compatibility for now. // FIXME: still needed? Kept for compatibility for now.
let success_message = self.success_message.replace('-', " "); let success_message = self.success_message.replace('-', " ");
let script = TEMPLATE let script = TEMPLATE
.replace("%%TEMPLATE_PRODUCT_NAME%%", &sh_quote(&product_name)) .replace("%%TEMPLATE_PRODUCT_NAME%%", &sh_quote(&product_name))
.replace("%%TEMPLATE_REL_MANIFEST_DIR%%", &self.rel_manifest_dir) .replace("%%TEMPLATE_REL_MANIFEST_DIR%%", &self.rel_manifest_dir)
.replace("%%TEMPLATE_SUCCESS_MESSAGE%%", &sh_quote(&success_message)) .replace("%%TEMPLATE_SUCCESS_MESSAGE%%", &sh_quote(&success_message))
.replace( .replace("%%TEMPLATE_LEGACY_MANIFEST_DIRS%%", &sh_quote(&self.legacy_manifest_dirs))
"%%TEMPLATE_LEGACY_MANIFEST_DIRS%%",
&sh_quote(&self.legacy_manifest_dirs),
)
.replace( .replace(
"%%TEMPLATE_RUST_INSTALLER_VERSION%%", "%%TEMPLATE_RUST_INSTALLER_VERSION%%",
&sh_quote(&crate::RUST_INSTALLER_VERSION), &sh_quote(&crate::RUST_INSTALLER_VERSION),

View file

@ -58,10 +58,7 @@ impl Tarballer {
let buf = BufWriter::with_capacity(1024 * 1024, encoder); let buf = BufWriter::with_capacity(1024 * 1024, encoder);
let mut builder = Builder::new(buf); let mut builder = Builder::new(buf);
let pool = rayon::ThreadPoolBuilder::new() let pool = rayon::ThreadPoolBuilder::new().num_threads(2).build().unwrap();
.num_threads(2)
.build()
.unwrap();
pool.install(move || { pool.install(move || {
for path in dirs { for path in dirs {
let src = Path::new(&self.work_dir).join(&path); let src = Path::new(&self.work_dir).join(&path);
@ -122,11 +119,7 @@ where
let name = name.as_ref(); let name = name.as_ref();
if !name.is_relative() && !name.starts_with(root) { if !name.is_relative() && !name.starts_with(root) {
bail!( bail!("input '{}' is not in work dir '{}'", name.display(), root.display());
"input '{}' is not in work dir '{}'",
name.display(),
root.display()
);
} }
let mut dirs = vec![]; let mut dirs = vec![];

View file

@ -15,8 +15,7 @@ use std::os::windows::fs::symlink_file;
/// Converts a `&Path` to a UTF-8 `&str`. /// Converts a `&Path` to a UTF-8 `&str`.
pub fn path_to_str(path: &Path) -> Result<&str> { pub fn path_to_str(path: &Path) -> Result<&str> {
path.to_str() path.to_str().ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
.ok_or_else(|| format_err!("path is not valid UTF-8 '{}'", path.display()))
} }
/// Wraps `fs::copy` with a nicer error message. /// Wraps `fs::copy` with a nicer error message.
@ -27,11 +26,7 @@ pub fn copy<P: AsRef<Path>, Q: AsRef<Path>>(from: P, to: Q) -> Result<u64> {
Ok(0) Ok(0)
} else { } else {
let amt = fs::copy(&from, &to).with_context(|| { let amt = fs::copy(&from, &to).with_context(|| {
format!( format!("failed to copy '{}' to '{}'", from.as_ref().display(), to.as_ref().display())
"failed to copy '{}' to '{}'",
from.as_ref().display(),
to.as_ref().display()
)
})?; })?;
Ok(amt) Ok(amt)
} }
@ -123,8 +118,12 @@ where
} }
macro_rules! actor_field_default { macro_rules! actor_field_default {
() => { Default::default() }; () => {
(= $expr:expr) => { $expr.into() } Default::default()
};
(= $expr:expr) => {
$expr.into()
};
} }
/// Creates an "actor" with default values, setters for all fields, and Clap parser support. /// Creates an "actor" with default values, setters for all fields, and Clap parser support.

File diff suppressed because it is too large Load diff

View file

@ -95,17 +95,41 @@ mod os_impl {
return true; return true;
} }
// FIXME: check when rust-installer test sh files will be removed,
// and then remove them from exclude list
const RI_EXCLUSION_LIST: &[&str] = &[
"src/tools/rust-installer/test/image1/bin/program",
"src/tools/rust-installer/test/image1/bin/program2",
"src/tools/rust-installer/test/image1/bin/bad-bin",
"src/tools/rust-installer/test/image2/bin/oldprogram",
"src/tools/rust-installer/test/image3/bin/cargo",
];
fn filter_rust_installer_no_so_bins(path: &Path) -> bool {
RI_EXCLUSION_LIST.iter().any(|p| path.ends_with(p))
}
#[cfg(unix)] #[cfg(unix)]
pub fn check(path: &Path, bad: &mut bool) { pub fn check(path: &Path, bad: &mut bool) {
use std::ffi::OsStr; use std::ffi::OsStr;
const ALLOWED: &[&str] = &["configure", "x"]; const ALLOWED: &[&str] = &["configure", "x"];
for p in RI_EXCLUSION_LIST {
if !path.join(Path::new(p)).exists() {
tidy_error!(bad, "rust-installer test bins missed: {p}");
}
}
// FIXME: we don't need to look at all binaries, only files that have been modified in this branch // FIXME: we don't need to look at all binaries, only files that have been modified in this branch
// (e.g. using `git ls-files`). // (e.g. using `git ls-files`).
walk_no_read( walk_no_read(
&[path], &[path],
|path, _is_dir| filter_dirs(path) || path.ends_with("src/etc"), |path, _is_dir| {
filter_dirs(path)
|| path.ends_with("src/etc")
|| filter_rust_installer_no_so_bins(path)
},
&mut |entry| { &mut |entry| {
let file = entry.path(); let file = entry.path();
let extension = file.extension(); let extension = file.extension();

View file

@ -4,6 +4,8 @@ use std::{ffi::OsStr, fs::File, io::Read, path::Path};
/// The default directory filter. /// The default directory filter.
pub fn filter_dirs(path: &Path) -> bool { pub fn filter_dirs(path: &Path) -> bool {
// FIXME: sync submodule exclusion list with rustfmt.toml
// bootstrap/etc
let skip = [ let skip = [
"tidy-test-file", "tidy-test-file",
"compiler/rustc_codegen_cranelift", "compiler/rustc_codegen_cranelift",
@ -15,9 +17,7 @@ pub fn filter_dirs(path: &Path) -> bool {
"src/tools/cargo", "src/tools/cargo",
"src/tools/clippy", "src/tools/clippy",
"src/tools/miri", "src/tools/miri",
"src/tools/rls",
"src/tools/rust-analyzer", "src/tools/rust-analyzer",
"src/tools/rust-installer",
"src/tools/rustfmt", "src/tools/rustfmt",
"src/doc/book", "src/doc/book",
"src/doc/edition-guide", "src/doc/edition-guide",