detectPacman function

Future<bool> detectPacman()

Detects if installed via pacman by querying pacman's database. Gates on Arch distro family before invoking pacman.

Implementation

Future<bool> detectPacman() async {
  if (!Platform.isLinux) return false;
  final osRelease = await getOsRelease();
  if (osRelease != null && !isDistroFamily(osRelease, ['arch'])) return false;
  final execPath = Platform.resolvedExecutable;
  try {
    final result = await Process.run('pacman', ['-Qo', execPath]);
    return result.exitCode == 0 && (result.stdout as String).isNotEmpty;
  } catch (_) {
    return false;
  }
}