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.
105 lines
3.4 KiB
105 lines
3.4 KiB
<?php
|
|
|
|
namespace package_managers;
|
|
|
|
class nala {
|
|
|
|
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);
|
|
$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 ' . safeCmdQuotes($prog) . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to upgrade: {$prog}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function install(string $prog, bool $auto=true) {
|
|
$assume = ($auto) ? "--assume-yes " : "";
|
|
exec(\neato::get_user_bin . 'nala install ' . $assume . safeCmdQuotes($prog) . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to install: {$prog}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function purge(string $prog, bool $auto=true) {
|
|
$assume = ($auto) ? "--assume-yes " : "";
|
|
exec(\neato::get_user_bin . 'nala purge ' . $assume . safeCmdQuotes($prog) . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to uninstall: {$prog}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function uninstall(string $prog, bool $auto=true) {
|
|
$assume = ($auto) ? "--assume-yes " : "";
|
|
exec(\neato::get_user_bin . 'nala remove ' . $assume . safeCmdQuotes($prog) . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
checkForError($exit_code, "Unable to uninstall: {$prog}");
|
|
return $exit_code;
|
|
}
|
|
|
|
/**
|
|
* @todo fix me
|
|
*/
|
|
public static function add_repo(string $repo) {
|
|
return false;
|
|
}
|
|
|
|
public static function update() {
|
|
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 && ' . \neato::get_user_bin . 'nala autoremove && ' . \neato::get_user_bin . 'nala clean' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function full_system_upgrade() {
|
|
return false;
|
|
}
|
|
|
|
public static function list() {
|
|
exec(\neato::get_user_bin . 'nala list --upgradeable' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
/*
|
|
* shows only the packages installed on the system.
|
|
*/
|
|
public static function installed() {
|
|
exec(\neato::get_user_bin . 'nala list --installed' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
/*
|
|
* View the list of mirrors by using the fetch command.
|
|
*/
|
|
public static function fetch() {
|
|
exec(\neato::get_user_bin . 'nala fetch' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
/*
|
|
* Delete the local cache files with the clean command.
|
|
*/
|
|
public static function clean() {
|
|
exec(\neato::get_user_bin . 'nala clean' . stdErr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
} |