From ed3f5ca56cdb203e6fac5577d8c56b3a61bb9208 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 18 Jul 2015 02:18:15 +0300 Subject: [PATCH] Fix matching binary packages --- slpkg/binary/install.py | 24 ++++++++++++++++-------- slpkg/slack/patches.py | 29 +++++++++++++++++++---------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 48070692..75563daa 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -173,6 +173,14 @@ class BinaryInstall(object): PackageManager(package).upgrade("--install-new") return [installs, upgraded] + def find_installed(self, pkg): + """Return installed package name + """ + find = find_package(pkg + "-", self.meta.pkg_path) + if find: + return split_package(find[0])[0] + return "" + def checksums(self, install): """ Checksums before install @@ -205,23 +213,23 @@ class BinaryInstall(object): # fix repositories align repo = self.repo + (" " * (6 - (len(self.repo)))) for pkg, comp in zip(install, comp_sum): - pkg_split = split_package(pkg[:-4]) + pkg_repo = split_package(pkg[:-4]) if find_package(pkg[:-4], self.meta.pkg_path): pkg_sum += 1 COLOR = self.meta.color["GREEN"] - elif find_package(pkg_split[0] + self.meta.sp, self.meta.pkg_path): + elif pkg_repo[0] == self.find_installed(pkg_repo[0]): COLOR = self.meta.color["YELLOW"] upg_sum += 1 else: COLOR = self.meta.color["RED"] uni_sum += 1 - ver = get_installed_version(pkg_split[0]) + ver = get_installed_version(pkg_repo[0]) print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format( - COLOR, pkg_split[0] + ver, self.meta.color["ENDC"], - " " * (23-len(pkg_split[0] + ver)), pkg_split[1], - " " * (18-len(pkg_split[1])), pkg_split[2], - " " * (8-len(pkg_split[2])), pkg_split[3], - " " * (7-len(pkg_split[3])), repo, + COLOR, pkg_repo[0] + ver, self.meta.color["ENDC"], + " " * (23-len(pkg_repo[0] + ver)), pkg_repo[1], + " " * (18-len(pkg_repo[1])), pkg_repo[2], + " " * (8-len(pkg_repo[2])), pkg_repo[3], + " " * (7-len(pkg_repo[3])), repo, comp, " K")).rstrip() return [pkg_sum, upg_sum, uni_sum] diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index a6b61111..6c6aa694 100644 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -158,19 +158,28 @@ class Patches(object): Views packages """ for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)): - pkg_split = split_package(upg[:-4]) - color = self.meta.color["YELLOW"] - if not find_package(pkg_split[0], self.meta.pkg_path): - color = self.meta.color["RED"] - ver = get_installed_version(pkg_split[0]) + pkg_repo = split_package(upg[:-4]) + color = self.meta.color["RED"] + pkg_inst = self.find_installed(pkg_repo[0]) + if pkg_repo[0] == pkg_inst: + color = self.meta.color["YELLOW"] + ver = get_installed_version(pkg_repo[0]) print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format( - color, pkg_split[0] + ver, self.meta.color["ENDC"], - " " * (23-len(pkg_split[0] + ver)), pkg_split[1], - " " * (18-len(pkg_split[1])), pkg_split[2], - " " * (8-len(pkg_split[2])), pkg_split[3], - " " * (7-len(pkg_split[3])), "Slack", + color, pkg_repo[0] + ver, self.meta.color["ENDC"], + " " * (23-len(pkg_repo[0] + ver)), pkg_repo[1], + " " * (18-len(pkg_repo[1])), pkg_repo[2], + " " * (8-len(pkg_repo[2])), pkg_repo[3], + " " * (7-len(pkg_repo[3])), "Slack", size, " K")).rstrip() + def find_installed(self, pkg): + """Return installed package name + """ + find = find_package(pkg + "-", self.meta.pkg_path) + if find: + return split_package(find[0])[0] + return "" + def upgrade(self): """ Upgrade packages