PHP Deployment Scripts
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.
 
 

91 lines
2.5 KiB

<?php
namespace package_managers;
class snap {
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() {
return self::update();
}
public static function install(string $prog) {
exec(\neato::get_user_bin . 'snap 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) {
return self::uninstall($prog);
}
public static function uninstall(string $prog) {
exec(\neato::get_user_bin . 'snap 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 . 'snap refresh' . stderr(), $output, $exit_code);
display($output);
return $exit_code;
}
public static function full_update() {
return false;
}
// Have a Backup!!
public static function full_system_upgrade() {
return false;
}
public static function list() {
exec(\neato::get_user_bin . 'snap 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 . 'snap --installed' . stderr(), $output, $exit_code);
display($output);
return $exit_code;
}
/*
* View the list of mirrors by using the fetch command.
*/
public static function info() {
exec(\neato::get_user_bin . 'snap info --verbose' . stderr(), $output, $exit_code);
display($output);
return $exit_code;
}
/*
* Revert a Snap package to a previous version:
*/
public static function revert() {
exec(\neato::get_user_bin . 'snap revert' . stderr(), $output, $exit_code);
display($output);
return $exit_code;
}
}