This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix SLES, openSUSE, Ubuntu #46
base: master
Are you sure you want to change the base?
Fix SLES, openSUSE, Ubuntu #46
Changes from all commits
4425976
4319466
e858293
5cad4ee
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Hmm, maybe we should just do the get_distro_alias() once in the distro detection code and return the alias if defined, then we can forget about aliases in the rest of the code right?
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.
The problem is, that for packages we don't want to use alias, but for others we do want (installing pkg, updating package database, 32bit).
Also, some methods (at least
install_ltp_pkgs()
) are used fromrunltp-ng
, but we don't export functions with@EXPORT
, so I'm not sure what is the interface outside of the module, thus I wanted any method worked called from outside (not expecting to get correct distro from outside).But sure, I'm open to rewrite code if we agree what's the clearest way.
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.
So we have to pass the distro to the package mapping since debian and ubuntu have different packages while the rest of the operations are the same for the families of distributions.
Maybe it would be cleaner to have a function to map the distribution name into the package management so that we would map anything debian-like to apt, SUSE to zypper, anything from redhat to yum and alpine to apk.
That would allow us to choose the action based on the tool we are going to use rather than on some distribution name aliases.
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.
Sounds good, I'll add something like
distro_to_pkg_tool()
method.Also I was thinking that having
@build_pkgs
,@devel_libs
and@mkfs
as global arrays defined on the top would be more readable than having them hidden in the functions. We also add distro versions in of these arrays infoo_to_pkg()
, which is a different method. But this can wait after this fix.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.
Well, we need that distro alias function in
foo_to_pkg()
function as well, thus not sure aboutdistro_to_pkg_tool()
name. You're right, it's only the case for Ubuntu (currently). I suppose we don't want to specifically check for Ubuntu there.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.
Actually the only function used from the library at the moment is isntall_ltp_pkgs() that does everything including the call to the backend. I guess that it should be the other way the module should export the functions that generate the list of packages and the commandlines and that should be used. Generally the code should be cleaned up a bit, I guess that the detect_distro() function and install_ltp_pkgs() conceptually belongs somewhere else and that the interface to the module should really be the get_build_pkgs() get_runtime_pkgs() and get_install_cmds() functions. And I would declare the rest of the functions internal. Also we would need to add architecture parameter to the get_install_cmds() to properly support m32 on Debian.
Also I would add distro_to_pkg_too() function that would simply map distribution to the tool. As for the pkg_map we should do it so that we would try the distribution name first and if that fails we would use a distribution alias, so for ubuntu we would check if there is package foo-ubuntu mapping, if not we would look up an distro alias hash that would return debian, so we would try foo-debian and if that fails we would try looking up just foo. Does that sound reasonable?
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.
Sure, agree.
FYI although I agree exported functions I meant internal arrays. As the code is IMHO a bit too complicated for just a simple thing (given how simple and thus readable are scripts in https://github.com/linux-test-project/ltp/tree/master/ci, although it cannot print things obviously and I don't mean to use bash).
I also don't like that we apped distro to the package "key" with and distro separator is the same (
-
) as what is used in package key (i.e. 'libaio-devel' vs. 'libaio-devel-opensuse'), sure it's obvious that it's a distro, but it's not that readable.Also having default which can be overwritten is just strange (which distro is a default?). I'd prefer hashes of hashes array:
(
{runtime or build}{distro{ => (array of package)
) and specify everything (no "default)Also we should think about other scenarios when some package is not supported on particular distro, should it be empty? Or there are 2 packages needed. This feature is not needed now, but might be for runtime packages (e.g. for networking).