updated sum view, sbo_version

This commit is contained in:
Dimitris Zlatanidis 2014-08-20 07:11:07 +03:00
parent 6bbde1892f
commit d83055f9c4
5 changed files with 45 additions and 39 deletions

View file

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

View file

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

View file

@ -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()

View file

@ -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):

View file

@ -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, "/"),