mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-28 19:58:18 +01:00
upgrade source
This commit is contained in:
parent
3e9d5ebb34
commit
b77b46999f
11 changed files with 318 additions and 255 deletions
|
@ -28,11 +28,11 @@ from colors import RED, GREEN, ENDC
|
|||
|
||||
|
||||
class BlackList(object):
|
||||
|
||||
'''
|
||||
Blacklist class to add, remove or listed packages
|
||||
in blacklist file.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
'''
|
||||
Initialization blacklist file if not exist in /etc/slpkg
|
||||
|
|
|
@ -40,8 +40,8 @@ class Download(object):
|
|||
Check if file already download the skip or continue
|
||||
download if before stoped.
|
||||
'''
|
||||
print("\n{0}[ Download ] -->{1} {2}\n".format(GREEN, ENDC,
|
||||
self.file_name))
|
||||
print("\n[ {0}Download{1} ] -->{1} {2}\n".format(GREEN, ENDC,
|
||||
self.file_name))
|
||||
try:
|
||||
subprocess.call("wget -c -N --directory-prefix={0} {1}".format(
|
||||
self.path, self.url), shell=True)
|
||||
|
|
|
@ -36,7 +36,7 @@ from pkg.manager import PackageManager
|
|||
from sbo.check import sbo_check
|
||||
from sbo.views import sbo_network
|
||||
from sbo.tracking import track_dep
|
||||
from sbo.slackbuild import sbo_build
|
||||
from sbo.slackbuild import SlackBuild
|
||||
|
||||
from slack.patches import patches
|
||||
from slack.install import install
|
||||
|
@ -133,7 +133,7 @@ def main():
|
|||
print(opt)
|
||||
elif len(args) == 3 and args[0] == "-s":
|
||||
if args[1] == repository[0]:
|
||||
sbo_build(args[2])
|
||||
SlackBuild(args[2]).start()
|
||||
elif args[1] == repository[1]:
|
||||
version = "stable"
|
||||
install(args[2], version)
|
||||
|
|
|
@ -93,14 +93,3 @@ def view_sbo(pkg, sbo_url, sbo_desc, sbo_dwn, source_dwn, sbo_req):
|
|||
print(" {0}I{1}nstall Download/Build/Install".format(
|
||||
RED, ENDC))
|
||||
print(" {0}Q{1}uit Quit\n".format(RED, ENDC))
|
||||
|
||||
|
||||
def sbo_packages_view(PKG_COLOR, package, version, ARCH_COLOR, arch):
|
||||
'''
|
||||
View slackbuild packages with version and arch
|
||||
'''
|
||||
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"))
|
||||
|
|
|
@ -37,6 +37,7 @@ class PackageManager(object):
|
|||
Package manager class for install, upgrade,
|
||||
reinstall, remove, find and display packages.
|
||||
'''
|
||||
|
||||
def __init__(self, binary):
|
||||
self.binary = binary
|
||||
|
||||
|
@ -52,7 +53,7 @@ class PackageManager(object):
|
|||
except subprocess.CalledProcessError:
|
||||
message = "Can't install"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
bol = eol = ""
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
@ -69,7 +70,7 @@ class PackageManager(object):
|
|||
except subprocess.CalledProcessError:
|
||||
message = "Can't upgrade"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
bol = eol = ""
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
@ -87,7 +88,7 @@ class PackageManager(object):
|
|||
except subprocess.CalledProcessError:
|
||||
message = "Can't reinstall"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
bol = eol = ""
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
@ -108,7 +109,7 @@ class PackageManager(object):
|
|||
for pkg in self.binary:
|
||||
pkgs = find_package(pkg + sp, pkg_path)
|
||||
if pkgs:
|
||||
print("{0}[ delete ]{1} --> {2}".format(RED, ENDC,
|
||||
print("[ {0}delete{1} ] --> {2}".format(RED, ENDC,
|
||||
"\n ".join(pkgs)))
|
||||
|
||||
removed.append(pkg)
|
||||
|
@ -196,7 +197,7 @@ class PackageManager(object):
|
|||
Find installed Slackware packages
|
||||
'''
|
||||
self.binary = "".join(self.binary)
|
||||
matching = size = int()
|
||||
matching = size = 0
|
||||
print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
|
||||
CYAN, self.binary, ENDC))
|
||||
for match in find_package(self.binary, pkg_path):
|
||||
|
@ -241,7 +242,7 @@ class PackageManager(object):
|
|||
else:
|
||||
message = "Can't dislpay"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
bol = eol = ""
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
|
|
@ -40,6 +40,7 @@ class QueuePkgs(object):
|
|||
Class to list, add or remove packages in queue,
|
||||
also build or install.
|
||||
'''
|
||||
|
||||
def __init__(self):
|
||||
queue_file = [
|
||||
"# In this file you can create a list of\n",
|
||||
|
|
|
@ -55,7 +55,7 @@ def sbo_check():
|
|||
sys.stdout.write(reading_lists)
|
||||
sys.stdout.flush()
|
||||
initialization()
|
||||
index, toolbar_width = int(), 3
|
||||
index, toolbar_width = 0, 3
|
||||
[
|
||||
dependencies,
|
||||
dependencies_list,
|
||||
|
@ -152,7 +152,7 @@ def sbo_check():
|
|||
"Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
print("Upgrading:")
|
||||
count_upgraded = count_installed = int()
|
||||
count_upgraded = count_installed = 0
|
||||
for upg, ver, arch in zip(pkg_for_upg, upg_ver, upg_arch):
|
||||
if find_package(upg[:-len(ver)], pkg_path):
|
||||
COLOR = YELLOW
|
||||
|
@ -205,10 +205,10 @@ def sbo_check():
|
|||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
if find_package(name + sp, pkg_path):
|
||||
print("{0}[ Upgrading ] --> {1}{2}".format(
|
||||
GREEN, ENDC, name))
|
||||
print("[ {0}Upgrading{1} ] --> {2}".format(
|
||||
YELLOW, ENDC, name))
|
||||
else:
|
||||
print("{0}[ Installing ] --> {1}{2}".format(
|
||||
print("[ {0}Installing{1} ] --> {2}".format(
|
||||
GREEN, ENDC, name))
|
||||
# Use this list to pick out what
|
||||
# packages will be installed
|
||||
|
|
|
@ -26,12 +26,12 @@ import sys
|
|||
|
||||
from init import initialization
|
||||
from downloader import Download
|
||||
from splitting import split_package
|
||||
from __metadata__ import (tmp, pkg_path, build_path,
|
||||
log_path, lib_path, sp)
|
||||
from colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC
|
||||
from messages import (pkg_found, template, build_FAILED,
|
||||
pkg_not_found, sbo_packages_view)
|
||||
|
||||
pkg_not_found)
|
||||
|
||||
from pkg.find import find_package
|
||||
from pkg.build import build_package
|
||||
|
@ -43,85 +43,100 @@ from download import sbo_slackbuild_dwn
|
|||
from dependency import sbo_dependencies_pkg
|
||||
|
||||
|
||||
def sbo_build(name):
|
||||
class SlackBuild(object):
|
||||
'''
|
||||
Download, build and install or upgrade packages
|
||||
with all dependencies if version is greater than
|
||||
that established.
|
||||
'''
|
||||
done = "{0}Done{1}\n".format(GREY, ENDC)
|
||||
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
|
||||
sys.stdout.write(reading_lists)
|
||||
sys.stdout.flush()
|
||||
initialization()
|
||||
[
|
||||
sbo_ver,
|
||||
pkg_arch,
|
||||
installs,
|
||||
upgraded,
|
||||
versions,
|
||||
requires,
|
||||
dependencies
|
||||
] = ([] for i in range(7))
|
||||
PKG_COLOR = DEP_COLOR = ARCH_COLOR = str()
|
||||
dependencies_list = sbo_dependencies_pkg(name)
|
||||
try:
|
||||
if dependencies_list or sbo_search_pkg(name) is not None:
|
||||
pkg_sum = count_upgraded = count_installed = int()
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.src = []
|
||||
self.sbo_ver = []
|
||||
self.pkg_arch = []
|
||||
self.installs = []
|
||||
self.upgraded = []
|
||||
self.versions = []
|
||||
self.requires = []
|
||||
self.dependencies = []
|
||||
self.pkg_sum = 0
|
||||
self.done = "{0}Done{1}\n".format(GREY, ENDC)
|
||||
self.reading_lists = "{0}Reading package lists ...{1}".format(GREY,
|
||||
ENDC)
|
||||
initialization()
|
||||
|
||||
def start(self):
|
||||
'''
|
||||
Create list with package and dependencies
|
||||
'''
|
||||
sys.stdout.write(self.reading_lists)
|
||||
sys.stdout.flush()
|
||||
dependencies_list = sbo_dependencies_pkg(self.name)
|
||||
if dependencies_list or sbo_search_pkg(self.name) is not None:
|
||||
# Insert master package in list to
|
||||
# install it after dependencies
|
||||
requires.append(name)
|
||||
self.requires.append(self.name)
|
||||
# Create one list for all packages
|
||||
for pkg in dependencies_list:
|
||||
requires += pkg
|
||||
requires.reverse()
|
||||
self.requires += pkg
|
||||
self.requires.reverse()
|
||||
# Remove double dependencies
|
||||
for duplicate in requires:
|
||||
if duplicate not in dependencies:
|
||||
dependencies.append(duplicate)
|
||||
for duplicate in self.requires:
|
||||
if duplicate not in self.dependencies:
|
||||
self.dependencies.append(duplicate)
|
||||
# Create two lists one for package version and one
|
||||
# for package arch.
|
||||
for pkg in dependencies:
|
||||
version = SBoGrep(pkg).version()
|
||||
sbo_ver.append(version)
|
||||
src = SBoGrep(pkg).source()
|
||||
pkg_arch.append(select_arch(src))
|
||||
for pkg in self.dependencies:
|
||||
grep = SBoGrep(pkg)
|
||||
version = grep.version()
|
||||
self.sbo_ver.append(version)
|
||||
self.src = grep.source()
|
||||
self.pkg_arch.append(self._select_arch(self.src))
|
||||
sbo_pkg = ("{0}-{1}".format(pkg, version))
|
||||
if find_package(sbo_pkg, pkg_path):
|
||||
pkg_sum += 1
|
||||
sys.stdout.write(done)
|
||||
self.pkg_sum += 1
|
||||
sys.stdout.write(self.done)
|
||||
self._process() # continue to install packages
|
||||
else:
|
||||
self._matching() # view matching packages
|
||||
|
||||
def _process(self):
|
||||
'''
|
||||
Continue build and install or upgrade packages with all
|
||||
dependencies.
|
||||
'''
|
||||
count_upgraded = count_installed = 0
|
||||
PKG_COLOR = DEP_COLOR = ARCH_COLOR = ""
|
||||
try:
|
||||
# Tag with color green if package already installed,
|
||||
# color yellow for packages to upgrade and color red
|
||||
# if not installed. Also if package arch is UNSUPPORTED
|
||||
# tag with color red and if UNTESTED with color yellow.
|
||||
master_pkg = ("{0}-{1}".format(name, sbo_ver[-1]))
|
||||
master_pkg = ("{0}-{1}".format(self.name, self.sbo_ver[-1]))
|
||||
if find_package(master_pkg, pkg_path):
|
||||
PKG_COLOR = GREEN
|
||||
elif find_package(name + sp, pkg_path):
|
||||
elif find_package(self.name + sp, pkg_path):
|
||||
PKG_COLOR = YELLOW
|
||||
count_upgraded += 1
|
||||
else:
|
||||
PKG_COLOR = RED
|
||||
count_installed += 1
|
||||
if "UNSUPPORTED" in pkg_arch[-1]:
|
||||
if "UNSUPPORTED" in self.pkg_arch[-1]:
|
||||
ARCH_COLOR = RED
|
||||
elif "UNTESTED" in pkg_arch[-1]:
|
||||
elif "UNTESTED" in self.pkg_arch[-1]:
|
||||
ARCH_COLOR = YELLOW
|
||||
print("\nThe following packages will be automatically installed "
|
||||
"or upgraded")
|
||||
print("\nThe following packages will be automatically "
|
||||
"installed or upgraded")
|
||||
print("with new version:\n")
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
||||
"| Package", " " * 30, "Version",
|
||||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
self._view_top()
|
||||
print("Installing:")
|
||||
sbo_packages_view(PKG_COLOR, name, sbo_ver[-1], ARCH_COLOR,
|
||||
pkg_arch[-1])
|
||||
self._view_packages(PKG_COLOR, self.name, self.sbo_ver[-1],
|
||||
ARCH_COLOR, self.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]):
|
||||
for dep, ver, dep_arch in zip(self.dependencies[:-1],
|
||||
self.sbo_ver[:-1],
|
||||
self.pkg_arch[:-1]):
|
||||
dep_pkg = ("{0}-{1}".format(dep, ver))
|
||||
if find_package(dep_pkg, pkg_path):
|
||||
DEP_COLOR = GREEN
|
||||
|
@ -135,182 +150,238 @@ def sbo_build(name):
|
|||
ARCH_COLOR = RED
|
||||
elif "UNTESTED" in dep_arch:
|
||||
ARCH_COLOR = YELLOW
|
||||
sbo_packages_view(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
|
||||
msg_upg = msg_ins = "package"
|
||||
if count_installed > 1:
|
||||
msg_ins = msg_ins + "s"
|
||||
if count_upgraded > 1:
|
||||
msg_upg = msg_upg + "s"
|
||||
self._view_packages(DEP_COLOR, dep, ver, ARCH_COLOR,
|
||||
dep_arch)
|
||||
msgs = self._msgs(self.dependencies, count_installed,
|
||||
count_upgraded)
|
||||
total_msg = msgs[0]
|
||||
msg_ins = msgs[1]
|
||||
msg_upg = msgs[2]
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2}.".format(GREY, len(dependencies), msg_ins))
|
||||
print("{0}Total {1} {2}.".format(GREY, len(self.dependencies),
|
||||
total_msg))
|
||||
print("{0} {1} will be installed, {2} allready installed and "
|
||||
"{3} {4}".format(count_installed, msg_ins, pkg_sum,
|
||||
"{3} {4}".format(count_installed, msg_ins, self.pkg_sum,
|
||||
count_upgraded, msg_upg))
|
||||
print("will be upgraded.{0}\n".format(ENDC))
|
||||
# Check if package supported or tested by arch
|
||||
# before proceed to install
|
||||
UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
if src in UNST:
|
||||
print("{0}The package {1}{2}\n".format(RED, src, ENDC))
|
||||
if self.src in UNST:
|
||||
print("{0}The package {1}{2}\n".format(RED, self.src, ENDC))
|
||||
read = ""
|
||||
# exit if all packages already installed
|
||||
elif pkg_sum == len(dependencies):
|
||||
elif self.pkg_sum == len(self.dependencies):
|
||||
read = ""
|
||||
else:
|
||||
read = raw_input("Do you want to continue [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
if not os.path.exists(build_path):
|
||||
os.mkdir(build_path)
|
||||
os.chdir(build_path)
|
||||
for pkg, ver, ar in zip(dependencies, sbo_ver, pkg_arch):
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
sbo_file = "".join(find_package(prgnam, pkg_path))
|
||||
if sbo_file:
|
||||
sbo_file_version = sbo_file[len(pkg) + 1:-len(ar) - 7]
|
||||
template(78)
|
||||
pkg_found(pkg, sbo_file_version)
|
||||
template(78)
|
||||
self._install(count_installed, count_upgraded, msg_ins, msg_upg)
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def _install(self, count_installed, count_upgraded, msg_ins, msg_upg):
|
||||
'''
|
||||
Build and install package with all dependencies
|
||||
'''
|
||||
if not os.path.exists(build_path):
|
||||
os.mkdir(build_path)
|
||||
os.chdir(build_path)
|
||||
try:
|
||||
for pkg, ver in zip(self.dependencies, self.sbo_ver):
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
sbo_file = "".join(find_package(prgnam, pkg_path))
|
||||
if sbo_file:
|
||||
sbo_file_version = split_package(sbo_file)[-3]
|
||||
template(78)
|
||||
pkg_found(pkg, sbo_file_version)
|
||||
template(78)
|
||||
else:
|
||||
grep = SBoGrep(pkg)
|
||||
sbo_url = sbo_search_pkg(pkg)
|
||||
sbo_link = sbo_slackbuild_dwn(sbo_url)
|
||||
src_link = grep.source().split()
|
||||
script = sbo_link.split("/")[-1]
|
||||
Download(build_path, sbo_link).start()
|
||||
sources = []
|
||||
for src in src_link:
|
||||
# get file from source
|
||||
sources.append(src.split("/")[-1])
|
||||
Download(build_path, src).start()
|
||||
build_package(script, sources, build_path)
|
||||
# Searches the package name and version in /tmp to
|
||||
# install. If find two or more packages e.g.
|
||||
# to build tag 2 or 3 will fit most.
|
||||
binary_list = []
|
||||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
binary_list.append(search)
|
||||
try:
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
except ValueError:
|
||||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
if find_package(pkg + sp, pkg_path):
|
||||
print("[ {0}Upgrading{1} ] --> {2}".format(
|
||||
YELLOW, ENDC, pkg))
|
||||
self.upgraded.append(pkg)
|
||||
else:
|
||||
sbo_url = sbo_search_pkg(pkg)
|
||||
sbo_link = sbo_slackbuild_dwn(sbo_url)
|
||||
src_link = SBoGrep(pkg).source().split()
|
||||
script = sbo_link.split("/")[-1]
|
||||
Download(build_path, sbo_link).start()
|
||||
sources = []
|
||||
for src in src_link:
|
||||
# get file from source
|
||||
sources.append(src.split("/")[-1])
|
||||
Download(build_path, src).start()
|
||||
build_package(script, sources, build_path)
|
||||
# Searches the package name and version in /tmp to
|
||||
# install. If find two or more packages e.g. to build
|
||||
# tag 2 or 3 will fit most.
|
||||
binary_list = []
|
||||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
binary_list.append(search)
|
||||
try:
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
except ValueError:
|
||||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
if find_package(pkg + sp, pkg_path):
|
||||
print("{0}[ Upgrading ] --> {1}{2}".format(
|
||||
GREEN, ENDC, pkg))
|
||||
upgraded.append(pkg)
|
||||
else:
|
||||
print("{0}[ Installing ] --> {1}{2}".format(
|
||||
GREEN, ENDC, pkg))
|
||||
PackageManager(binary).upgrade()
|
||||
installs.append(pkg)
|
||||
versions.append(ver)
|
||||
# Reference list with packages installed
|
||||
# and upgraded.
|
||||
if len(installs) > 1:
|
||||
template(78)
|
||||
print("| Total {0} {1} installed and {2} {3} "
|
||||
"upgraded".format(count_installed, msg_ins,
|
||||
count_upgraded, msg_upg))
|
||||
template(78)
|
||||
for pkg, ver in zip(installs, versions):
|
||||
installed = ("{0}-{1}".format(pkg, ver))
|
||||
if find_package(installed, pkg_path):
|
||||
if pkg in upgraded:
|
||||
print("| Package {0} upgraded "
|
||||
"successfully".format(installed))
|
||||
else:
|
||||
print("| Package {0} installed "
|
||||
"successfully".format(installed))
|
||||
else:
|
||||
print("| Package {0} NOT installed".format(
|
||||
installed))
|
||||
template(78)
|
||||
# Write dependencies in a log file
|
||||
# into directory `/var/log/slpkg/dep/`
|
||||
if find_package(name + sp, pkg_path):
|
||||
dep_path = log_path + "dep/"
|
||||
if not os.path.exists(dep_path):
|
||||
os.mkdir(dep_path)
|
||||
if os.path.isfile(dep_path + name):
|
||||
os.remove(dep_path + name)
|
||||
if len(dependencies) > 1:
|
||||
with open(dep_path + name, "w") as f:
|
||||
for dep in dependencies:
|
||||
f.write(dep + "\n")
|
||||
f.close()
|
||||
print("[ {0}Installing{1} ] --> {2}".format(
|
||||
GREEN, ENDC, pkg))
|
||||
PackageManager(binary).upgrade()
|
||||
self.installs.append(pkg)
|
||||
self.versions.append(ver)
|
||||
# Reference list with packages installed
|
||||
# and upgraded.
|
||||
if len(self.installs) > 1:
|
||||
self._reference(count_installed, count_upgraded,
|
||||
msg_ins, msg_upg)
|
||||
self._write_log(self.dependencies)
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def _matching(self):
|
||||
ins = uns = 0
|
||||
sbo_matching = []
|
||||
index, toolbar_width = 0, 3
|
||||
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
|
||||
"r") as SLACKBUILDS_TXT:
|
||||
for line in SLACKBUILDS_TXT:
|
||||
if line.startswith("SLACKBUILD NAME: "):
|
||||
sbo_name = line[17:].strip()
|
||||
if self.name in sbo_name:
|
||||
index += 1
|
||||
if index == toolbar_width:
|
||||
sys.stdout.write("{0}.{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
toolbar_width += 6
|
||||
sbo_matching.append(sbo_name)
|
||||
self.sbo_ver.append(SBoGrep(sbo_name).version())
|
||||
src = SBoGrep(sbo_name).source()
|
||||
self.pkg_arch.append(self._select_arch(src))
|
||||
SLACKBUILDS_TXT.close()
|
||||
sys.stdout.write(self.done)
|
||||
if sbo_matching:
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]"
|
||||
"\n".format(CYAN, self.name, ENDC))
|
||||
self._view_top()
|
||||
print("Matching:")
|
||||
ARCH_COLOR = ""
|
||||
for match, ver, march in zip(sbo_matching, self.sbo_ver,
|
||||
self.pkg_arch):
|
||||
if find_package(match + sp + ver, pkg_path):
|
||||
self._view_packages(GREEN, match, ver,
|
||||
ARCH_COLOR, march)
|
||||
ins += 1
|
||||
else:
|
||||
self._view_packages(RED, match, ver,
|
||||
ARCH_COLOR, march)
|
||||
uns += 1
|
||||
msgs = self._msgs(sbo_matching, ins, uns)
|
||||
total_msg = msgs[0]
|
||||
ins_msg = msgs[1]
|
||||
uns_msg = msgs[2]
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total found {1} matching {2}.".format(
|
||||
GREY, len(sbo_matching), total_msg))
|
||||
print("{0} installed {1} and {2} uninstalled {3}.{4}"
|
||||
"\n".format(ins, ins_msg, uns, uns_msg, ENDC))
|
||||
else:
|
||||
ins = uns = int()
|
||||
sbo_matching = []
|
||||
index, toolbar_width = int(), 3
|
||||
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
|
||||
"r") as SLACKBUILDS_TXT:
|
||||
for line in SLACKBUILDS_TXT:
|
||||
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(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
toolbar_width += 6
|
||||
sbo_matching.append(sbo_name)
|
||||
sbo_ver.append(SBoGrep(sbo_name).version())
|
||||
src = SBoGrep(sbo_name).source()
|
||||
pkg_arch.append(select_arch(src))
|
||||
SLACKBUILDS_TXT.close()
|
||||
sys.stdout.write(done)
|
||||
if sbo_matching:
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
CYAN, 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 = 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
|
||||
message = "No matching"
|
||||
pkg_not_found("\n", self.name, message, "\n")
|
||||
|
||||
def _msgs(self, packages, ins, uns):
|
||||
'''
|
||||
Count packages and print `packages` or
|
||||
`package`
|
||||
'''
|
||||
total_msg = ins_msg = uns_msg = "package"
|
||||
if len(packages) > 1:
|
||||
total_msg = total_msg + "s"
|
||||
if ins > 1:
|
||||
ins_msg = ins_msg + "s"
|
||||
if uns > 1:
|
||||
uns_msg = uns_msg + "s"
|
||||
return [total_msg, ins_msg, uns_msg]
|
||||
|
||||
def _view_top(self):
|
||||
'''
|
||||
View headers
|
||||
'''
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
||||
"| Package", " " * 30, "Version",
|
||||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
|
||||
def _view_packages(self, PKG_COLOR, package, version, ARCH_COLOR, arch):
|
||||
'''
|
||||
View packages list
|
||||
'''
|
||||
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"))
|
||||
|
||||
def _reference(self, count_installed, count_upgraded, msg_ins, msg_upg):
|
||||
'''
|
||||
Reference list with packages installed
|
||||
and upgraded.
|
||||
'''
|
||||
if len(self.installs) > 1:
|
||||
template(78)
|
||||
print("| Total {0} {1} installed and {2} {3} "
|
||||
"upgraded".format(count_installed, msg_ins,
|
||||
count_upgraded, msg_upg))
|
||||
template(78)
|
||||
for pkg, ver in zip(self.installs, self.versions):
|
||||
installed = ("{0}-{1}".format(pkg, ver))
|
||||
if find_package(installed, pkg_path):
|
||||
if pkg in self.upgraded:
|
||||
print("| Package {0} upgraded "
|
||||
"successfully".format(installed))
|
||||
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("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total found {1} matching {2}.".format(
|
||||
GREY, len(sbo_matching), total_msg))
|
||||
print("{0} installed {1} and {2} uninstalled {3}.{4}\n".format(
|
||||
ins, ins_msg, uns, uns_msg, ENDC))
|
||||
else:
|
||||
message = "No matching"
|
||||
pkg_not_found("\n", name, message, "\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
print("| Package {0} installed "
|
||||
"successfully".format(installed))
|
||||
else:
|
||||
print("| Package {0} NOT installed".format(installed))
|
||||
template(78)
|
||||
|
||||
def _write_log(self, dependencies):
|
||||
'''
|
||||
write dependencies in a log file
|
||||
into directory `/var/log/slpkg/dep/`
|
||||
'''
|
||||
if find_package(self.name + sp, pkg_path):
|
||||
dep_path = log_path + "dep/"
|
||||
if not os.path.exists(dep_path):
|
||||
os.mkdir(dep_path)
|
||||
if os.path.isfile(dep_path + self.name):
|
||||
os.remove(dep_path + self.name)
|
||||
if len(dependencies) > 1:
|
||||
with open(dep_path + self.name, "w") as f:
|
||||
for dep in dependencies:
|
||||
f.write(dep + "\n")
|
||||
f.close()
|
||||
|
||||
def select_arch(src):
|
||||
'''
|
||||
Looks if sources unsupported or untested
|
||||
from arch else select arch
|
||||
'''
|
||||
arch = os.uname()[4]
|
||||
support = [
|
||||
"UNSUPPORTED",
|
||||
"UNTESTED",
|
||||
]
|
||||
if arch.startswith("i") and arch.endswith("86"):
|
||||
arch = "i486"
|
||||
for item in support:
|
||||
if item in src:
|
||||
arch = item
|
||||
return arch
|
||||
def _select_arch(self, src):
|
||||
'''
|
||||
Looks if sources unsupported or untested
|
||||
from arch else select arch
|
||||
'''
|
||||
arch = os.uname()[4]
|
||||
support = [
|
||||
"UNSUPPORTED",
|
||||
"UNTESTED",
|
||||
]
|
||||
if arch.startswith("i") and arch.endswith("86"):
|
||||
arch = "i486"
|
||||
for item in support:
|
||||
if item in src:
|
||||
arch = item
|
||||
return arch
|
||||
|
|
|
@ -54,17 +54,18 @@ def sbo_network(name):
|
|||
initialization()
|
||||
sbo_url = sbo_search_pkg(name)
|
||||
if sbo_url:
|
||||
sbo_desc = SBoGrep(name).description()[len(name) + 2:-1]
|
||||
sbo_req = SBoGrep(name).requires()
|
||||
grep = SBoGrep(name)
|
||||
sbo_desc = grep.description()[len(name) + 2:-1]
|
||||
sbo_req = grep.requires()
|
||||
source_dwn = grep.source().split()
|
||||
sbo_dwn = sbo_slackbuild_dwn(sbo_url)
|
||||
source_dwn = SBoGrep(name).source().split()
|
||||
sys.stdout.write(done)
|
||||
view_sbo(name, sbo_url, sbo_desc, sbo_dwn.split("/")[-1],
|
||||
", ".join([src.split("/")[-1] for src in source_dwn]),
|
||||
sbo_req)
|
||||
# Check if package supported by arch
|
||||
# before proceed to install
|
||||
FAULT = str()
|
||||
FAULT = ""
|
||||
UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
if "".join(source_dwn) in UNST:
|
||||
FAULT = "".join(source_dwn)
|
||||
|
@ -110,7 +111,7 @@ def sbo_network(name):
|
|||
sys.exit()
|
||||
if not os.path.exists(build_path):
|
||||
os.mkdir(build_path)
|
||||
sbo_version = SBoGrep(name).version()
|
||||
sbo_version = grep.version()
|
||||
prgnam = ("{0}-{1}".format(name, sbo_version))
|
||||
if find_package(prgnam + sp, pkg_path) == []:
|
||||
sources = []
|
||||
|
@ -133,8 +134,8 @@ def sbo_network(name):
|
|||
except ValueError:
|
||||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
print("{0}[ Installing ] --> {1} {2}".format(GREEN, ENDC,
|
||||
name))
|
||||
print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC,
|
||||
name))
|
||||
PackageManager(binary).upgrade()
|
||||
break
|
||||
else:
|
||||
|
|
|
@ -28,6 +28,7 @@ import time
|
|||
from url_read import url_read
|
||||
from downloader import Download
|
||||
from blacklist import BlackList
|
||||
from splitting import split_package
|
||||
from messages import pkg_not_found, template
|
||||
from __metadata__ import slpkg_tmp, pkg_path
|
||||
from colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
|
||||
|
@ -36,7 +37,6 @@ from pkg.find import find_package
|
|||
from pkg.manager import PackageManager
|
||||
|
||||
from mirrors import mirrors
|
||||
from splitting import split_package
|
||||
|
||||
|
||||
def install(slack_pkg, version):
|
||||
|
@ -57,8 +57,8 @@ def install(slack_pkg, version):
|
|||
package_name,
|
||||
package_location
|
||||
] = ([] for i in range(9))
|
||||
arch = COLOR = str()
|
||||
pkg_sum = uni_sum = upg_sum = int()
|
||||
arch = COLOR = ""
|
||||
pkg_sum = uni_sum = upg_sum = 0
|
||||
# create directories if not exists
|
||||
tmp_path = slpkg_tmp + "packages/"
|
||||
if not os.path.exists(slpkg_tmp):
|
||||
|
@ -172,15 +172,15 @@ def install(slack_pkg, version):
|
|||
for install, name in zip(install_all, names):
|
||||
package = ((tmp_path + install).split())
|
||||
if os.path.isfile(pkg_path + install[:-4]):
|
||||
print("{0}[ reinstalling ] --> {1}{2}".format(
|
||||
print("[ {0}reinstalling{1} ] --> {2}".format(
|
||||
GREEN, ENDC, install))
|
||||
PackageManager(package).reinstall()
|
||||
elif find_package(name + "-", pkg_path):
|
||||
print("{0}[ upgrading ] --> {1}{2}".format(
|
||||
GREEN, ENDC, install))
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(
|
||||
YELLOW, ENDC, install))
|
||||
PackageManager(package).upgrade()
|
||||
else:
|
||||
print("{0}[ installing ] --> {1}{2}".format(
|
||||
print("[ {0}installing{1} ] --> {2}".format(
|
||||
GREEN, ENDC, install))
|
||||
PackageManager(package).upgrade()
|
||||
read = raw_input("Removal downloaded packages [Y/n]? ")
|
||||
|
|
|
@ -30,13 +30,13 @@ from url_read import url_read
|
|||
from messages import template
|
||||
from downloader import Download
|
||||
from blacklist import BlackList
|
||||
from splitting import split_package
|
||||
from colors import GREY, YELLOW, ENDC
|
||||
from __metadata__ import pkg_path, slpkg_tmp
|
||||
from colors import GREEN, GREY, YELLOW, ENDC
|
||||
|
||||
from pkg.manager import PackageManager
|
||||
|
||||
from mirrors import mirrors
|
||||
from splitting import split_package
|
||||
from slack_version import slack_ver
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ def patches(version):
|
|||
package_name,
|
||||
package_location
|
||||
] = ([] for i in range(8))
|
||||
slack_arch = str()
|
||||
slack_arch = ""
|
||||
patch_path = slpkg_tmp + "patches/"
|
||||
if not os.path.exists(slpkg_tmp):
|
||||
os.mkdir(slpkg_tmp)
|
||||
|
@ -178,7 +178,7 @@ def patches(version):
|
|||
Download(patch_path, dwn).start()
|
||||
Download(patch_path, dwn + ".asc").start()
|
||||
for pkg in upgrade_all:
|
||||
print("{0}[ upgrading ] --> {1}{2}".format(GREEN, ENDC,
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC,
|
||||
pkg[:-4]))
|
||||
PackageManager((patch_path + pkg).split()).upgrade()
|
||||
for kernel in upgrade_all:
|
||||
|
|
Loading…
Add table
Reference in a new issue