From 00f88d55ce906b61469175a39b99945e63a8d66b Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Sat, 16 Apr 2011 17:03:20 +0200 Subject: do not import double apk packages only import packages one time and with higher version number. --- apk_browser.module | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'apk_browser.module') 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) { -- cgit v1.2.3