|
|
|
|
@ -7,33 +7,40 @@ class nala { |
|
|
|
|
public static function is_installed(string $prog) { |
|
|
|
|
exec(\neato::get_user_bin . 'dpkg -s ' . safe_cmd($prog) . ' | ' . \neato::get_bin . 'grep "install ok installed"', $out, $exit_code); |
|
|
|
|
exec(\neato::get_user_bin . 'dpkg -s ' . safe_cmd($prog) . ' | ' . \neato::get_bin . 'grep ^Version', $output, $code); |
|
|
|
|
$version = str_replace('Version: ', '', $output[0]); |
|
|
|
|
$get_version = $output[0] ?? false; |
|
|
|
|
if ($get_version === false) { |
|
|
|
|
return ['installed' => false]; |
|
|
|
|
} |
|
|
|
|
$version = str_replace('Version: ', '', $get_version); |
|
|
|
|
return ($exit_code == 0) ? ['installed' => true, 'version' => $version] : ['installed' => false]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function upgrade(string $prog) { |
|
|
|
|
exec(\neato::get_user_bin . 'nala upgrade -y ' . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
exec(\neato::get_user_bin . 'nala upgrade ' . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
display($output); |
|
|
|
|
check_for_error($exit_code, "Unable to upgrade: {$prog}"); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function install(string $prog) { |
|
|
|
|
exec(\neato::get_user_bin . 'nala install -y ' . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
public static function install(string $prog, bool $auto=true) { |
|
|
|
|
$assume = ($auto) ? "--assume-yes " : ""; |
|
|
|
|
exec(\neato::get_user_bin . 'nala install ' . $assume . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
display($output); |
|
|
|
|
check_for_error($exit_code, "Unable to install: {$prog}"); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function purge(string $prog) { |
|
|
|
|
exec(\neato::get_user_bin . 'nala purge -y ' . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
public static function purge(string $prog, bool $auto=true) { |
|
|
|
|
$assume = ($auto) ? "--assume-yes " : ""; |
|
|
|
|
exec(\neato::get_user_bin . 'nala purge ' . $assume . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
display($output); |
|
|
|
|
check_for_error($exit_code, "Unable to uninstall: {$prog}"); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function uninstall(string $prog) { |
|
|
|
|
exec(\neato::get_user_bin . 'nala remove -y ' . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
public static function uninstall(string $prog, bool $auto=true) { |
|
|
|
|
$assume = ($auto) ? "--assume-yes " : ""; |
|
|
|
|
exec(\neato::get_user_bin . 'nala remove ' . $assume . safe_cmd_quotes($prog) . stderr(), $output, $exit_code); |
|
|
|
|
display($output); |
|
|
|
|
check_for_error($exit_code, "Unable to uninstall: {$prog}"); |
|
|
|
|
return $exit_code; |
|
|
|
|
@ -47,18 +54,17 @@ class nala { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function update() { |
|
|
|
|
exec(\neato::get_user_bin . 'nala update -y ' . stderr(), $output, $exit_code); |
|
|
|
|
exec(\neato::get_user_bin . 'nala update' . stderr(), $output, $exit_code); |
|
|
|
|
display($output); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static function full_update() { |
|
|
|
|
exec(\neato::get_user_bin . 'nala update -y && ' . \neato::get_user_bin . 'nala autoremove -y && ' . \neato::get_user_bin . 'nala clean -y' . stderr(), $output, $exit_code); |
|
|
|
|
exec(\neato::get_user_bin . 'nala update && ' . \neato::get_user_bin . 'nala autoremove && ' . \neato::get_user_bin . 'nala clean' . stderr(), $output, $exit_code); |
|
|
|
|
display($output); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Have a Backup!! |
|
|
|
|
public static function full_system_upgrade() { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -91,7 +97,7 @@ class nala { |
|
|
|
|
* Delete the local cache files with the clean command. |
|
|
|
|
*/ |
|
|
|
|
public static function clean() { |
|
|
|
|
exec(\neato::get_user_bin . 'nala fetch' . stderr(), $output, $exit_code); |
|
|
|
|
exec(\neato::get_user_bin . 'nala clean' . stderr(), $output, $exit_code); |
|
|
|
|
display($output); |
|
|
|
|
return $exit_code; |
|
|
|
|
} |
|
|
|
|
|