From d83055f9c464af6914c7d591f211c744748d92ba Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 20 Aug 2014 07:11:07 +0300 Subject: [PATCH] updated sum view, sbo_version --- slpkg/sbo/check.py | 2 +- slpkg/sbo/greps.py | 20 +++++++++-------- slpkg/sbo/search.py | 10 ++++----- slpkg/sbo/slackbuild.py | 50 ++++++++++++++++++++++------------------- slpkg/sbo/views.py | 2 +- 5 files changed, 45 insertions(+), 39 deletions(-) diff --git a/slpkg/sbo/check.py b/slpkg/sbo/check.py index 2cf165fc..58cb5ffa 100755 --- a/slpkg/sbo/check.py +++ b/slpkg/sbo/check.py @@ -60,7 +60,7 @@ def sbo_check(name): pkg_not_found(bol, name, message, eol) else: sys.stdout.write("Done\n") - sbo_version = sbo_version_pkg(sbo_url, name) + sbo_version = sbo_version_pkg(name) sbo_dwn = sbo_slackbuild_dwn(sbo_url, name) source_dwn = sbo_source_dwn(sbo_url, name) extra_dwn = sbo_extra_dwn(sbo_url, name) diff --git a/slpkg/sbo/greps.py b/slpkg/sbo/greps.py index 321924a1..2da641e4 100755 --- a/slpkg/sbo/greps.py +++ b/slpkg/sbo/greps.py @@ -24,7 +24,7 @@ import os from url_read import url_read -from __metadata__ import arch +from __metadata__ import arch, lib_path def sbo_source_dwn(sbo_url, name): ''' @@ -64,11 +64,13 @@ def sbo_requires_pkg(sbo_url, name): if line.startswith("REQUIRES=\""): return line[10:-1].strip() -def sbo_version_pkg(sbo_url, name): - ''' - Grep package version - ''' - read_info = url_read(sbo_url + name + ".info") - for line in read_info.splitlines(): - if line.startswith("VERSION=\""): - return line[9:-1].strip() +def sbo_version_pkg(name): + sbo_name, sbo_ver = [], [] + for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"): + if line.startswith("SLACKBUILD NAME: "): + sbo_name.append(line[17:].strip()) + if line.startswith("SLACKBUILD VERSION: "): + sbo_ver.append(line[20:].strip()) + for nam, ver in zip(sbo_name, sbo_ver): + if nam == name: + return ver diff --git a/slpkg/sbo/search.py b/slpkg/sbo/search.py index a9d5b9e8..f6b3913c 100755 --- a/slpkg/sbo/search.py +++ b/slpkg/sbo/search.py @@ -41,12 +41,12 @@ def sbo_search_pkg(name): sbo_location = [] sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver())) for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"): - if line.startswith('SLACKBUILD LOCATION'): - sbo_location.append(line.replace('SLACKBUILD LOCATION: ./', '')) + if line.startswith("SLACKBUILD LOCATION"): + sbo_location.append(line.replace("SLACKBUILD LOCATION: ./", "")) for location in sbo_location: - location = location.replace('\n', '') - if get_file(location, '/') == name: - return sbo_url + location.replace(name, '') + name + "/" + location = location.replace("\n", "") + if get_file(location, "/") == name: + return sbo_url + location.replace(name, "") + name + "/" except KeyboardInterrupt: print # new line at exit sys.exit() diff --git a/slpkg/sbo/slackbuild.py b/slpkg/sbo/slackbuild.py index badd3717..2fbe8736 100755 --- a/slpkg/sbo/slackbuild.py +++ b/slpkg/sbo/slackbuild.py @@ -64,31 +64,34 @@ def sbo_build(name): if duplicate not in dependencies: dependencies.append(duplicate) pkg_sum = 0 - dep_report = [] - for dep in dependencies: - if find_package(dep + sp, pkg_path): - dep_report.append(colors.GREEN + dep + colors.ENDC) - pkg_sum += 1 - else: - dep_report.append(colors.RED + dep + colors.ENDC) - inst = "".join(dependencies[-1:]) - sbo_url = sbo_search_pkg(inst) - sbo_ver = sbo_version_pkg(sbo_url, inst) - print len(sbo_ver) - sys.stdout.write("Done") - print # new lines at start + pkg_for_install = [] + if find_package(name + sp, pkg_path): + pkg_for_install.append(colors.GREEN + name + colors.ENDC) + pkg_sum = 1 + else: + pkg_for_install.append(colors.RED + name + colors.ENDC) + sbo_url = sbo_search_pkg(name) + sbo_ver = sbo_version_pkg(name) + sys.stdout.write("Done\n") print("The following packages will be automatically installed or upgraded with new version:\n") template(78) - print "| Package", " "*15, "Arch", " "*5, "Version", " "*7, "Repository", " "*4, "Size", " "*5 + print "| Package", " "*15, "Version", " "*5, "Arch", " "*7, "Repository" template(78) - inst_size = round((int("".join(server_file_size(sbo_slackbuild_dwn(sbo_url, inst)))) + int( - "".join(server_file_size(sbo_source_dwn(sbo_url, inst))))) * 9.5367431640625e-07, 2) print("Installing:") - print " ", "".join(dep_report[-1:]), " "*(22-len(inst)), arch, " "*3, sbo_ver, " "*(14-len( - sbo_ver)), "SBo", " "*11, inst_size, "Mb" + print " ", "".join(pkg_for_install), " "*(22-len(name)), sbo_ver, " "*( + 12-len(sbo_ver)), arch, " "*5, "SBo" print("Installing for dependencies:") - print(" " + " ".join(dep_report[:-1]) + "\n") - print("Installing summary") + for dep in dependencies[:-1]: + sbo_url = sbo_search_pkg(dep) + sbo_ver = sbo_version_pkg(dep) + if find_package(dep + sp, pkg_path): + print " ", colors.GREEN + dep + colors.ENDC, " "*(22-len(dep)), sbo_ver, " "*( + 12-len(sbo_ver)), arch, " "*5, "SBo" + pkg_sum += 1 + else: + print " ", colors.RED + dep + colors.ENDC, " "*(22-len(dep)), sbo_ver, " "*( + 12-len(sbo_ver)), arch, " "*5, "SBo" + print("\nInstalling summary") print("="*79) print("Total {0} packages.".format(len(dependencies))) print("{0} packages will be installed, {1} allready installed.".format( @@ -97,11 +100,11 @@ def sbo_build(name): if read == "Y" or read == "y": for pkg in dependencies: sbo_url = sbo_search_pkg(pkg) - sbo_version = sbo_version_pkg(sbo_url, pkg) + sbo_version = sbo_version_pkg(pkg) sbo_file = "".join(find_package(pkg + sp, pkg_path)) sbo_file_version = sbo_file[len(pkg) + 1:-len(arch) - 7] if sbo_version > sbo_file_version: - prgnam = ("{0}-{1}".format(pkg, sbo_version_pkg(sbo_url, pkg))) + prgnam = ("{0}-{1}".format(pkg, sbo_version_pkg(pkg))) sbo_link = sbo_slackbuild_dwn(sbo_url, pkg) src_link = sbo_source_dwn(sbo_url, pkg) ext_link = sbo_extra_dwn(sbo_url, pkg) @@ -121,7 +124,8 @@ def sbo_build(name): pkg_found(pkg, sbo_file_version) template(78) ''' - Write dependencies in a log file into directory `/var/log/slpkg/dep/` + Write dependencies in a log file + into directory `/var/log/slpkg/dep/` ''' dep_path = log_path + "dep/" if not os.path.exists(dep_path): diff --git a/slpkg/sbo/views.py b/slpkg/sbo/views.py index 091231fa..d1f6319a 100755 --- a/slpkg/sbo/views.py +++ b/slpkg/sbo/views.py @@ -59,7 +59,7 @@ def sbo_network(name): sys.stdout.write ("Done\n") sbo_req = sbo_requires_pkg(sbo_url, name) sbo_dwn = sbo_slackbuild_dwn(sbo_url, name) - sbo_version = sbo_version_pkg(sbo_url, name) + sbo_version = sbo_version_pkg(name) source_dwn = sbo_source_dwn(sbo_url, name) extra_dwn = " ".join(sbo_extra_dwn(sbo_url, name)) view_sbo(name, sbo_url, get_file(sbo_dwn, "/"), get_file(source_dwn, "/"),