-
Notifications
You must be signed in to change notification settings - Fork 207
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
Fully defined apt repository package checking #2554
Conversation
just some examples where the output before is wrong
no output, there should be correct output now:
|
…if_unused In order to run remove_repofile_if_unused on a backports repo, the search algorithms needed to be redone to consider dist information and installed package versions. Otherwise backports repos would never be removed due to false positives.
…ed apt repository for installed packages instead of checking the apt-cache policy on each package individually, check all installed packages that exist in a repo at once. this results in a multiple factor of magnitude speedup on large repositories (eg: debian/ubuntu main repositories) from minutes to seconds
83ee5cd
to
e69b7dd
Compare
7023ec6
to
c893bf0
Compare
there were also false negatives. I had sublime text and sublime merge installed. I then uninstalled sublime text and it removed the shared apt repo while sublime merge apt package was still installed. all these issues are fixed with this new function and its use |
1d137bb
to
6119ae6
Compare
|
||
local packages_in_repo="$(grep '^Package' "$repofile" | awk '{print $2}' | sort)" | ||
local installed_packages="$(apt list --installed 2>/dev/null | tail -n +2 | awk -F/ '{print $1}')" | ||
local apt_cache_policy_output="$(echo "$packages_in_repo" | list_intersect "$installed_packages" | tr '\n' ' ' | xargs -r apt-cache policy)" |
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.
With tr
used here, it seems to me like the output from this would always be a single line, meaning all matching packages would be passed to apt-cache in one run.
So it seems like the only use for xargs is shorthand to avoid running apt-cache if no packages from the repo are installed?
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.
apt-cache policy needs the input as individual arguments. it also does not read from stdin. these are the reasons why xargs is used.
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 explained poorly.
If apt-cache is only being run once, then something like this should work if I understand this correctly
local apt_cache_policy_output="$(apt-cache policy $(echo "$packages_in_repo" | list_intersect "$installed_packages" | tr '\n' ' '))"
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.
No I correctly interpreted what you said.
apt-cache policy needs the input as individual arguments.
What you just sent puts all output as one input argument I think. Can't check now.
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.
No quotes around the inner $()
will make each package into a separate argument.
If nothing else, this is simply something useful to know. I'm not necessarily requesting any changes here.
I have changed the how the list of installed packages is determined, directly using the dpkg status file which is much faster.
Time improvement: before=0m0.670s after=0m0.014s |
Also fixed setting |
that was just an oversight. no other reason |
Yup I discovered that yesterday as well before opening this PR. I intended to fix it in pi-apps but hadn't gotten around to it yet. I see you have already done so. |
I may change this back. The intention was to only get output for In order to obtain the architecture information from dpkg, we would need to parse 8 lines for each package, instead of the current 2. There is actually (at least one) case where the output from the grep command and the apt command differs once "correctly" sorted for architecture using your dpkg command, it now becomes
using the apt-cache policy, it now becomes
the one difference between the output is the dpkg command incorrectly filters out any manually held back packages while the apt command does not. I am currently holding back the to correct that and achieve the same result, now the command needs to be
now that is getting quite lengthy I feel like the dpkg status grep, although faster and I knew that, might be prone to breakage in the future. |
ee69eb1
to
3f3b369
Compare
ok understand |
OK once you have |
…from_uri_suite_component` handles .sources files and .list files with multiple components and multiple suites (as allowed) and filters out disabled sources. in deb822, it is convention to follow a field separator colon by a space and then the package name but the specification allows for no space or any number of spaces or tab characters. trim all tab and space characters to a single space character for components and suites that can have multiple strings of output
improve readibility, optimize list of installed packages Co-Authored-By: Botspot <[email protected]>
also replace function in brave install script with `anything_installed_from_uri_suite_component`
3f3b369
to
64c8fdd
Compare
resolves 27f5fe1#r139018751
these modified and new functions fully define the checking of an apt repository for installed packages.
This prevents false positives that did occur before if multiple apt repositories shared a URI and SUITE but had different COMPONENTS
This also greatly improves support for
.sources
files where multiple stanzas are now properly supported and parsed