Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'./configure' now checks if 'config.toml' exists before writing to that destination #110123

Merged
merged 3 commits into from
Apr 19, 2023
Merged

Conversation

madsravn
Copy link
Contributor

@madsravn madsravn commented Apr 9, 2023

Fixes #110109

Instead of overwriting the current config.toml file, exit the ./configure script with a message stating why.

@rustbot
Copy link
Collaborator

rustbot commented Apr 9, 2023

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 9, 2023
Copy link
Member

@KittyBorgX KittyBorgX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the function definition can be ommited and if os.path.isfile() block be directly placed in if __name__ == "__main__"?
Since there are no other function calls of the quit_if_file_exists function and its being abstracted away unnessecerily.

@madsravn
Copy link
Contributor Author

Can the function definition can be ommited and if os.path.isfile() block be directly placed in if __name__ == "__main__"? Since there are no other function calls of the quit_if_file_exists function and its being abstracted away unnessecerily.

Thank you for your suggestion. If it isn't against any of the style guidelines, I would like to keep it in its own function. A function has a name which goes to show intent. Also I would like to clutter as little as possible in the main function as possible.

@KittyBorgX
Copy link
Member

A function has a name which goes to show intent.

A comment could perhaps do the same? Though I'm unsure of it. With regard to the style guide, I believe there are no rules against abstracting away to a function but I suggested doing against that since we're dealing with python and it could increase time usage and size of the file merely 😅

I'd suggest changing the quit() however as I mentioned in a former review. With regard to the abstraction of function, I think it's best to wait for Mark (the reviewer for this PR) to reply since that would provide a greater clarity.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good :) r=me with the two comments addressed.

src/bootstrap/configure.py Outdated Show resolved Hide resolved
src/bootstrap/configure.py Outdated Show resolved Hide resolved
@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 19, 2023
@jyn514
Copy link
Member

jyn514 commented Apr 19, 2023

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Apr 19, 2023

📌 Commit 010d797 has been approved by jyn514

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 19, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 19, 2023
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#110123 ('./configure' now checks if 'config.toml' exists before writing to that destination)
 - rust-lang#110429 (Spelling src bootstrap)
 - rust-lang#110430 (Spelling src ci)
 - rust-lang#110515 (Don't special-case download-rustc in `maybe_install_llvm`)
 - rust-lang#110521 (Fix `x test lint-docs linkchecker` when download-rustc is enabled)
 - rust-lang#110525 (Fix `tests/run-make-translation` when download-rustc is enabled)
 - rust-lang#110531 (small type system cleanup)
 - rust-lang#110533 (Missing blanket impl trait not public)
 - rust-lang#110540 (Fix wrong comment in rustc_hir/src/hir.rs)
 - rust-lang#110541 (Fix various configure bugs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 73bfa18 into rust-lang:master Apr 19, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 19, 2023
@xiangzhai
Copy link

xiangzhai commented Apr 21, 2023

Or just rename it as config.toml.bak?

diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index f95a97518c5..eaa4c71b4a3 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -525,7 +525,8 @@ def write_config_toml(writer, section_order, targets, sections):
 
 def quit_if_file_exists(file):
     if os.path.isfile(file):
-        err("Existing '" + file + "' detected.")
+        os.rename(file, file + ".bak")
+        print("Existing '" + file + "' detected.")
 
 if __name__ == "__main__":
     # If 'config.toml' already exists, exit the script at this point

./src/ci/docker/run.sh dist-your-image will exit:

sccache: Starting the server...
configure: error: Existing 'config.toml' detected.

Thanks,
Leslie Zhai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

./configure should not silently overwrite an existing config.toml
7 participants