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
Implement the HOMEBREW_INSTALL_CLEANUP env to trigger cleanup on reinstall/install/upgrade #5165
Implement the HOMEBREW_INSTALL_CLEANUP env to trigger cleanup on reinstall/install/upgrade #5165
Conversation
setup_test_formula "testball" | ||
# allow(ENV).to receive(:[]).and_call_original | ||
# allow(ENV).to receive(:[]).with("HOMEBREW_INSTALL_CLEANUP").and_return("1") | ||
ENV["HOMEBREW_INSTALL_CLEANUP"] = "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried both manually setting into ENV
and mocking it out as shown in the 2 commented lines. I wasn't able to get either working even though I could confirm the functionality manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wojonatior Ideally we wouldn't add another integration test for this (they are really slow). Either add a unit test or omit one entirely.
Library/Homebrew/cmd/upgrade.rb
Outdated
@@ -3,7 +3,7 @@ | |||
#: | |||
#: Options for the `install` command are also valid here. | |||
#: | |||
#: If `--cleanup` is specified or `HOMEBREW_UPGRADE_CLEANUP` is set then remove | |||
#: If `--cleanup` is specified, `HOMEBREW_INSTALL_CLEANUP` or `HOMEBREW_UPGRADE_CLEANUP` is set then remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a clarification around the original feature, is the intent to keep both ENVs or to enhance what the old one did as well a rename it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wojonatior Good question 👍 Let's remove the documentation for HOMEBREW_UPGRADE_CLEANUP
in favour of HOMEBREW_INSTALL_CLEANUP
but keep the HOMEBREW_UPGRADE_CLEANUP
variable functional for people who are still using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start here! I'd like to see cmd/install
changed similarly before this is merged.
setup_test_formula "testball" | ||
# allow(ENV).to receive(:[]).and_call_original | ||
# allow(ENV).to receive(:[]).with("HOMEBREW_INSTALL_CLEANUP").and_return("1") | ||
ENV["HOMEBREW_INSTALL_CLEANUP"] = "1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wojonatior Ideally we wouldn't add another integration test for this (they are really slow). Either add a unit test or omit one entirely.
Library/Homebrew/cmd/upgrade.rb
Outdated
@@ -3,7 +3,7 @@ | |||
#: | |||
#: Options for the `install` command are also valid here. | |||
#: | |||
#: If `--cleanup` is specified or `HOMEBREW_UPGRADE_CLEANUP` is set then remove | |||
#: If `--cleanup` is specified, `HOMEBREW_INSTALL_CLEANUP` or `HOMEBREW_UPGRADE_CLEANUP` is set then remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wojonatior Good question 👍 Let's remove the documentation for HOMEBREW_UPGRADE_CLEANUP
in favour of HOMEBREW_INSTALL_CLEANUP
but keep the HOMEBREW_UPGRADE_CLEANUP
variable functional for people who are still using it.
I've added the formula cleanup to the |
Library/Homebrew/cmd/install.rb
Outdated
@@ -73,6 +73,9 @@ | |||
#: | |||
#: If `--git` (or `-g`) is passed, Homebrew will create a Git repository, useful for | |||
#: creating patches to the software. | |||
#: | |||
#: If `HOMEBREW_INSTALL_CLEANUP` is set then remove previously installed versions | |||
#: of upgraded <formulae>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also will clean up the HOMEBREW_CACHE for that formula
@Wojonatior After fixing the docs please run |
Formula cleanup 👍. Could have regular cleanup occurring every e.g. 100 installs or something, though? Thoughts?
Nothing specifically but there may be leftover cache and cellar entries that it's worth cleaning up at this stage. |
@MikeMcQuaid I updated the docs and the manpage. I like the idea of the occasional full clean. Would it make sense to count that in the formula clean or specifically for the install? Is there a pattern established somewhere for how I would persist the number of installs? |
I was thinking that rather than being by installs it could be by days. |
Thanks so much for your first contribution! Without people like you submitting PRs we couldn't run this project. You rock, @Wojonatior! This is useful as-is so figured it was worth merging. Would still love to see the stuff we talked about in a follow-up PR! |
@MikeMcQuaid Thanks! Sorry about the lack of communication on my part. I definitely want to make the follow-up PR for this, you should hopefully see something around it in the next week or so. |
@Wojonatior No worries, looking forward to it! |
brew style
with your changes locally?brew tests
with your changes locally?This PR is thethe implementation of the
HOMEBREW_INSTALL_CLEANUP
ENV and associated features as discussed in #4760.