add update functions

This commit is contained in:
Derek Macias 2015-12-14 21:48:49 -07:00
parent 509559b725
commit 99fb631974

View File

@ -13,36 +13,49 @@ $pkgs_file = file_get_contents("/boot/config/plugins/NerdPack/packages.json");
$pkgs_github = json_decode($pkgs_file, true); $pkgs_github = json_decode($pkgs_file, true);
$pkgs_array = array(); $pkgs_array = array();
for ($i = 0; $i < sizeof($pkgs_github); $i++) { for ($i = 0; $i < sizeof($pkgs_github); $i++) {
$pkg_NameArray = explode("-", $pkgs_github[$i]["name"]); // split package name into array $pkg_nameArray = explode("-", $pkgs_github[$i]["name"]); // split package name into array
$pkg_Name = $pkg_NameArray[0]; $pkg_name = $pkg_nameArray[0];
if (sizeof($pkg_NameArray) > 4){ //if package name has a subset get it if (sizeof($pkg_nameArray) > 4){ //if package name has a subset get it
for ($ii = 1; $ii < sizeof($pkg_NameArray)-3; $ii++) { for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) {
$pkg_Name = $pkg_Name."-".$pkg_NameArray[$ii]; $pkg_name = $pkg_name."-".$pkg_nameArray[$ii];
} }
} }
$pkg_version = $pkg_NameArray[sizeof($pkg_NameArray)-3]; // get package version $pkg_version = $pkg_nameArray[sizeof($pkg_nameArray)-3]; // get package version
$pkg_nver = $pkg_Name."-".str_replace(".", "_", $pkg_version); // add underscored version to package name $pkg_nver = $pkg_name."-".str_replace(".", "_", $pkg_version); // add underscored version to package name
$pkg_pattern = "/^".$pkg_name.".*/"; // search patter for packages
$pkg = array(); $pkg = array();
$pkg["name"] = $pkgs_github[$i]["name"]; // add full package name $pkg["name"] = $pkgs_github[$i]["name"]; // add full package name
$pkg["pkgname"] = $pkg_Name; // add package name only $pkg["pkgname"] = $pkg_name; // add package name only
$pkg["pkgnver"] = $pkg_nver; // add package name with underscored version $pkg["pkgnver"] = $pkg_nver; // add package name with underscored version
$pkg["pkgversion"] = $pkg_version; // add package name with underscored version
$pkg["size"] = $pkgs_github[$i]["size"]; // add package size $pkg["size"] = $pkgs_github[$i]["size"]; // add package size
$pkg["installed"] = in_array( pathinfo($pkgs_github[$i]["name"], PATHINFO_FILENAME), $pkgs_installed ) ? "yes" : "no"; // checks if package is installed // checks if package name is installed
$pkg["installed"] = preg_grep($pkg_pattern , $pkgs_installed) ? "yes" : "no";
$pkg["downloaded"] = in_array( $pkgs_github[$i]["name"], $pkgs_downloaded ) ? "yes" : "no"; // checks if package is downloaded // checks if package is installed equals github exactly
$pkg["installeq"] = in_array( pathinfo($pkgs_github[$i]["name"], PATHINFO_FILENAME), $pkgs_installed ) ? "yes" : "no";
// checks if package name is downloaded
$pkg["downloaded"] = preg_grep($pkg_pattern , $pkgs_downloaded) ? "yes" : "no";
// checks if package is downloaded equals github exactly
$pkg["downloadeq"] = in_array( $pkgs_github[$i]["name"], $pkgs_downloaded ) ? "yes" : "no";
$pkg["config"] = isset($pkg_cfg["$pkg_nver"]) ? $pkg_cfg["$pkg_nver"] : "no"; // checks config for install preference $pkg["config"] = isset($pkg_cfg["$pkg_nver"]) ? $pkg_cfg["$pkg_nver"] : "no"; // checks config for install preference