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.
99 lines
3.1 KiB
99 lines
3.1 KiB
<?php
|
|
|
|
namespace package_managers;
|
|
|
|
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]);
|
|
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);
|
|
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);
|
|
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);
|
|
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);
|
|
display($output);
|
|
check_for_error($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 -y ' . 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);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
// Have a Backup!!
|
|
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 fetch' . stderr(), $output, $exit_code);
|
|
display($output);
|
|
return $exit_code;
|
|
}
|
|
|
|
} |