[Suggestion] Use /etc/os-release or /etc/lsb_release for distrobox-upgrade
#1899
Replies: 24 comments
-
|
Thanks @uncomfyhalomacro Open to suggestions :) |
Beta Was this translation helpful? Give feedback.
-
|
This should be quite straightforward to be done. We can source the file with Then we can use case "${ID_LIKE}" in
debian) package_manager=apt ;;
...
esacThe tough part is researching If no one takes a stab at this, in my next round of distrobox contributions I could add this task to my Todo list. |
Beta Was this translation helpful? Give feedback.
-
|
Yea the fact that we can simply source it is really nice We need more info about which thing we can use to just infere the pkg manager The only thing that we might lose (i'm just guessing) is the ability to "just try and see if it works" |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Yeah, we need to have a closer looking to see if there's really a pattern we can rely on rather than going with
Yeah, I see the lines of code increasing a bit with this proposed approach. The "try and see" approach should work most of the time, because most of the time distros only have package manager. And if there's only one package, most likely there's only one canonical way of updating the system. However, there could be corner cases where things could end up not so pretty, with the current approach. The more people use distrobox the more likely such a thing could happen. |
Beta Was this translation helpful? Give feedback.
-
Yea that's what I fear :/ (and definitely won't do)
This in fact can be a problem if/when openSUSE migrates to dnf if command -v package_manager; then
> we get from os-release the distro
> package_manager install list of packages for detected distro
> else we install the package list for the most associated distro (dnf-fedora/rh, apt-debian etc etc)so we just add a little logic to the present approach this way |
Beta Was this translation helpful? Give feedback.
-
|
To be honest, I don't see openSUSE switching to DNF as its default package manager. However, I had the same thought about some cases needing a mixed approach. I'm gonna think this over when I get some time to spare. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the help! |
Beta Was this translation helpful? Give feedback.
-
Hey @luc14n0, did you manage to think about the issue? |
Beta Was this translation helpful? Give feedback.
-
|
I made a script to evaluate what fields can be used based on these samples. Also:
So, my proposal would be to use NAME to simplify things. |
Beta Was this translation helpful? Give feedback.
-
|
Further analyzing, we have 25 unique NAME tags: So, I guess we'd only need a "case" for these items only to define the corresponding package manager. |
Beta Was this translation helpful? Give feedback.
-
|
So, it would boil down to something like this: Testing: |
Beta Was this translation helpful? Give feedback.
-
|
And of course, if there are exceptions, like suppose there 4 versions of CentOS and one of them doesn't support DNF... test the other fields, preferrably PRETTY_NAME and then VERSION, if it exists. |
Beta Was this translation helpful? Give feedback.
-
|
Checkihg the distrobox-upgrade script, where the checks if a package manager is installed, we could just call a function, like the one that @doccaz did, and then compare which package returned, instead of checking which package manager is installed. What do you think @89luca89 ? |
Beta Was this translation helpful? Give feedback.
-
|
Yeah my suggestion seems flaky after I read all suggestions here, especially from @doccaz |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for thinking about this! Only problem I see is supporting unknown distros For example, The proposed solution would make it "hardcoded" which family of distros we support, |
Beta Was this translation helpful? Give feedback.
-
In this case, you could resort to the other available fields, like PRETTY_NAME or VERSION, as I mentioned. |
Beta Was this translation helpful? Give feedback.
-
That doesn't always work Another thing would maybe do a pkg manager detection fallback 1 - ID |
Beta Was this translation helpful? Give feedback.
-
Exactly. If everything else fails, test for the package manager binaries. |
Beta Was this translation helpful? Give feedback.
-
|
Im late to the discussion but this may be worth doing until proper solution is in place? For example on openSUSE, if zypper is checked first then it will not look for dnf so quick order i thought of Looking forward to your thoughts |
Beta Was this translation helpful? Give feedback.
-
|
mmh this would be a little stopgap, but that would do some damage on an opensuse with both dnf and zypper installed (I guess?? I do not know if installing dnf removes zypper and vice versa 🤷♂️ ) |
Beta Was this translation helpful? Give feedback.
-
|
I believe that we can have both, as there are some packages that install dnf, IIRC. But either way, for such a tool like distrobox, I believe that preferring zypper is safe. I never saw anyone using dnf on openSUSE as by default zypper is the package manager. |
Beta Was this translation helpful? Give feedback.
-
|
According to opensuse wiki dnf is in the repos but also it is never mentioned that it is unsupported only thing i could find is the following
No, dnf is available to install but zypper is kept, i do not know if zypper can be uninstalled but would that really be something distrobox need to care about if zypper works and is the default? EDIT: Also on archlinux you can install apt and dnf but i do not think we should care for such cases |
Beta Was this translation helpful? Give feedback.
-
|
IMHO, distrobox should first respect the default package manager for a distro. After this is done, well, some corner cases could be handled. (And yes, I understand that's kind of messed up to have two package managers, but what do I know?). |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Detecting which package manager is available through
commandcan be faulty. For example, I haveoscinstalled in my system before and tried outdistrobox-oscalso pullsdnfas part of the recommends (?). And because of that this may have mess up mydistroboxinstall causing it to look for dnf even after I removed it - related issue #706 .Wouldn't it be better to use
/etc/os-releaseor/etc/lsb_releaseto check which distro someone has at first and use the default package manager then usecommandas a fallback later?Errata:
oscdoes not havednfinstalled as part of recommends. But I do believe it might be someobs-service-*package that has dnf as part of its recommends since I used to runoscon the host with those plugins.PS: This could be a good discussion to look out for. Not a high priority to be honest since all of us are busy with our lives at this moment.
CC: @luc14n0 @89luca89
Beta Was this translation helpful? Give feedback.
All reactions