[Feature Request] Reliable way to invoke apt-get#192
Conversation
* Avoid user interaction in case of error * Use exit code `1` if `/ust/bin/apt-get` doesn't exist
|
Can you rebase it against the current master please, so the actual changes are easily viewable? |
|
I didn't know about the whereis command. It looks nice an avoids hardcoding paths. It can be assumed installed on Debian systems using apt-fast as it is a dependency for mount (which is a dependency for systemd). So I placed an exec file in /usr/local/bin/apt-get and the whereas output is: How is the order of the output? |
It seems
For instance, invoking Large text ahead
Additionally, I also tried to confuse Invoking apt-get: /usr/bin/apt-get /usr/sbin/apt-get /usr/local/bin/apt-get /usr/share/man/man8/apt-get.8.gz
Based on my output from |
|
BTW, I marked this PR as a draft temporarily, since I've been a bit stressed out lately, and I accidentaly messed up something when trying to rebase. 🤦♂️ (facepalm) I'll fix it in the next few days; in the meantime, we can continue analyzing the idea behind my PR. |
Why?
This PR attempts to cover an edge case which might occur here if an user attempts to use aptitude (or any other custom package manager) in
apt-fast.conf, by overriding"${_APTMGR}", while being in an environment which prioritizes/usr/local/binover/usr/binin"${PATH}", with a symlink from e.g./usr/local/bin/aptitude->/usr/bin/apt.fast.Trying to invoke
apt-fastwith this setup would causeapt-fastto call himself.Is this necessary?
Although such environment would seem extremely unusual at first, taking a closer look to your
"${PATH}"might reveal that, in fact, you could be using a similar configuration without even knowing (Like i discovered); also, if we take into account thatapt-fast.confactually allows"${_APTMGR}"to be overridden, than means that we'd just need to also create a symlink like the one above described to trigger this edge case.So? What's the idea?
The idea behind this PR it's quite simple: We just need to make sure that we're calling
/usr/bin/apt-getwhenever we call forapt-get.This can be achieved in many ways
apt-getoccurence withinapt-fastwith/usr/bin/apt-get/usr/bin/apt-getinto a variable, and replace eachapt-getoccurence with"${var}"[Currently in use]Or we could use
whereiscommand, from utils-linux package to do something like thisreal_APT="${whereis_APT[1]}"Are there any drawbacks?
Strictly talking, there could be a few:
Option 1
This option would end up adding a lot of hardcoded lines into
apt-fastOption 2
This option requires an additional variable to store
apt-getfullpath, and just one hardcoded line.Option 3
This option requires (at least) an additional variable to store
apt-getfullpath, and adding another dependency: utils-linux package.After a little research, seems
systemdpackage depends onutils-linux, so that meansutils-linuxcomes preinstalled, at least in Ubuntu (Debian's systemd doesn't seem to share that dependency)Final notes
As always, If I made some mistake, or if you have any suggestion, it's always welcome.