-
Notifications
You must be signed in to change notification settings - Fork 16
Fix SLES, openSUSE, Ubuntu #46
base: master
Are you sure you want to change the base?
Conversation
Ah, bug, it needs to be fixed. |
57e6a96
to
a8748c7
Compare
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.
It says "Remove Ubuntu" but leap is removed as well. If that was intentional it should be at least mentioned in the commit message.
while dpkg --print-architecture works only for Debian, not for Ubuntu. Thus use uname -r. Reviewed-by: Cyril Hrubis <[email protected]> Signed-off-by: Petr Vorel <[email protected]>
a8748c7
to
d9f60f6
Compare
Thanks! Unintentional, Leap put back. Added your |
install_pkg.pm
Outdated
@@ -76,6 +76,17 @@ sub foo_to_pkg | |||
'libnuma-devel-opensuse' => 'libnuma-devel', | |||
); | |||
|
|||
my $pkg = $pkg_map{"$foo-$distro"}; | |||
$pkg = $pkg_map{"$foo-" . get_distro_alias($distro)} unless defined $pkg; |
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 do not like the unless part here that much. Maybe we should just do:
my $pkg;
pkg = $pkg_map{"$foo-$distro");
return $pkg if defined;
$pkg = $pkg_map{"$foo-" . get_distro_alias($distro)};
return $pkg if defined $pkg;
return $pkg_map{"$foo");
@@ -189,7 +194,7 @@ sub update_pkg_db | |||
return "yum update -y"; | |||
} | |||
|
|||
if ($distro eq "suse") { | |||
if ($distro eq "opensuse") { | |||
return "zypper --non-interactive ref"; | |||
} | |||
|
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 from runltp-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 in foo_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.
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.
Sounds good, I'll add something like
distro_to_pkg_tool()
method.
Well, we need that distro alias function in foo_to_pkg()
function as well, thus not sure about distro_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.
the interface to the module should really be the get_build_pkgs() get_runtime_pkgs() and get_install_cmds() functions.
Sure, agree.
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.
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).
Problem affect SLES and Ubuntu, but visible only on Ubuntu. Fixes: e572aa5 ("install_pkg: Introduce Ubuntu") Signed-off-by: Petr Vorel <[email protected]>
These commands prints nothing: ./install_pkg.pm --build --run --distro sles --cmd ./install_pkg.pm --build --run --distro opensuse --cmd ./install_pkg.pm --build --run --distro ubuntu --cmd Fixes: 22db0cd ("install_pkg: Introduce openSUSE, SLES instead of suse") Fixes: e572aa5 ("install_pkg: Introduce Ubuntu") Signed-off-by: Petr Vorel <[email protected]>
Groovy and Xenial are EOL now. impish does not have linux-headers package. But update releases does not help because Focal (LTS, it'd be a candidate to test) and Hirsute have problems to install linux-headers-5.11.0-1021-azure (some strange timeout). This means that 6999232 ("install_pkg: Fix kernel headers for Ubuntu") was tested only locally. Reviewed-by: Cyril Hrubis <[email protected]> Signed-off-by: Petr Vorel <[email protected]>
d9f60f6
to
5cad4ee
Compare
2 fixes for 22db0cd e572aa5:
Previously these 3 commands didn't print anything: