From bfbdf0e5c763a8d66c2929dc6e54f0bfe3f16987 Mon Sep 17 00:00:00 2001 From: Autumn Date: Fri, 29 Jul 2022 11:58:02 -0700 Subject: [PATCH 1/4] don't log on update if no-self-update is enabled but auto-self-update=disable --- src/cli/rustup_mode.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 7659c3bf29..fa278e909a 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1036,7 +1036,7 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { check_rustup_update()?; } - if self_update::NEVER_SELF_UPDATE { + if self_update::NEVER_SELF_UPDATE && self_update_mode != SelfUpdateMode::Disable { info!("self-update is disabled for this build of rustup"); info!("any updates to rustup will need to be fetched with your system package manager") } @@ -1608,16 +1608,23 @@ fn set_profile(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { } fn set_auto_self_update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { - if self_update::NEVER_SELF_UPDATE { + cfg.set_auto_self_update(m.value_of("auto-self-update-mode").unwrap())?; + + let new_self_update_mode = cfg.get_self_update_mode()?; + if self_update::NEVER_SELF_UPDATE && new_self_update_mode != SelfUpdateMode::Disable { let mut args = crate::process().args_os(); let arg0 = args.next().map(PathBuf::from); let arg0 = arg0 .as_ref() .and_then(|a| a.to_str()) .ok_or(CLIError::NoExeName)?; - warn!("{} is built with the no-self-update feature: setting auto-self-update will not have any effect.",arg0); + warn!("{} is built with the no-self-update feature", arg0); + warn!( + "setting auto-self-update to {} won't lead to updates being checked", + new_self_update_mode.to_string(), + ); } - cfg.set_auto_self_update(m.value_of("auto-self-update-mode").unwrap())?; + Ok(utils::ExitCode(0)) } From a6a2ee31601fa0355d9e256d34794d01e5db69d3 Mon Sep 17 00:00:00 2001 From: Autumn Date: Fri, 29 Jul 2022 12:03:23 -0700 Subject: [PATCH 2/4] make auto-self-update=check-only work with no-self-update --- src/cli/rustup_mode.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index fa278e909a..c4ceda4a3f 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1032,11 +1032,11 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { cfg.temp_cfg.clean(); } - if !self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::CheckOnly { + if self_update_mode == SelfUpdateMode::CheckOnly { check_rustup_update()?; } - if self_update::NEVER_SELF_UPDATE && self_update_mode != SelfUpdateMode::Disable { + if self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::Enable { info!("self-update is disabled for this build of rustup"); info!("any updates to rustup will need to be fetched with your system package manager") } @@ -1610,8 +1610,7 @@ fn set_profile(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { fn set_auto_self_update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { cfg.set_auto_self_update(m.value_of("auto-self-update-mode").unwrap())?; - let new_self_update_mode = cfg.get_self_update_mode()?; - if self_update::NEVER_SELF_UPDATE && new_self_update_mode != SelfUpdateMode::Disable { + if self_update::NEVER_SELF_UPDATE && cfg.get_self_update_mode()? == SelfUpdateMode::Enable { let mut args = crate::process().args_os(); let arg0 = args.next().map(PathBuf::from); let arg0 = arg0 @@ -1619,10 +1618,7 @@ fn set_auto_self_update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result Date: Fri, 29 Jul 2022 12:07:42 -0700 Subject: [PATCH 3/4] check but don't install updates when no-self-update && auto-self-update=enable --- src/cli/rustup_mode.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index c4ceda4a3f..f7c7f20f23 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1032,8 +1032,9 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { cfg.temp_cfg.clean(); } - if self_update_mode == SelfUpdateMode::CheckOnly { - check_rustup_update()?; + match (&self_update_mode, self_update::NEVER_SELF_UPDATE) { + (SelfUpdateMode::CheckOnly, _) | (SelfUpdateMode::Enable, true) => check_rustup_update()?, + (SelfUpdateMode::Disable, _) | (SelfUpdateMode::Enable, false) => {} } if self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::Enable { @@ -1618,7 +1619,7 @@ fn set_auto_self_update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result Date: Fri, 29 Jul 2022 12:12:38 -0700 Subject: [PATCH 4/4] suggest setting auto-self-update to disable on update when built with no-self-update --- src/cli/rustup_mode.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index f7c7f20f23..b38d7c0477 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -1038,8 +1038,19 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { } if self_update::NEVER_SELF_UPDATE && self_update_mode == SelfUpdateMode::Enable { + let mut args = crate::process().args_os(); + let arg0 = args.next().map(PathBuf::from); + let arg0 = arg0 + .as_ref() + .and_then(|a| a.to_str()) + .ok_or(CLIError::NoExeName)?; + info!("self-update is disabled for this build of rustup"); - info!("any updates to rustup will need to be fetched with your system package manager") + info!("any updates to rustup will need to be fetched with your system package manager"); + info!( + "to suppress this message, run `{} set auto-self-update disable`", + arg0, + ); } Ok(utils::ExitCode(0))