formatting, filter md5

This commit is contained in:
dmacias72 2016-10-08 14:45:37 -06:00
parent 0b5ac0e685
commit f674f79ee7

View File

@ -15,58 +15,62 @@ $pkgs_array = [];
foreach ($pkgs_github_array as $pkg_github) { foreach ($pkgs_github_array as $pkg_github) {
$pkg_nameArray = explode('-', $pkg_github['name']); // split package name into array $pkg_nameArray = explode('-', $pkg_github['name']); // split package name into array
$pkg_name = $pkg_nameArray[0]; // strip md5 files
if(!strpos(end($pkg_nameArray),'.md5')) {
if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it $pkg_name = $pkg_nameArray[0];
for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) {
$pkg_name .= '-'.$pkg_nameArray[$ii];
}
}
$pkg_version = $pkg_nameArray[sizeof($pkg_nameArray) - 3]; // get package version if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it
for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) {
$pkg_nver = $pkg_name.'-'.str_replace('.', '_', $pkg_version); // add underscored version to package name $pkg_name .= '-'.$pkg_nameArray[$ii];
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search pattern for packages
// check all plugins for package dependency
$plugins = [];
exec("cd /boot/config/plugins ; find *.plg | xargs grep '${pkg_name}-${pkg_version}' -sl",$plugins);
$pkg_plgs = '--';
if ($plugins){
foreach ($plugins as $plugin){
$pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME).', ';
}
$pkg_plgs = substr($pkg_plgs, 2, -2);
}
// get package preference from config file
$pkg_set = "no";
foreach ($pkg_cfg as $pkg_key => $pkg_line) {
if (preg_match('/^'.$pkg_name.'.*/',$pkg_key)){
if(sizeof(array_diff(split('-', $pkg_key), split('-', $pkg_name))) < 2 ){
$pkg_set = $pkg_line;
break;
} }
} }
$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_pattern = '/^'.$pkg_name.'-.*/'; // search pattern for packages
// check all plugins for package dependency
$plugins = [];
exec("cd /boot/config/plugins ; find *.plg | xargs grep '${pkg_name}-${pkg_version}' -sl",$plugins);
$pkg_plgs = '--';
if ($plugins){
foreach ($plugins as $plugin){
$pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME).', ';
}
$pkg_plgs = substr($pkg_plgs, 2, -2);
}
// get package preference from config file
$pkg_set = "no";
foreach ($pkg_cfg as $pkg_key => $pkg_line) {
if (preg_match('/^'.$pkg_name.'.*/',$pkg_key)){
if(sizeof(array_diff(split('-', $pkg_key), split('-', $pkg_name))) < 2 ){
$pkg_set = $pkg_line;
break;
}
}
}
$pkg = [
'name' => $pkg_github['name'], // add full package name
'pkgname' => $pkg_name, // add package name only
'pkgnver' => $pkg_nver, // add package name with underscored version
'pkgversion' => $pkg_version, // add package name with raw version
'size' => format_size($pkg_github['size'], 1, '?'), // add package size
'installed' => preg_grep($pkg_pattern, $pkgs_installed) ? 'yes' : 'no', // checks if package name is installed
'installeq' => in_array(pathinfo($pkg_github['name'], PATHINFO_FILENAME), $pkgs_installed) ? 'yes' : 'no', // checks if package installed equals github exactly
'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded
'downloadeq' => in_array($pkg_github['name'], $pkgs_downloaded) ? 'yes' : 'no', // checks if package downloaded equals github exactly
'config' => $pkg_set, // install preference
'plugins' => $pkg_plgs, // plugins dependency on package
'desc' => $pkgs_desc_array[$pkg_name]
];
$pkgs_array[] = $pkg;
} }
$pkg = [
'name' => $pkg_github['name'], // add full package name
'pkgname' => $pkg_name, // add package name only
'pkgnver' => $pkg_nver, // add package name with underscored version
'pkgversion' => $pkg_version, // add package name with raw version
'size' => format_size($pkg_github['size'], 1, '?'), // add package size
'installed' => preg_grep($pkg_pattern, $pkgs_installed) ? 'yes' : 'no', // checks if package name is installed
'installeq' => in_array(pathinfo($pkg_github['name'], PATHINFO_FILENAME), $pkgs_installed) ? 'yes' : 'no', // checks if package installed equals github exactly
'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded
'downloadeq' => in_array($pkg_github['name'], $pkgs_downloaded) ? 'yes' : 'no', // checks if package downloaded equals github exactly
'config' => $pkg_set, // install preference
'plugins' => $pkg_plgs, // plugins dependency on package
'desc' => $pkgs_desc_array[$pkg_name]
];
$pkgs_array[] = $pkg;
} }
$return = [ $return = [