mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
update code
This commit is contained in:
parent
a191eb1ace
commit
496160ed0d
2 changed files with 105 additions and 103 deletions
|
@ -36,7 +36,7 @@ from pkg.manager import PackageManager
|
||||||
from sbo.check import sbo_check
|
from sbo.check import sbo_check
|
||||||
from sbo.views import SBoNetwork
|
from sbo.views import SBoNetwork
|
||||||
from sbo.tracking import track_dep
|
from sbo.tracking import track_dep
|
||||||
from sbo.slackbuild import sbo_install
|
from sbo.slackbuild import SBoInstall
|
||||||
|
|
||||||
from slack.install import Slack
|
from slack.install import Slack
|
||||||
from slack.patches import Patches
|
from slack.patches import Patches
|
||||||
|
@ -133,7 +133,7 @@ def main():
|
||||||
print(opt)
|
print(opt)
|
||||||
elif len(args) == 3 and args[0] == "-s":
|
elif len(args) == 3 and args[0] == "-s":
|
||||||
if args[1] == repository[0]:
|
if args[1] == repository[0]:
|
||||||
sbo_install(args[2])
|
SBoInstall(args[2]).start()
|
||||||
elif args[1] == repository[1]:
|
elif args[1] == repository[1]:
|
||||||
Slack(args[2], "stable").start()
|
Slack(args[2], "stable").start()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -44,84 +44,39 @@ from download import sbo_slackbuild_dwn
|
||||||
from dependency import sbo_dependencies_pkg
|
from dependency import sbo_dependencies_pkg
|
||||||
|
|
||||||
|
|
||||||
def sbo_install(name):
|
class SBoInstall(object):
|
||||||
'''
|
|
||||||
Download, build and install or upgrade packages
|
def __init__(self, name):
|
||||||
with all dependencies if version is greater than
|
self.name = name
|
||||||
that established.
|
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
||||||
'''
|
sys.stdout.flush()
|
||||||
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
initialization()
|
||||||
sys.stdout.flush()
|
self.UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||||
initialization()
|
self.dependencies_list = sbo_dependencies_pkg(name)
|
||||||
UNST = ["UNSUPPORTED",
|
|
||||||
"UNTESTED"]
|
def start(self):
|
||||||
dependencies_list = sbo_dependencies_pkg(name)
|
'''
|
||||||
try:
|
Download, build and install or upgrade packages
|
||||||
if dependencies_list or sbo_search_pkg(name) is not None:
|
with all dependencies if version is greater than
|
||||||
requires = one_for_all(name, dependencies_list)
|
that established.
|
||||||
dependencies = remove_dbs(requires)
|
'''
|
||||||
# sbo_versions = st[0]
|
try:
|
||||||
# package_arch = st[1]
|
if self.dependencies_list or sbo_search_pkg(self.name) is not None:
|
||||||
# package_sum = st[2]
|
requires = one_for_all(self.name, self.dependencies_list)
|
||||||
# sources = st[3]
|
dependencies = remove_dbs(requires)
|
||||||
st = store(dependencies, UNST)
|
# sbo_versions = st[0]
|
||||||
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
# package_arch = st[1]
|
||||||
(PKG_COLOR,
|
# package_sum = st[2]
|
||||||
count_upgraded,
|
# sources = st[3]
|
||||||
count_installed
|
st = store(dependencies, self.UNST)
|
||||||
) = pkg_colors_tag(name, st[0], 0, 0)
|
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
||||||
ARCH_COLOR = arch_colors_tag(UNST, st[1])
|
# count_upgraded = cnt[0]
|
||||||
print("\nThe following packages will be automatically installed "
|
# count_installed = cnt[1]
|
||||||
"or upgraded")
|
(PKG_COLOR, cnt) = pkg_colors_tag(self.name, st[0], 0, 0)
|
||||||
print("with new version:\n")
|
ARCH_COLOR = arch_colors_tag(self.UNST, st[1])
|
||||||
template(78)
|
print("\nThe following packages will be automatically "
|
||||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
"installed or upgraded")
|
||||||
"| Package", " " * 30,
|
print("with new version:\n")
|
||||||
"Version", " " * 10,
|
|
||||||
"Arch", " " * 9,
|
|
||||||
"Repository"))
|
|
||||||
template(78)
|
|
||||||
print("Installing:")
|
|
||||||
view(PKG_COLOR, name, st[0][-1], ARCH_COLOR, st[1][-1])
|
|
||||||
print("Installing for dependencies:")
|
|
||||||
for dep, ver, dep_arch in zip(dependencies[:-1], st[0][:-1],
|
|
||||||
st[1][:-1]):
|
|
||||||
(DEP_COLOR,
|
|
||||||
count_upgraded,
|
|
||||||
count_installed
|
|
||||||
) = pkg_colors_tag(dep, ver, count_upgraded, count_installed)
|
|
||||||
ARCH_COLOR = arch_colors_tag(UNST, dep)
|
|
||||||
view(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
|
|
||||||
# ins_msg = msg[0]
|
|
||||||
# upg_msg = msg[1]
|
|
||||||
# total_msg = msg[2]
|
|
||||||
msg = msgs(dependencies, count_installed, count_upgraded)
|
|
||||||
print("\nInstalling summary")
|
|
||||||
print("=" * 79)
|
|
||||||
print("{0}Total {1} {2}.".format(GREY, len(dependencies), msg[2]))
|
|
||||||
print("{0} {1} will be installed, {2} allready installed and "
|
|
||||||
"{3} {4}".format(count_installed, msg[0], st[2],
|
|
||||||
count_upgraded, msg[1]))
|
|
||||||
print("will be upgraded.{0}\n".format(ENDC))
|
|
||||||
read = arch_support(st[3], UNST, st[2], dependencies)
|
|
||||||
if read == "Y" or read == "y":
|
|
||||||
(installs,
|
|
||||||
upgraded,
|
|
||||||
versions
|
|
||||||
) = build_install(dependencies, st[0], st[1])
|
|
||||||
reference(count_installed, msg[0], count_upgraded, msg[1],
|
|
||||||
installs, versions, upgraded)
|
|
||||||
write_deps(name, dependencies)
|
|
||||||
else:
|
|
||||||
count_installed = count_uninstalled = 0
|
|
||||||
(sbo_matching,
|
|
||||||
sbo_ver,
|
|
||||||
pkg_arch
|
|
||||||
) = matching(name, UNST)
|
|
||||||
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
|
||||||
if sbo_matching:
|
|
||||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
|
||||||
CYAN, name, ENDC))
|
|
||||||
template(78)
|
template(78)
|
||||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
||||||
"| Package", " " * 30,
|
"| Package", " " * 30,
|
||||||
|
@ -129,30 +84,77 @@ def sbo_install(name):
|
||||||
"Arch", " " * 9,
|
"Arch", " " * 9,
|
||||||
"Repository"))
|
"Repository"))
|
||||||
template(78)
|
template(78)
|
||||||
print("Matching:")
|
print("Installing:")
|
||||||
ARCH_COLOR = ""
|
view(PKG_COLOR, self.name, st[0][-1], ARCH_COLOR, st[1][-1])
|
||||||
for match, ver, march in zip(sbo_matching, sbo_ver, pkg_arch):
|
print("Installing for dependencies:")
|
||||||
if find_package(match + sp + ver, pkg_path):
|
for dep, ver, dep_arch in zip(dependencies[:-1], st[0][:-1],
|
||||||
view(GREEN, match, ver, ARCH_COLOR, march)
|
st[1][:-1]):
|
||||||
count_installed += 1
|
(DEP_COLOR, cnt) = pkg_colors_tag(dep, ver, cnt[0], cnt[1])
|
||||||
else:
|
ARCH_COLOR = arch_colors_tag(self.UNST, dep)
|
||||||
view(RED, match, ver, ARCH_COLOR, march)
|
view(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
|
||||||
count_uninstalled += 1
|
|
||||||
# ins_msg = msg[0]
|
# ins_msg = msg[0]
|
||||||
# uns_msg = msg[1]
|
# upg_msg = msg[1]
|
||||||
# total_msg = msg[2]
|
# total_msg = msg[2]
|
||||||
msg = msgs(sbo_matching, count_installed, count_uninstalled)
|
msg = msgs(dependencies, cnt[1], cnt[0])
|
||||||
print("\nInstalling summary")
|
print("\nInstalling summary")
|
||||||
print("=" * 79)
|
print("=" * 79)
|
||||||
print("{0}Total found {1} matching {2}.".format(
|
print("{0}Total {1} {2}.".format(GREY, len(dependencies),
|
||||||
GREY, len(sbo_matching), msg[2]))
|
msg[2]))
|
||||||
print("{0} installed {1} and {2} uninstalled {3}.{4}\n".format(
|
print("{0} {1} will be installed, {2} allready installed and "
|
||||||
count_installed, msg[0], count_uninstalled, msg[1], ENDC))
|
"{3} {4}".format(cnt[1], msg[0], st[2],
|
||||||
|
cnt[0], msg[1]))
|
||||||
|
print("will be upgraded.{0}\n".format(ENDC))
|
||||||
|
read = arch_support(st[3], self.UNST, st[2], dependencies)
|
||||||
|
if read == "Y" or read == "y":
|
||||||
|
# installs = bi[0]
|
||||||
|
# upgraded = bi[1]
|
||||||
|
# versions = bi[2]
|
||||||
|
bi = build_install(dependencies, st[0], st[1])
|
||||||
|
reference(cnt[1], msg[0], cnt[0], msg[1], bi[0], bi[2],
|
||||||
|
bi[1])
|
||||||
|
write_deps(self.name, dependencies)
|
||||||
else:
|
else:
|
||||||
pkg_not_found("\n", name, "No matching", "\n")
|
count_installed = count_uninstalled = 0
|
||||||
except KeyboardInterrupt:
|
# sbo_matching = mt[0]
|
||||||
print # new line at exit
|
# sbo_ver = mt[1]
|
||||||
sys.exit()
|
# pkg_arch = mt[2]
|
||||||
|
mt = matching(self.name, self.UNST)
|
||||||
|
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
||||||
|
if mt[0]:
|
||||||
|
print("\nPackages with name matching [ {0}{1}{2} ]"
|
||||||
|
"\n".format(CYAN, self.name, 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 = ""
|
||||||
|
for match, ver, march in zip(mt[0], mt[1], mt[2]):
|
||||||
|
if find_package(match + sp + ver, pkg_path):
|
||||||
|
view(GREEN, match, ver, ARCH_COLOR, march)
|
||||||
|
count_installed += 1
|
||||||
|
else:
|
||||||
|
view(RED, match, ver, ARCH_COLOR, march)
|
||||||
|
count_uninstalled += 1
|
||||||
|
# ins_msg = msg[0]
|
||||||
|
# uns_msg = msg[1]
|
||||||
|
# total_msg = msg[2]
|
||||||
|
msg = msgs(mt[0], count_installed, count_uninstalled)
|
||||||
|
print("\nInstalling summary")
|
||||||
|
print("=" * 79)
|
||||||
|
print("{0}Total found {1} matching {2}.".format(
|
||||||
|
GREY, len(mt[0]), msg[2]))
|
||||||
|
print("{0} installed {1} and {2} uninstalled {3}.{4}"
|
||||||
|
"\n".format(count_installed, msg[0],
|
||||||
|
count_uninstalled, msg[1], ENDC))
|
||||||
|
else:
|
||||||
|
pkg_not_found("\n", self.name, "No matching", "\n")
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print # new line at exit
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def one_for_all(name, dependencies):
|
def one_for_all(name, dependencies):
|
||||||
|
@ -217,7 +219,7 @@ def pkg_colors_tag(name, sbo_versions, count_upg, count_ins):
|
||||||
else:
|
else:
|
||||||
color = RED
|
color = RED
|
||||||
count_ins += 1
|
count_ins += 1
|
||||||
return color, count_upg, count_ins
|
return color, [count_upg, count_ins]
|
||||||
|
|
||||||
|
|
||||||
def arch_colors_tag(support, package_arch):
|
def arch_colors_tag(support, package_arch):
|
||||||
|
@ -254,7 +256,7 @@ def msgs(packages, count_ins, count_uni):
|
||||||
ins_msg = ins_msg + "s"
|
ins_msg = ins_msg + "s"
|
||||||
if count_uni > 1:
|
if count_uni > 1:
|
||||||
uns_msg = uns_msg + "s"
|
uns_msg = uns_msg + "s"
|
||||||
return ins_msg, uns_msg, total_msg
|
return [ins_msg, uns_msg, total_msg]
|
||||||
|
|
||||||
|
|
||||||
def arch_support(source, support, package_sum, dependencies):
|
def arch_support(source, support, package_sum, dependencies):
|
||||||
|
@ -320,7 +322,7 @@ def build_install(dependencies, sbo_versions, packages_arch):
|
||||||
PackageManager(binary).upgrade()
|
PackageManager(binary).upgrade()
|
||||||
installs.append(pkg)
|
installs.append(pkg)
|
||||||
versions.append(ver)
|
versions.append(ver)
|
||||||
return installs, upgraded, versions
|
return [installs, upgraded, versions]
|
||||||
|
|
||||||
|
|
||||||
def reference(*args):
|
def reference(*args):
|
||||||
|
@ -383,7 +385,7 @@ def matching(name, support):
|
||||||
sources = SBoGrep(sbo_name).source()
|
sources = SBoGrep(sbo_name).source()
|
||||||
packages_arch.append(select_arch(sources, support))
|
packages_arch.append(select_arch(sources, support))
|
||||||
SLACKBUILDS_TXT.close()
|
SLACKBUILDS_TXT.close()
|
||||||
return sbo_matching, sbo_versions, packages_arch
|
return [sbo_matching, sbo_versions, packages_arch]
|
||||||
|
|
||||||
|
|
||||||
def select_arch(src, support):
|
def select_arch(src, support):
|
||||||
|
|
Loading…
Reference in a new issue