bestForArch method
Determines the best installation method for Arch Linux.
The to parameter is the installation target.
Implementation
Future<String> bestForArch({String to = 'install'}) async {
/// Here can be the path to sudo if the package manager is pacman, others ask for sudo automatically.
String needsSudo = '';
final methods = package.methods ?? [];
final hasMethod = methods.contains('pacman');
final defaults = package.defaults ?? [];
final hasDefault = defaults.contains('pacman');
if (hasMethod || hasDefault) {
final paru = await Executable('paru').find();
final yay = await Executable('yay').find();
final pacman = await Executable('pacman').find();
String? bestArchLinux = paru ?? yay ?? pacman;
if (bestArchLinux != null) {
if (bestArchLinux == pacman) {
needsSudo = Global.sudoPath;
}
Global.updateCommand = '${Global.sudoPath} $bestArchLinux -Sy || $errorOnUpdate';
if (hasDefault) {
final operation = to == 'install' ? '-S' : '-R';
return '$needsSudo $bestArchLinux --noconfirm $operation ${package.name}';
}
return '${to}_pacman "$needsSudo $bestArchLinux --noconfirm"';
}
}
stopIfForcedMethodNotFound();
return await bestForAny(to: to);
}