This commit is contained in:
Dimitris Zlatanidis 2014-08-25 09:01:11 +03:00
parent 2e8fa423af
commit afd81b666b

View file

@ -44,14 +44,13 @@ def sbo_check():
Upgrade all slackbuilds packages from slackbuilds.org Upgrade all slackbuilds packages from slackbuilds.org
repository repository
''' '''
try:
sys.stdout.write("Reading package lists ...") sys.stdout.write("Reading package lists ...")
sys.stdout.flush() sys.stdout.flush()
index, toolbar_width = 0, 3 index, toolbar_width = 0, 3
sbo_list, pkg_name, sbo_ver, pkg_for_upg = [], [], [], [] pkg_name, sbo_ver, pkg_for_upg = [], [], []
for pkg in os.listdir(pkg_path): for pkg in os.listdir(pkg_path):
if "_SBo" in pkg: if "_SBo" in pkg:
sbo_list.append(pkg)
for pkg in sbo_list:
index += 1 index += 1
if index == toolbar_width: if index == toolbar_width:
sys.stdout.write(".") sys.stdout.write(".")
@ -68,10 +67,8 @@ def sbo_check():
else: else:
arch = os.uname()[4] arch = os.uname()[4]
name = pkg[:-(len(arch) + len("_SBo") + 3)] name = pkg[:-(len(arch) + len("_SBo") + 3)]
pkg_version = get_file(name, "-") pkg_version = get_file(name, "-")[1:]
pkg_version = pkg_version[1:]
name = name[:-(len(pkg_version) + 1)] name = name[:-(len(pkg_version) + 1)]
sbo_url = sbo_search_pkg(name)
sbo_version = sbo_version_pkg(name) sbo_version = sbo_version_pkg(name)
if sbo_version > pkg_version: if sbo_version > pkg_version:
pkg_name.append(name) pkg_name.append(name)
@ -81,18 +78,18 @@ def sbo_check():
if pkg_for_upg: if pkg_for_upg:
print("\nThese packages need upgrading:\n") print("\nThese packages need upgrading:\n")
template(78) template(78)
print "| Package", " "*15, "New version", " "*5, "Arch", " "*7, "Repository" print "| Package", " "*27, "New version", " "*5, "Arch", " "*7, "Repository"
template(78) template(78)
print("Upgrading:") print("Upgrading:")
for upg, ver in zip(pkg_for_upg, sbo_ver): for upg, ver in zip(pkg_for_upg, sbo_ver):
print " ", upg, " "*(22-len(upg)), ver, " "*( print " ", upg, " "*(34-len(upg)), ver, " "*(
16-len(ver)), arch, " "*(11-len(arch)), "SBo" 16-len(ver)), arch, " "*(11-len(arch)), "SBo"
msg_pkg = "package" msg_pkg = "package"
if len(pkg_for_upg) > 1: if len(pkg_for_upg) > 1:
msg_pkg = msg_pkg + "s" msg_pkg = msg_pkg + "s"
print("\nInstalling summary") print("\nInstalling summary")
print("=" * 79) print("=" * 79)
print("Total {0} {1} will be upgrading.\n".format(len(pkg_for_upg), msg_pkg)) print("Total {0} {1} will be upgraded.\n".format(len(pkg_for_upg), msg_pkg))
read = raw_input("Would you like to upgrade [Y/n]? ") read = raw_input("Would you like to upgrade [Y/n]? ")
if read == "Y" or read == "y": if read == "Y" or read == "y":
if not os.path.exists(build_path): if not os.path.exists(build_path):
@ -113,7 +110,12 @@ def sbo_check():
build_package(script, sources, build_path) build_package(script, sources, build_path)
binary = ("{0}{1}{2}{3}{4}".format( binary = ("{0}{1}{2}{3}{4}".format(
tmp, pkg_for_install, sbo_arch, sbo_tag, sbo_filetype).split()) tmp, pkg_for_install, sbo_arch, sbo_tag, sbo_filetype).split())
print("{0}[ Upgrading ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, name))
pkg_upgrade(binary) pkg_upgrade(binary)
print("Completed!\n") print("Completed!\n")
else: else:
print("\nAll packages are up to date\n") print("\nAll packages are up to date\n")
except KeyboardInterrupt:
print # new line at exit
sys.exit()