upgrade source

This commit is contained in:
Dimitris Zlatanidis 2014-10-18 07:12:51 +03:00
parent 3e9d5ebb34
commit b77b46999f
11 changed files with 318 additions and 255 deletions

View file

@ -28,11 +28,11 @@ from colors import RED, GREEN, ENDC
class BlackList(object): class BlackList(object):
''' '''
Blacklist class to add, remove or listed packages Blacklist class to add, remove or listed packages
in blacklist file. in blacklist file.
''' '''
def __init__(self): def __init__(self):
''' '''
Initialization blacklist file if not exist in /etc/slpkg Initialization blacklist file if not exist in /etc/slpkg

View file

@ -40,8 +40,8 @@ class Download(object):
Check if file already download the skip or continue Check if file already download the skip or continue
download if before stoped. download if before stoped.
''' '''
print("\n{0}[ Download ] -->{1} {2}\n".format(GREEN, ENDC, print("\n[ {0}Download{1} ] -->{1} {2}\n".format(GREEN, ENDC,
self.file_name)) self.file_name))
try: try:
subprocess.call("wget -c -N --directory-prefix={0} {1}".format( subprocess.call("wget -c -N --directory-prefix={0} {1}".format(
self.path, self.url), shell=True) self.path, self.url), shell=True)

View file

@ -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 sbo_network from sbo.views import sbo_network
from sbo.tracking import track_dep from sbo.tracking import track_dep
from sbo.slackbuild import sbo_build from sbo.slackbuild import SlackBuild
from slack.patches import patches from slack.patches import patches
from slack.install import install from slack.install import install
@ -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_build(args[2]) SlackBuild(args[2]).start()
elif args[1] == repository[1]: elif args[1] == repository[1]:
version = "stable" version = "stable"
install(args[2], version) install(args[2], version)

View file

@ -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( print(" {0}I{1}nstall Download/Build/Install".format(
RED, ENDC)) RED, ENDC))
print(" {0}Q{1}uit Quit\n".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"))

View file

@ -37,6 +37,7 @@ class PackageManager(object):
Package manager class for install, upgrade, Package manager class for install, upgrade,
reinstall, remove, find and display packages. reinstall, remove, find and display packages.
''' '''
def __init__(self, binary): def __init__(self, binary):
self.binary = binary self.binary = binary
@ -52,7 +53,7 @@ class PackageManager(object):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't install" message = "Can't install"
if len(self.binary) > 1: if len(self.binary) > 1:
bol = eol = str() bol = eol = ""
else: else:
bol = eol = "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
@ -69,7 +70,7 @@ class PackageManager(object):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't upgrade" message = "Can't upgrade"
if len(self.binary) > 1: if len(self.binary) > 1:
bol = eol = str() bol = eol = ""
else: else:
bol = eol = "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
@ -87,7 +88,7 @@ class PackageManager(object):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't reinstall" message = "Can't reinstall"
if len(self.binary) > 1: if len(self.binary) > 1:
bol = eol = str() bol = eol = ""
else: else:
bol = eol = "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
@ -108,7 +109,7 @@ class PackageManager(object):
for pkg in self.binary: for pkg in self.binary:
pkgs = find_package(pkg + sp, pkg_path) pkgs = find_package(pkg + sp, pkg_path)
if pkgs: if pkgs:
print("{0}[ delete ]{1} --> {2}".format(RED, ENDC, print("[ {0}delete{1} ] --> {2}".format(RED, ENDC,
"\n ".join(pkgs))) "\n ".join(pkgs)))
removed.append(pkg) removed.append(pkg)
@ -196,7 +197,7 @@ class PackageManager(object):
Find installed Slackware packages Find installed Slackware packages
''' '''
self.binary = "".join(self.binary) self.binary = "".join(self.binary)
matching = size = int() matching = size = 0
print("\nPackages with matching name [ {0}{1}{2} ]\n".format( print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
CYAN, self.binary, ENDC)) CYAN, self.binary, ENDC))
for match in find_package(self.binary, pkg_path): for match in find_package(self.binary, pkg_path):
@ -241,7 +242,7 @@ class PackageManager(object):
else: else:
message = "Can't dislpay" message = "Can't dislpay"
if len(self.binary) > 1: if len(self.binary) > 1:
bol = eol = str() bol = eol = ""
else: else:
bol = eol = "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)

View file

@ -40,6 +40,7 @@ class QueuePkgs(object):
Class to list, add or remove packages in queue, Class to list, add or remove packages in queue,
also build or install. also build or install.
''' '''
def __init__(self): def __init__(self):
queue_file = [ queue_file = [
"# In this file you can create a list of\n", "# In this file you can create a list of\n",

View file

@ -55,7 +55,7 @@ def sbo_check():
sys.stdout.write(reading_lists) sys.stdout.write(reading_lists)
sys.stdout.flush() sys.stdout.flush()
initialization() initialization()
index, toolbar_width = int(), 3 index, toolbar_width = 0, 3
[ [
dependencies, dependencies,
dependencies_list, dependencies_list,
@ -152,7 +152,7 @@ def sbo_check():
"Arch", " " * 9, "Repository")) "Arch", " " * 9, "Repository"))
template(78) template(78)
print("Upgrading:") 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): for upg, ver, arch in zip(pkg_for_upg, upg_ver, upg_arch):
if find_package(upg[:-len(ver)], pkg_path): if find_package(upg[:-len(ver)], pkg_path):
COLOR = YELLOW COLOR = YELLOW
@ -205,10 +205,10 @@ def sbo_check():
build_FAILED(sbo_url, prgnam) build_FAILED(sbo_url, prgnam)
sys.exit() sys.exit()
if find_package(name + sp, pkg_path): if find_package(name + sp, pkg_path):
print("{0}[ Upgrading ] --> {1}{2}".format( print("[ {0}Upgrading{1} ] --> {2}".format(
GREEN, ENDC, name)) YELLOW, ENDC, name))
else: else:
print("{0}[ Installing ] --> {1}{2}".format( print("[ {0}Installing{1} ] --> {2}".format(
GREEN, ENDC, name)) GREEN, ENDC, name))
# Use this list to pick out what # Use this list to pick out what
# packages will be installed # packages will be installed

View file

@ -26,12 +26,12 @@ import sys
from init import initialization from init import initialization
from downloader import Download from downloader import Download
from splitting import split_package
from __metadata__ import (tmp, pkg_path, build_path, from __metadata__ import (tmp, pkg_path, build_path,
log_path, lib_path, sp) log_path, lib_path, sp)
from colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC from colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC
from messages import (pkg_found, template, build_FAILED, 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.find import find_package
from pkg.build import build_package from pkg.build import build_package
@ -43,85 +43,100 @@ from download import sbo_slackbuild_dwn
from dependency import sbo_dependencies_pkg from dependency import sbo_dependencies_pkg
def sbo_build(name): class SlackBuild(object):
''' '''
Download, build and install or upgrade packages Download, build and install or upgrade packages
with all dependencies if version is greater than with all dependencies if version is greater than
that established. that established.
''' '''
done = "{0}Done{1}\n".format(GREY, ENDC) def __init__(self, name):
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC) self.name = name
sys.stdout.write(reading_lists) self.src = []
sys.stdout.flush() self.sbo_ver = []
initialization() self.pkg_arch = []
[ self.installs = []
sbo_ver, self.upgraded = []
pkg_arch, self.versions = []
installs, self.requires = []
upgraded, self.dependencies = []
versions, self.pkg_sum = 0
requires, self.done = "{0}Done{1}\n".format(GREY, ENDC)
dependencies self.reading_lists = "{0}Reading package lists ...{1}".format(GREY,
] = ([] for i in range(7)) ENDC)
PKG_COLOR = DEP_COLOR = ARCH_COLOR = str() initialization()
dependencies_list = sbo_dependencies_pkg(name)
try: def start(self):
if dependencies_list or sbo_search_pkg(name) is not None: '''
pkg_sum = count_upgraded = count_installed = int() 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 # Insert master package in list to
# install it after dependencies # install it after dependencies
requires.append(name) self.requires.append(self.name)
# Create one list for all packages # Create one list for all packages
for pkg in dependencies_list: for pkg in dependencies_list:
requires += pkg self.requires += pkg
requires.reverse() self.requires.reverse()
# Remove double dependencies # Remove double dependencies
for duplicate in requires: for duplicate in self.requires:
if duplicate not in dependencies: if duplicate not in self.dependencies:
dependencies.append(duplicate) self.dependencies.append(duplicate)
# Create two lists one for package version and one # Create two lists one for package version and one
# for package arch. # for package arch.
for pkg in dependencies: for pkg in self.dependencies:
version = SBoGrep(pkg).version() grep = SBoGrep(pkg)
sbo_ver.append(version) version = grep.version()
src = SBoGrep(pkg).source() self.sbo_ver.append(version)
pkg_arch.append(select_arch(src)) self.src = grep.source()
self.pkg_arch.append(self._select_arch(self.src))
sbo_pkg = ("{0}-{1}".format(pkg, version)) sbo_pkg = ("{0}-{1}".format(pkg, version))
if find_package(sbo_pkg, pkg_path): if find_package(sbo_pkg, pkg_path):
pkg_sum += 1 self.pkg_sum += 1
sys.stdout.write(done) 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, # Tag with color green if package already installed,
# color yellow for packages to upgrade and color red # color yellow for packages to upgrade and color red
# if not installed. Also if package arch is UNSUPPORTED # if not installed. Also if package arch is UNSUPPORTED
# tag with color red and if UNTESTED with color yellow. # 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): if find_package(master_pkg, pkg_path):
PKG_COLOR = GREEN PKG_COLOR = GREEN
elif find_package(name + sp, pkg_path): elif find_package(self.name + sp, pkg_path):
PKG_COLOR = YELLOW PKG_COLOR = YELLOW
count_upgraded += 1 count_upgraded += 1
else: else:
PKG_COLOR = RED PKG_COLOR = RED
count_installed += 1 count_installed += 1
if "UNSUPPORTED" in pkg_arch[-1]: if "UNSUPPORTED" in self.pkg_arch[-1]:
ARCH_COLOR = RED ARCH_COLOR = RED
elif "UNTESTED" in pkg_arch[-1]: elif "UNTESTED" in self.pkg_arch[-1]:
ARCH_COLOR = YELLOW ARCH_COLOR = YELLOW
print("\nThe following packages will be automatically installed " print("\nThe following packages will be automatically "
"or upgraded") "installed or upgraded")
print("with new version:\n") print("with new version:\n")
template(78) self._view_top()
print("{0}{1}{2}{3}{4}{5}{6}".format(
"| Package", " " * 30, "Version",
" " * 10, "Arch", " " * 9, "Repository"))
template(78)
print("Installing:") print("Installing:")
sbo_packages_view(PKG_COLOR, name, sbo_ver[-1], ARCH_COLOR, self._view_packages(PKG_COLOR, self.name, self.sbo_ver[-1],
pkg_arch[-1]) ARCH_COLOR, self.pkg_arch[-1])
print("Installing for dependencies:") print("Installing for dependencies:")
ARCH_COLOR = "" # reset arch color for dependencies packages ARCH_COLOR = "" # reset arch color for dependencies packages
for dep, ver, dep_arch in zip(dependencies[:-1], sbo_ver[:-1], for dep, ver, dep_arch in zip(self.dependencies[:-1],
pkg_arch[:-1]): self.sbo_ver[:-1],
self.pkg_arch[:-1]):
dep_pkg = ("{0}-{1}".format(dep, ver)) dep_pkg = ("{0}-{1}".format(dep, ver))
if find_package(dep_pkg, pkg_path): if find_package(dep_pkg, pkg_path):
DEP_COLOR = GREEN DEP_COLOR = GREEN
@ -135,182 +150,238 @@ def sbo_build(name):
ARCH_COLOR = RED ARCH_COLOR = RED
elif "UNTESTED" in dep_arch: elif "UNTESTED" in dep_arch:
ARCH_COLOR = YELLOW ARCH_COLOR = YELLOW
sbo_packages_view(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch) self._view_packages(DEP_COLOR, dep, ver, ARCH_COLOR,
msg_upg = msg_ins = "package" dep_arch)
if count_installed > 1: msgs = self._msgs(self.dependencies, count_installed,
msg_ins = msg_ins + "s" count_upgraded)
if count_upgraded > 1: total_msg = msgs[0]
msg_upg = msg_upg + "s" msg_ins = msgs[1]
msg_upg = msgs[2]
print("\nInstalling summary") print("\nInstalling summary")
print("=" * 79) 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 " 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)) count_upgraded, msg_upg))
print("will be upgraded.{0}\n".format(ENDC)) print("will be upgraded.{0}\n".format(ENDC))
# Check if package supported or tested by arch # Check if package supported or tested by arch
# before proceed to install # before proceed to install
UNST = ["UNSUPPORTED", "UNTESTED"] UNST = ["UNSUPPORTED", "UNTESTED"]
if src in UNST: if self.src in UNST:
print("{0}The package {1}{2}\n".format(RED, src, ENDC)) print("{0}The package {1}{2}\n".format(RED, self.src, ENDC))
read = "" read = ""
# exit if all packages already installed # exit if all packages already installed
elif pkg_sum == len(dependencies): elif self.pkg_sum == len(self.dependencies):
read = "" read = ""
else: else:
read = raw_input("Do you want to continue [Y/n]? ") read = raw_input("Do you want to continue [Y/n]? ")
if read == "Y" or read == "y": if read == "Y" or read == "y":
if not os.path.exists(build_path): self._install(count_installed, count_upgraded, msg_ins, msg_upg)
os.mkdir(build_path) except KeyboardInterrupt:
os.chdir(build_path) print # new line at exit
for pkg, ver, ar in zip(dependencies, sbo_ver, pkg_arch): sys.exit()
prgnam = ("{0}-{1}".format(pkg, ver))
sbo_file = "".join(find_package(prgnam, pkg_path)) def _install(self, count_installed, count_upgraded, msg_ins, msg_upg):
if sbo_file: '''
sbo_file_version = sbo_file[len(pkg) + 1:-len(ar) - 7] Build and install package with all dependencies
template(78) '''
pkg_found(pkg, sbo_file_version) if not os.path.exists(build_path):
template(78) 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: else:
sbo_url = sbo_search_pkg(pkg) print("[ {0}Installing{1} ] --> {2}".format(
sbo_link = sbo_slackbuild_dwn(sbo_url) GREEN, ENDC, pkg))
src_link = SBoGrep(pkg).source().split() PackageManager(binary).upgrade()
script = sbo_link.split("/")[-1] self.installs.append(pkg)
Download(build_path, sbo_link).start() self.versions.append(ver)
sources = [] # Reference list with packages installed
for src in src_link: # and upgraded.
# get file from source if len(self.installs) > 1:
sources.append(src.split("/")[-1]) self._reference(count_installed, count_upgraded,
Download(build_path, src).start() msg_ins, msg_upg)
build_package(script, sources, build_path) self._write_log(self.dependencies)
# Searches the package name and version in /tmp to except KeyboardInterrupt:
# install. If find two or more packages e.g. to build print # new line at exit
# tag 2 or 3 will fit most. sys.exit()
binary_list = []
for search in find_package(prgnam, tmp): def _matching(self):
if "_SBo" in search: ins = uns = 0
binary_list.append(search) sbo_matching = []
try: index, toolbar_width = 0, 3
binary = (tmp + max(binary_list)).split() with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
except ValueError: "r") as SLACKBUILDS_TXT:
build_FAILED(sbo_url, prgnam) for line in SLACKBUILDS_TXT:
sys.exit() if line.startswith("SLACKBUILD NAME: "):
if find_package(pkg + sp, pkg_path): sbo_name = line[17:].strip()
print("{0}[ Upgrading ] --> {1}{2}".format( if self.name in sbo_name:
GREEN, ENDC, pkg)) index += 1
upgraded.append(pkg) if index == toolbar_width:
else: sys.stdout.write("{0}.{1}".format(GREY, ENDC))
print("{0}[ Installing ] --> {1}{2}".format( sys.stdout.flush()
GREEN, ENDC, pkg)) toolbar_width += 6
PackageManager(binary).upgrade() sbo_matching.append(sbo_name)
installs.append(pkg) self.sbo_ver.append(SBoGrep(sbo_name).version())
versions.append(ver) src = SBoGrep(sbo_name).source()
# Reference list with packages installed self.pkg_arch.append(self._select_arch(src))
# and upgraded. SLACKBUILDS_TXT.close()
if len(installs) > 1: sys.stdout.write(self.done)
template(78) if sbo_matching:
print("| Total {0} {1} installed and {2} {3} " print("\nPackages with name matching [ {0}{1}{2} ]"
"upgraded".format(count_installed, msg_ins, "\n".format(CYAN, self.name, ENDC))
count_upgraded, msg_upg)) self._view_top()
template(78) print("Matching:")
for pkg, ver in zip(installs, versions): ARCH_COLOR = ""
installed = ("{0}-{1}".format(pkg, ver)) for match, ver, march in zip(sbo_matching, self.sbo_ver,
if find_package(installed, pkg_path): self.pkg_arch):
if pkg in upgraded: if find_package(match + sp + ver, pkg_path):
print("| Package {0} upgraded " self._view_packages(GREEN, match, ver,
"successfully".format(installed)) ARCH_COLOR, march)
else: ins += 1
print("| Package {0} installed " else:
"successfully".format(installed)) self._view_packages(RED, match, ver,
else: ARCH_COLOR, march)
print("| Package {0} NOT installed".format( uns += 1
installed)) msgs = self._msgs(sbo_matching, ins, uns)
template(78) total_msg = msgs[0]
# Write dependencies in a log file ins_msg = msgs[1]
# into directory `/var/log/slpkg/dep/` uns_msg = msgs[2]
if find_package(name + sp, pkg_path): print("\nInstalling summary")
dep_path = log_path + "dep/" print("=" * 79)
if not os.path.exists(dep_path): print("{0}Total found {1} matching {2}.".format(
os.mkdir(dep_path) GREY, len(sbo_matching), total_msg))
if os.path.isfile(dep_path + name): print("{0} installed {1} and {2} uninstalled {3}.{4}"
os.remove(dep_path + name) "\n".format(ins, ins_msg, uns, uns_msg, ENDC))
if len(dependencies) > 1:
with open(dep_path + name, "w") as f:
for dep in dependencies:
f.write(dep + "\n")
f.close()
else: else:
ins = uns = int() message = "No matching"
sbo_matching = [] pkg_not_found("\n", self.name, message, "\n")
index, toolbar_width = int(), 3
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", def _msgs(self, packages, ins, uns):
"r") as SLACKBUILDS_TXT: '''
for line in SLACKBUILDS_TXT: Count packages and print `packages` or
if line.startswith("SLACKBUILD NAME: "): `package`
sbo_name = line[17:].strip() '''
if name in sbo_name: total_msg = ins_msg = uns_msg = "package"
index += 1 if len(packages) > 1:
if index == toolbar_width: total_msg = total_msg + "s"
sys.stdout.write("{0}.{1}".format(GREY, ENDC)) if ins > 1:
sys.stdout.flush() ins_msg = ins_msg + "s"
toolbar_width += 6 if uns > 1:
sbo_matching.append(sbo_name) uns_msg = uns_msg + "s"
sbo_ver.append(SBoGrep(sbo_name).version()) return [total_msg, ins_msg, uns_msg]
src = SBoGrep(sbo_name).source()
pkg_arch.append(select_arch(src)) def _view_top(self):
SLACKBUILDS_TXT.close() '''
sys.stdout.write(done) View headers
if sbo_matching: '''
print("\nPackages with name matching [ {0}{1}{2} ]\n".format( template(78)
CYAN, name, ENDC)) print("{0}{1}{2}{3}{4}{5}{6}".format(
template(78) "| Package", " " * 30, "Version",
print("{0}{1}{2}{3}{4}{5}{6}".format( " " * 10, "Arch", " " * 9, "Repository"))
"| Package", " " * 30, "Version", template(78)
" " * 10, "Arch", " " * 9, "Repository"))
template(78) def _view_packages(self, PKG_COLOR, package, version, ARCH_COLOR, arch):
print("Matching:") '''
ARCH_COLOR = str() View packages list
for match, ver, march in zip(sbo_matching, sbo_ver, pkg_arch): '''
if find_package(match + sp + ver, pkg_path): print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
sbo_packages_view(GREEN, match, ver, ARCH_COLOR, march) PKG_COLOR, package, ENDC,
ins += 1 " " * (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: else:
sbo_packages_view(RED, match, ver, ARCH_COLOR, march) print("| Package {0} installed "
uns += 1 "successfully".format(installed))
total_msg = ins_msg = uns_msg = "package" else:
if len(sbo_matching) > 1: print("| Package {0} NOT installed".format(installed))
total_msg = total_msg + "s" template(78)
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()
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): def _select_arch(self, src):
''' '''
Looks if sources unsupported or untested Looks if sources unsupported or untested
from arch else select arch from arch else select arch
''' '''
arch = os.uname()[4] arch = os.uname()[4]
support = [ support = [
"UNSUPPORTED", "UNSUPPORTED",
"UNTESTED", "UNTESTED",
] ]
if arch.startswith("i") and arch.endswith("86"): if arch.startswith("i") and arch.endswith("86"):
arch = "i486" arch = "i486"
for item in support: for item in support:
if item in src: if item in src:
arch = item arch = item
return arch return arch

View file

@ -54,17 +54,18 @@ def sbo_network(name):
initialization() initialization()
sbo_url = sbo_search_pkg(name) sbo_url = sbo_search_pkg(name)
if sbo_url: if sbo_url:
sbo_desc = SBoGrep(name).description()[len(name) + 2:-1] grep = SBoGrep(name)
sbo_req = SBoGrep(name).requires() sbo_desc = grep.description()[len(name) + 2:-1]
sbo_req = grep.requires()
source_dwn = grep.source().split()
sbo_dwn = sbo_slackbuild_dwn(sbo_url) sbo_dwn = sbo_slackbuild_dwn(sbo_url)
source_dwn = SBoGrep(name).source().split()
sys.stdout.write(done) sys.stdout.write(done)
view_sbo(name, sbo_url, sbo_desc, sbo_dwn.split("/")[-1], view_sbo(name, sbo_url, sbo_desc, sbo_dwn.split("/")[-1],
", ".join([src.split("/")[-1] for src in source_dwn]), ", ".join([src.split("/")[-1] for src in source_dwn]),
sbo_req) sbo_req)
# Check if package supported by arch # Check if package supported by arch
# before proceed to install # before proceed to install
FAULT = str() FAULT = ""
UNST = ["UNSUPPORTED", "UNTESTED"] UNST = ["UNSUPPORTED", "UNTESTED"]
if "".join(source_dwn) in UNST: if "".join(source_dwn) in UNST:
FAULT = "".join(source_dwn) FAULT = "".join(source_dwn)
@ -110,7 +111,7 @@ def sbo_network(name):
sys.exit() sys.exit()
if not os.path.exists(build_path): if not os.path.exists(build_path):
os.mkdir(build_path) os.mkdir(build_path)
sbo_version = SBoGrep(name).version() sbo_version = grep.version()
prgnam = ("{0}-{1}".format(name, sbo_version)) prgnam = ("{0}-{1}".format(name, sbo_version))
if find_package(prgnam + sp, pkg_path) == []: if find_package(prgnam + sp, pkg_path) == []:
sources = [] sources = []
@ -133,8 +134,8 @@ def sbo_network(name):
except ValueError: except ValueError:
build_FAILED(sbo_url, prgnam) build_FAILED(sbo_url, prgnam)
sys.exit() sys.exit()
print("{0}[ Installing ] --> {1} {2}".format(GREEN, ENDC, print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC,
name)) name))
PackageManager(binary).upgrade() PackageManager(binary).upgrade()
break break
else: else:

View file

@ -28,6 +28,7 @@ import time
from url_read import url_read from url_read import url_read
from downloader import Download from downloader import Download
from blacklist import BlackList from blacklist import BlackList
from splitting import split_package
from messages import pkg_not_found, template from messages import pkg_not_found, template
from __metadata__ import slpkg_tmp, pkg_path from __metadata__ import slpkg_tmp, pkg_path
from colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC 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 pkg.manager import PackageManager
from mirrors import mirrors from mirrors import mirrors
from splitting import split_package
def install(slack_pkg, version): def install(slack_pkg, version):
@ -57,8 +57,8 @@ def install(slack_pkg, version):
package_name, package_name,
package_location package_location
] = ([] for i in range(9)) ] = ([] for i in range(9))
arch = COLOR = str() arch = COLOR = ""
pkg_sum = uni_sum = upg_sum = int() pkg_sum = uni_sum = upg_sum = 0
# create directories if not exists # create directories if not exists
tmp_path = slpkg_tmp + "packages/" tmp_path = slpkg_tmp + "packages/"
if not os.path.exists(slpkg_tmp): if not os.path.exists(slpkg_tmp):
@ -172,15 +172,15 @@ def install(slack_pkg, version):
for install, name in zip(install_all, names): for install, name in zip(install_all, names):
package = ((tmp_path + install).split()) package = ((tmp_path + install).split())
if os.path.isfile(pkg_path + install[:-4]): if os.path.isfile(pkg_path + install[:-4]):
print("{0}[ reinstalling ] --> {1}{2}".format( print("[ {0}reinstalling{1} ] --> {2}".format(
GREEN, ENDC, install)) GREEN, ENDC, install))
PackageManager(package).reinstall() PackageManager(package).reinstall()
elif find_package(name + "-", pkg_path): elif find_package(name + "-", pkg_path):
print("{0}[ upgrading ] --> {1}{2}".format( print("[ {0}upgrading{1} ] --> {2}".format(
GREEN, ENDC, install)) YELLOW, ENDC, install))
PackageManager(package).upgrade() PackageManager(package).upgrade()
else: else:
print("{0}[ installing ] --> {1}{2}".format( print("[ {0}installing{1} ] --> {2}".format(
GREEN, ENDC, install)) GREEN, ENDC, install))
PackageManager(package).upgrade() PackageManager(package).upgrade()
read = raw_input("Removal downloaded packages [Y/n]? ") read = raw_input("Removal downloaded packages [Y/n]? ")

View file

@ -30,13 +30,13 @@ from url_read import url_read
from messages import template from messages import template
from downloader import Download from downloader import Download
from blacklist import BlackList from blacklist import BlackList
from splitting import split_package
from colors import GREY, YELLOW, ENDC
from __metadata__ import pkg_path, slpkg_tmp from __metadata__ import pkg_path, slpkg_tmp
from colors import GREEN, GREY, YELLOW, ENDC
from pkg.manager import PackageManager from pkg.manager import PackageManager
from mirrors import mirrors from mirrors import mirrors
from splitting import split_package
from slack_version import slack_ver from slack_version import slack_ver
@ -57,7 +57,7 @@ def patches(version):
package_name, package_name,
package_location package_location
] = ([] for i in range(8)) ] = ([] for i in range(8))
slack_arch = str() slack_arch = ""
patch_path = slpkg_tmp + "patches/" patch_path = slpkg_tmp + "patches/"
if not os.path.exists(slpkg_tmp): if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp) os.mkdir(slpkg_tmp)
@ -178,7 +178,7 @@ def patches(version):
Download(patch_path, dwn).start() Download(patch_path, dwn).start()
Download(patch_path, dwn + ".asc").start() Download(patch_path, dwn + ".asc").start()
for pkg in upgrade_all: for pkg in upgrade_all:
print("{0}[ upgrading ] --> {1}{2}".format(GREEN, ENDC, print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC,
pkg[:-4])) pkg[:-4]))
PackageManager((patch_path + pkg).split()).upgrade() PackageManager((patch_path + pkg).split()).upgrade()
for kernel in upgrade_all: for kernel in upgrade_all: