[libcalamares] Don't hard-code full paths

- See editorial in the code-comment. Still need to test that
   chroot(8) doesn't need a full path, otherwise this will
   go to /usr/bin/env udevadm to force lookup (redundantly
   if not in a chroot)
This commit is contained in:
Adriaan de Groot 2020-02-24 13:11:58 +01:00
parent 8c527ab592
commit ee52e37b36

View file

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2019-2020, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,7 +24,14 @@
void
CalamaresUtils::Partition::sync()
{
auto r = CalamaresUtils::System::runCommand( { "/sbin/udevadm", "settle" }, std::chrono::seconds( 10 ) );
/* I would normally use full paths here, e.g. /sbin/udevadm and /bin/sync,
* but there's enough variation / opinion on where these executables
* should live, that full paths would need to be configurable.
* Instead, just run them and assume they're found in PATH;
* either chroot(8) or env(1) is used to run the command,
* and they do suitable lookup.
*/
auto r = CalamaresUtils::System::runCommand( { "udevadm", "settle" }, std::chrono::seconds( 10 ) );
if ( r.getExitCode() != 0 )
{
@ -32,5 +39,5 @@ CalamaresUtils::Partition::sync()
r.explainProcess( "udevadm", std::chrono::seconds( 10 ) );
}
CalamaresUtils::System::runCommand( { "/bin/sync" }, std::chrono::seconds( 10 ) );
CalamaresUtils::System::runCommand( { "sync" }, std::chrono::seconds( 10 ) );
}