You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.0 KiB
57 lines
2.0 KiB
<?php
|
|
|
|
namespace package_managers;
|
|
|
|
class pacman {
|
|
|
|
public static function is_installed(string $prog) {
|
|
exec(\neato::get_user_bin . 'dpkg -s ' . safeCmd($prog) . ' | ' . \neato::get_bin . 'grep "install ok installed"', $out, $exit_code);
|
|
exec(\neato::get_user_bin . 'dpkg -s ' . safeCmd($prog) . ' | ' . \neato::get_bin . 'grep ^Version', $output, $code);
|
|
$version = str_replace('Version: ', '', $output[0]);
|
|
return ($exit_code == 0) ? ['installed' => true, 'version' => $version] : ['installed' => false];
|
|
}
|
|
|
|
public static function upgrade($prog) {
|
|
exec(\neato::get_user_bin . 'pacman upgrade -y ' . safeCmdQuotes($prog) . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to upgrade: {$prog}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function install($prog) {
|
|
exec(\neato::get_user_bin . 'pacman -S ' . safeCmdQuotes($prog) . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to install: {$prog}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function uninstall($prog) {
|
|
exec(\neato::get_user_bin . 'pacman del -y ' . safeCmdQuotes($prog) . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to uninstall: {$prog}");
|
|
return $exit_code;
|
|
}
|
|
|
|
/**
|
|
* @todo figure out this method
|
|
*/
|
|
public static function add_repo($repo) {
|
|
exec(\neato::get_user_bin . 'pacman update' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to add new repo: {$repo}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function update() {
|
|
exec(\neato::get_user_bin . 'pacman update -y ' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function full_update() {
|
|
exec(\neato::get_user_bin . 'pacman update -y && ' . \neato::get_user_bin . 'apk upgrade -y' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
} |