Fix matching binary packages

This commit is contained in:
Dimitris Zlatanidis 2015-07-18 02:18:15 +03:00
parent fac2e67770
commit ed3f5ca56c
2 changed files with 35 additions and 18 deletions

View file

@ -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]

View file

@ -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):
pkg_repo = split_package(upg[:-4])
color = self.meta.color["RED"]
ver = get_installed_version(pkg_split[0])
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