mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
added matching packages
This commit is contained in:
parent
8316a76578
commit
1a8d07c79e
2 changed files with 93 additions and 30 deletions
|
@ -90,12 +90,13 @@ def template(max):
|
|||
'''
|
||||
print("+" + "=" * max)
|
||||
|
||||
def view_sbo(pkg, sbo_url, sbo_dwn, source_dwn, sbo_req):
|
||||
def view_sbo(pkg, sbo_url, sbo_desc, sbo_dwn, source_dwn, sbo_req):
|
||||
print # new line at start
|
||||
template(78)
|
||||
print("| {0}Package {1}{2}{3} --> {4}".format(colors.GREEN,
|
||||
colors.CYAN, pkg, colors.GREEN, colors.ENDC + sbo_url))
|
||||
template(78)
|
||||
print("| {0}Description : {1}{2}".format(colors.GREEN, colors.ENDC, sbo_desc))
|
||||
print("| {0}SlackBuild : {1}{2}".format(colors.GREEN, colors.ENDC, sbo_dwn))
|
||||
print("| {0}Sources : {1}{2}".format(colors.GREEN, colors.ENDC, source_dwn))
|
||||
print("| {0}Requirements : {1}{2}".format(colors.YELLOW, colors.ENDC,
|
||||
|
@ -109,3 +110,13 @@ def view_sbo(pkg, sbo_url, sbo_dwn, source_dwn, sbo_req):
|
|||
print(" {0}I{1}nstall Download/Build/Install".format(colors.RED, colors.ENDC))
|
||||
print(" {0}Q{1}uit Quit\n".format(colors.RED, colors.ENDC))
|
||||
|
||||
def sbo_packages_view(PKG_COLOR, package, version, ARCH_COLOR, arch):
|
||||
'''
|
||||
View slackbuild packages with version and arch
|
||||
'''
|
||||
ENDC = colors.ENDC
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(PKG_COLOR, package, ENDC, \
|
||||
" " * (38-len(package)), version, \
|
||||
" " * (17-len(version)), ARCH_COLOR, arch, ENDC, \
|
||||
" " * (13-len(arch)), "SBo"))
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ import subprocess
|
|||
|
||||
from colors import colors
|
||||
from functions import get_file
|
||||
from __metadata__ import tmp, pkg_path, build_path, log_path, sp
|
||||
from messages import pkg_not_found, pkg_found, template, build_FAILED
|
||||
from __metadata__ import tmp, pkg_path, build_path, log_path, sp, lib_path
|
||||
from messages import pkg_not_found, pkg_found, template, build_FAILED, sbo_packages_view
|
||||
|
||||
from pkg.find import find_package
|
||||
from pkg.build import build_package
|
||||
|
@ -46,18 +46,20 @@ def sbo_build(name):
|
|||
with all dependencies if version is greater than
|
||||
that established.
|
||||
'''
|
||||
sys.stdout.write("{0}Building dependency tree ...{1}".format(
|
||||
arch = os.uname()[4]
|
||||
sbo_ver, pkg_arch, installs, upgraded, \
|
||||
versions, requires, dependencies = ([] for i in range(7))
|
||||
PKG_COLOR = DEP_COLOR = ARCH_COLOR = str()
|
||||
GREEN, RED, GREY, ENDC = colors.GREEN, colors.RED, \
|
||||
colors.GREY, colors.ENDC
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(
|
||||
colors.GREY, colors.ENDC))
|
||||
sys.stdout.flush()
|
||||
initialization()
|
||||
dependencies_list = sbo_dependencies_pkg(name)
|
||||
try:
|
||||
if dependencies_list is not None:
|
||||
pkg_sum = count_upgraded = count_installed = int()
|
||||
sbo_ver, pkg_arch, installs, upgraded, \
|
||||
versions, requires, dependencies = ([] for i in range(7))
|
||||
PKG_COLOR = DEP_COLOR = ARCH_COLOR = str()
|
||||
ENDC = colors.ENDC
|
||||
arch = os.uname()[4]
|
||||
# Insert master package in list to
|
||||
# install it after dependencies
|
||||
requires.append(name)
|
||||
|
@ -75,18 +77,18 @@ def sbo_build(name):
|
|||
version = sbo_version_pkg(pkg)
|
||||
sbo_ver.append(version)
|
||||
src = sbo_source_dwn(pkg)
|
||||
if arch == "x86_64":
|
||||
# Looks if sources unsupported or untested
|
||||
# from arch else select arch
|
||||
if "UNSUPPORTED" in src:
|
||||
pkg_arch.append("UNSUPPORTED")
|
||||
elif "UNTESTED" in src:
|
||||
pkg_arch.append("UNTESTED")
|
||||
elif arch == "x86_64":
|
||||
pkg_arch.append("x86_64")
|
||||
elif arch.startswith("i") and arch.endswith("86"):
|
||||
pkg_arch.append("i486")
|
||||
elif "arm" in arch:
|
||||
pkg_arch.append("arm")
|
||||
# Looks if sources unsupported or untested
|
||||
# from arch
|
||||
if "UNSUPPORTED" in src:
|
||||
pkg_arch.append("UNSUPPORTED")
|
||||
elif "UNTESTED" in src:
|
||||
pkg_arch.append("UNTESTED")
|
||||
sbo_pkg = ("{0}-{1}".format(pkg, version))
|
||||
if find_package(sbo_pkg, pkg_path):
|
||||
pkg_sum += 1
|
||||
|
@ -116,10 +118,7 @@ def sbo_build(name):
|
|||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
print("Installing:")
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(PKG_COLOR, name, ENDC, \
|
||||
" " * (38-len(name)), sbo_ver[-1], \
|
||||
" " * (17-len(sbo_ver[-1])), ARCH_COLOR, pkg_arch[-1], ENDC, \
|
||||
" " * (13-len(pkg_arch[-1])), "SBo"))
|
||||
sbo_packages_view(PKG_COLOR, name, sbo_ver[-1], ARCH_COLOR, pkg_arch[-1])
|
||||
print("Installing for dependencies:")
|
||||
ARCH_COLOR = "" # reset arch color for dependencies packages
|
||||
for dep, ver, dep_arch in zip(dependencies[:-1], sbo_ver[:-1], pkg_arch[:-1]):
|
||||
|
@ -136,10 +135,7 @@ def sbo_build(name):
|
|||
ARCH_COLOR = colors.RED
|
||||
elif "UNTESTED" in dep_arch:
|
||||
ARCH_COLOR = colors.YELLOW
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(DEP_COLOR, dep, ENDC, \
|
||||
" " * (38-len(dep)), ver, \
|
||||
" " * (17-len(ver)), ARCH_COLOR, dep_arch, ENDC, \
|
||||
" " * (13-len(dep_arch)), "SBo"))
|
||||
sbo_packages_view(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
|
||||
msg_ins = "package"
|
||||
msg_upg = msg_ins
|
||||
if count_installed > 1:
|
||||
|
@ -148,10 +144,10 @@ def sbo_build(name):
|
|||
msg_upg = msg_upg + "s"
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("Total {0} {1}.".format(len(dependencies), msg_ins))
|
||||
print("{0} {1} will be installed, {2} allready installed and {3} {4}".format(
|
||||
count_installed, msg_ins, pkg_sum, count_upgraded, msg_upg))
|
||||
print("will be upgraded.\n")
|
||||
print("{0}Total {1} {2}.{3}".format(GREY, len(dependencies), msg_ins, ENDC))
|
||||
print("{0}{1} {2} will be installed, {3} allready installed and {4} {5}{6}".format(
|
||||
GREY, count_installed, msg_ins, pkg_sum, count_upgraded, msg_upg, ENDC))
|
||||
print("{0}will be upgraded.{1}\n".format(GREY, ENDC))
|
||||
# Check if package supported or tested by arch
|
||||
# before proceed to install
|
||||
UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
|
@ -240,9 +236,65 @@ def sbo_build(name):
|
|||
f.write(dep + "\n")
|
||||
f.close()
|
||||
else:
|
||||
ins = uns = int()
|
||||
sbo_matching = []
|
||||
index, toolbar_width = int(), 3
|
||||
for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
|
||||
if line.startswith("SLACKBUILD NAME: "):
|
||||
sbo_name = line[17:].strip()
|
||||
if name in sbo_name:
|
||||
index += 1
|
||||
if index == toolbar_width:
|
||||
sys.stdout.write("{0}.{1}".format(colors.GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
toolbar_width += 6
|
||||
sbo_matching.append(sbo_name)
|
||||
sbo_ver.append(sbo_version_pkg(sbo_name))
|
||||
src = sbo_source_dwn(sbo_name)
|
||||
# Looks if sources unsupported or untested
|
||||
# from arch else select arch
|
||||
if "UNSUPPORTED" in src:
|
||||
pkg_arch.append("UNSUPPORTED")
|
||||
elif "UNTESTED" in src:
|
||||
pkg_arch.append("UNTESTED")
|
||||
elif arch == "x86_64":
|
||||
pkg_arch.append("x86_64")
|
||||
elif arch.startswith("i") and arch.endswith("86"):
|
||||
pkg_arch.append("i486")
|
||||
elif "arm" in arch:
|
||||
pkg_arch.append("arm")
|
||||
sys.stdout.write("{0}Done{1}\n".format(colors.GREY, colors.ENDC))
|
||||
message = "From slackbuilds.org"
|
||||
pkg_not_found("\n", name, message, "\n")
|
||||
if sbo_matching:
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
colors.CYAN, name, colors.ENDC))
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format("| Package", " " * 30, "Version", \
|
||||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
print("Matching:")
|
||||
ARCH_COLOR = str()
|
||||
for match, ver, march in zip(sbo_matching, sbo_ver, pkg_arch):
|
||||
if find_package(match + sp + ver, pkg_path):
|
||||
sbo_packages_view(GREEN, match, ver, ARCH_COLOR, march)
|
||||
ins += 1
|
||||
else:
|
||||
sbo_packages_view(RED, match, ver, ARCH_COLOR, march)
|
||||
uns += 1
|
||||
total_msg = ins_msg = uns_msg = "package"
|
||||
if len(sbo_matching) > 1:
|
||||
total_msg = total_msg + "s"
|
||||
if ins > 1:
|
||||
ins_msg = ins_msg + "s"
|
||||
if uns > 1:
|
||||
uns_msg = uns_msg + "s"
|
||||
print("\nMatching summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total found {1} matching {2}.{3}".format(
|
||||
GREY, len(sbo_matching), total_msg, ENDC))
|
||||
print("{0}{1} installed {2} and {3} uninstalled {4}.{5}\n".format(
|
||||
GREY, ins, ins_msg, uns, uns_msg, ENDC))
|
||||
else:
|
||||
print("\nNo package was found to match\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
Loading…
Add table
Reference in a new issue