-
Notifications
You must be signed in to change notification settings - Fork 126
[RFC] pkg
: never implicitly update package cache without upgrading all packages
#172
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
base: master
Are you sure you want to change the base?
[RFC] pkg
: never implicitly update package cache without upgrading all packages
#172
Conversation
pkg
: never implicitly update package cache without upgrading all packages
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.
Thanks for putting in the work Robert.
I mostly agree with the changes proposed here but I would like to discourage the non-interactive upgrade part of the handle_install_${TERMUX_APP_PACKAGE_MANAGER}
functions.
If you'll indulge me and my soapbox for a bit.
<soapbox>
Users should be able to cancel out of a suggested update at any point, and no changes requesting user confirmation should be made without user consent.
I understand the dpkg
"What would you like to do about it" prompt,
e.g:
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** %s (Y/I/N/O/D/Z) [default=N] ?
can be intimidating for new users.
But I think the better remedy to that would be building dpkg
to default to [default=Y]
on that prompt, but still offer it to the user.
Instead of skipping it with the -y
flag.
</soapbox>
0bf138e
to
8d2da30
Compare
I am fine with the idea but I think it is not really compatible with mirror rotation in If other maintainers agree with this using this concept we can workaround it though. |
Also since we have full control on |
Or we could simply do a simple GET request to current mirror for reading first 200 bytes in Release file, compare it with the 200 first bytes of the current release file and ask user if they want to perform an update (in apt). Probably it is naive but it also a viable option, it breaks current UX though. |
I think we should not patch |
I will add some additional clarification. This is intended behavior in my idea here. In my personal opinion, it is completely OK for apt to use stale data and continue to use the last selected mirror for as long as the packages can be successfully downloaded, until it is time for package cache to be updated and a full upgrade also performed. You can see here that, when the failure to download the package during package installation is detected for any reason, which could also include the mirror being down, too slow, or a network outage (which can take many forms and can be partial), I chose this because it is my personal belief that a mirror should implicitly be allowed to default to being used (just in If your opinion is different that the detection of the mirror outdatedness compared to the main mirror packages-cf.termux.dev needs to be run very regularly, for example after this PR: And that you believe
I would agree with this idea and it is fine in my opinion (note: my approval of the behavior of changes to apt internal code is conditional on my review when testing the changes to apt, to make sure what it would do is the same thing I am imagining now). However, I do not currently know how to implement that inside Also, If you read the discussions above, originally I had a little bit more assumptions that the user gave consent, but I removed them in favor of complete interactive prompts at every possible step, because Tomjo2000 requested that all interactive prompts be kept.
I am not very sure whether that would work because, if any mirror is not absolutely 100% up to date always, then it will not contain identical package versions to the versions in other mirrors, so it is not be possible to swap between mirrors like that without performing either a full upgrade (desired situation in this proposal) or a partial upgrade (undesired situation in this proposal). Maybe I do not exactly understand what you mean by this part though. |
I do not fully understand this idea. By "current release file" do you mean a similar, second GET request to the main mirror packages-cf.termux.dev to compare with its release file? Or do you mean the local release file copy stored on the device? |
Apt stores separate local copies of Release files for every single mirror. So after rotating mirrors most likely Release file will be outdated by more that 6/12/24/48 hours because most likely a mirror was not used for a long time.
Second GET request to obtain actual timestamp of current mirror because of the reason above. |
What I mean is that in the proposal shown here, just as before (except without checking the metadata files or timeout anymore that I mentioned at the start of the PR description), the package cache is always updated immediately after the
|
select_mirror | ||
# since package installation failed because of failure to download a package, | ||
# updating the package cache is always necessary | ||
apt update |
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.
here is where I mean that apt update
is still always run after select_mirror
in this proposal.
…ading all packages > [!IMPORTANT] > These changes are not intended to be considered absolutely necessary or mandatory to merge. > They are changes that would alter behavior users might have come to expect from Termux `pkg`, that has been different from how other distros behave for a long time. > These changes are instead meant to serve an example of how Termux's `pkg` command **could** have been designed in retrospect, in order to prevent accidental partial upgrades, in a way that is familiar to users of other rolling-release distributions that existed for a long time before Termux existed. - Fixes termux#137 - Never skip updating the package cache based on a timeout or the presence of metadata files. - Instead, always try directly installing packages first, then interpret the output message from the package manager to determine the appropriate action. - If the package installation was successful despite the package cache not having been updated, then everything is actually OK, and no further action is required - If the package installation failed with an error indicating failure to download the package **or** an error indicating the package was not found (which could happen in three cases: the package cache has never been generated, or the package is new and the package cache has not been updated since the package became available, or the package name has a typo and does not actually exist), then automatically update package cache **and** upgrade all packages, and **then** attempt to install the package again. - This change of behavior prevents the accidental partial upgrades that currently happen mainly because of the current `pkg install` command updating package cache without upgrading all packages simultaneously. - If the package installation failed, but one of the errors handled here was not not detected in the output of the package manager, then exit and do nothing since in that case, there is no reason that updating the package cache or upgrading all packages would help. - Do not implicitly update package cache during `pkg search` before running the package manager search command, because it could result in accidentally updating the package cache without upgrading all packages, which could result in accidental partial upgrades.
8d2da30
to
f3fcdba
Compare
I realized I forgot to close fd 3 in the codepath where execution is returned to the case statement which called |
The logic around individual install ops in the top comment makes some sense to me, and I'm (obviously) motivated by the goal of not doing things in common paths that are known to be dangerous. :) Just thinking out loud for now, not voting either way. Other goals that are important to us and maybe don't interact well with this proposal:
|
Correct except for the "6h period" part, I don't think there is any enforced "6h period" involved here in this version of this proposal except for the time between rotating mirrors, which is not modified here, with the exception that this proposes to not rotate mirrors during This proposal is designed to provide users of
I personally disagree. In my opinion, errors caused by partial updates are more common than errors caused by interrupted updates, but it could just be that I've personally seen more errors caused by partial updates, and you've personally seen more errors caused by interrupted updates. It's hard to gather evidence to identify which type of error is objectively more common. There is, however, the factor in support of my position that, if all intended package operations complete successfully, then if implicit partial updates are invoked repeatedly, an error will always eventually happen to at least one package, but if implicit partial updates are disallowed, then all user-side dependency-related errors are prevented.
Not quite correct - this proposal would introduce the behavior that, if someone types
Correct, this proposal introduces a behavior where if someone types |
General message for readers here: I have tried to explain every detail of the proposed changes in a precise way through the commit message and my responses here, but despite that, I believe that the full extent of the subtle changes in the behavior of the If anyone is confused about what these changes would mean for them, I encourage them to consider installing and testing this PR on a temporary Termux installation, such as an installation on a test device, an Android virtual device, or a termux-docker container, so that they can experience the changes firsthand and compare with their expectations and preferences of how they believe Termux |
Sorry, wasn't saying there was. I meant that in the other discussions, in today's
To be clear, I'm reporting my experience of other people's problems in the discord/matrix, not my own. :) apt-getting-killed feels like it comes up every month or three, is independent of changes or lack of changes to repo state, and is largely independent of user behavior. (It doesn't matter a ton if you have lots of packages or any specific packages or an old install or run upgrades frequently/rarely/through any specific path - you just have background Termux mid-update, which is a natural thing to do.) The partial update problem, and particularly the version of the partial update problem that isn't trivially fixed by a I agree that it's a problem worth fixing! But I'm worried about worsening something that's in the first few pages of my playbook for "someone says their shit is broken".
I think we're saying the same thing here, but I didn't do a great job explaining it. One of the sources of package staleness is metadata staleness; I think your proposal will increase the average, but not the tail, contribution of metadata staleness to overall staleness, as long as we don't mess with the behavior of only holding mirror choices for 6h. That's not a problem. Mentioning this because thinking through this proposal seems to create an incentive to mess with that behavior, and doing so has negatives for the way we do support communications and write instructions.
I think I'm following, but if you'd like to develop this further and build some consensus, I recommend adding a "what would change / what wouldn't change" to the top comment. I mean that in the broad sense: software behavior, UX, assumptions we can/can't have about the world. This is a thorny space and it'll help to get that front and center. |
My guess is that the discrepancy we're seeing is because partial upgrade errors may be more commonly reported in GitHub Issues, while interrupted upgrade errors may be more commonly reported in Discord/Matrix. In messages above this, I didn't want to basically "spam ping" in GitHub by saying something like "fixes all of these", because what I'm about to do will GitHub-ping all subscribers to these issues, but the topic has more or less been forced, so doing so now:
Issue list collected from searches like this: https://github.com/termux/termux-packages/issues?q=label%3Anot-bug%20is%3Aclosed%20CANNOT%20LINK%20EXECUTABLE It's a bit hard to separate out issues that this proposal would actually fix from ones that have other causes (limited information provided, real dependency bug, mirror partially synced, revision-bumps still building in CI, interrupted upgrade), but ones where
Noted, like you suggest, I could probably think of a clearer way to summarize the changes with phrasing that fits under headings "what would change" and "what wouldn't change" for easier understanding. I'll work on writing that. |
"What would change" and "What wouldn't change" summaries are now added to the description of the PR. |
If I am understanding the concern you are talking about here correctly, I believe I can provide a worst-case scenario example of what would become possible after the changes proposed here. In a worst-case scenario of what you describe, what would become possible is this:
This is essentially one of the intended behaviors of the current design of this proposal, because I personally have a belief that if a mirror was not stale when it was initially rotated to, and the user does not ever experience any errors nor perform an explicit However, if this part of the proposal is disliked, this could be resolved and avoided by changing this proposal in a way that I mentioned in one of my earlier comments. Quoting what I said above:
|
098b6db
to
efb1463
Compare
…e not for (if the package cache has not been updated since) 6 hours
efb1463
to
351a46c
Compare
Important
These changes are not intended to be considered absolutely necessary or mandatory to merge.
They are changes that would alter behavior users might have come to expect from Termux
pkg
, that has been different from how other distros behave for a long time.These changes are instead meant to serve an example of how Termux's
pkg
command could have been designed in retrospect, in order to prevent accidental partial upgrades, in a way that is familiar to users of other rolling-release distributions that existed for a long time before Termux existed.Fixes
pkg i
usespacman -Sy
, which is fundamentally unsafe #137Never skip updating the package cache based on a timeout or the presence of metadata files.
Instead, always try directly installing packages first, then interpret the output message from the package manager to determine the appropriate action.
If the package installation was successful despite the package cache not having been updated, then everything is actually OK, and no further action is required
If the package installation failed with an error indicating failure to download the package or an error indicating the package was not found (which could happen in three cases: the package cache has never been generated, or the package is new and the package cache has not been updated since the package became available, or the package name has a typo and does not actually exist), then automatically update package cache and upgrade all packages, and then attempt to install the package again.
pkg install
command updating package cache without upgrading all packages simultaneously.If the package installation failed, but one of the errors handled here was not not detected in the output of the package manager, then exit and do nothing since in that case, there is no reason that updating the package cache or upgrading all packages would help.
Do not implicitly update package cache during
pkg search
before running the package manager search command, because it could result in accidentally updating the package cache without upgrading all packages, which could result in accidental partial upgrades.What would change
pkg install
would no longer automatically rotate mirrors every time it has run if it has been more than 6 hours since the last mirror rotation. Instead, it would only rotate mirrors when both of the following conditions are met:pkg install
would no longer automatically update the package cache every single time it is run. Instead, it would only update the package cache when the following condition is met:pkg install
would no longer install package(s) immediately after updating the package cache, because that would perform a partial upgrade, which can sometimes causeCANNOT LINK EXECUTABLE
errors, and other kinds of errors, to appear afterward.pkg install
exits in a failure state, after showing the original error message.pkg search
would no longer automatically update the package cache before searching for packages.What wouldn't change
pkg install
would still always provide a pathway to installing packages successfully even if the package cache was missing or outdated at the moment thatpkg install
was initiatedpkg update
would still always perform only a package cache update, because that command is taken to mean an explicit, not an implicit, request to update the package cache.pkg upgrade
would still keep the exact same behavior:pacman
-based andapt
-based Termux installations, meaning:pacman
-based Termux installations do not currently perform "mirror rotation", changes related to "mirror rotation" would not apply topacman
-based Termux installations.pacman
-based Termux installations, and all other changes are equally relevant topacman
-based andapt
-based Termux installations.pacman
-based andapt
-based Termux installations, without increasing or reducing the degree of consistency between them.pkg
subcommands not yet mentioned (f*
,sh*
,autoc*
,cl*
,list-a*
,list-i*
,rei*
,un*
) would remain exactly the same, and would not be affected by any of these changes.apt
andpacman
when invoked directly would remain exactly the sameapt
andpacman
when directly invoked are essentially consistent, insofar as they relate to package cache synchronizing and package downloading, with their equivalent behaviors found in the GNU/Linux distros Debian sid and Arch Linux both prior to and after the creation of Termux.pkg
wrapper ofapt
andpacman
, with the goal of removingpkg
's current tendency to perform implicit package cache updates without upgrading all packages immediately afterward (implicit partial upgrades)