diff options
author | Carlo Landmeter <clandmeter@gmail.com> | 2011-04-16 17:03:20 +0200 |
---|---|---|
committer | Carlo Landmeter <clandmeter@gmail.com> | 2011-04-16 17:03:20 +0200 |
commit | 00f88d55ce906b61469175a39b99945e63a8d66b (patch) | |
tree | d899a35c15e9b1f9a8f1486db19e449d1517cf7e /apk_browser.module | |
parent | 8a7d7cc25f05cc42566d6e1f961dfb8041cf459c (diff) | |
download | apk_browser-00f88d55ce906b61469175a39b99945e63a8d66b.tar.bz2 apk_browser-00f88d55ce906b61469175a39b99945e63a8d66b.tar.xz |
do not import double apk packages
only import packages one time and with higher version number.
Diffstat (limited to 'apk_browser.module')
-rw-r--r-- | apk_browser.module | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/apk_browser.module b/apk_browser.module index 61f2993..a5ec0ac 100644 --- a/apk_browser.module +++ b/apk_browser.module @@ -357,16 +357,33 @@ function apk_browser_apkindex_reader($apk_string) { //depend and install_if lines case "D": case "i": - $apackages[$key][$apk_line[0]] = explode(" ", substr($apk_line, 2)); + $result[$key][$apk_line[0]] = explode(" ", substr($apk_line, 2)); break; //other apk variables default: - $apackages[$key][$apk_line[0]] = substr($apk_line, 2); + $result[$key][$apk_line[0]] = substr($apk_line, 2); } } } + /* + * this should take care of having multiple packages with different + * version in repositories + */ + foreach ($result as $pkg) { + //check if package name already exit in result array + if (isset($output[$pkg['P']])) { + //check if version number is higher then previous + if ($output[$pkg['P']]['V'] < $pkg['V']) { + //if version is higher we overwrite package + $output[$pkg['P']] = $pkg; + } + //all not matching packages we just write them + } else { + $output[$pkg['P']] = $pkg; + } + } unlink($temp); - return $apackages; + return $output; } function apk_browser_apk_check($title, $arch, $repo) { |