Update metadata import

This commit is contained in:
Dimitris Zlatanidis 2015-06-08 06:28:49 +03:00
parent 5538e7b93d
commit 620e0b2e69
22 changed files with 265 additions and 231 deletions

View file

@ -29,7 +29,7 @@ from slpkg.messages import Msg
from slpkg.toolbar import status
from slpkg.blacklist import BlackList
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
@ -76,4 +76,4 @@ def installed():
"""
Return all installed packages
"""
return find_package("", _m.pkg_path)
return find_package("", _meta_.pkg_path)

View file

@ -27,7 +27,7 @@ import sys
from slpkg.utils import Utils
from slpkg.toolbar import status
from slpkg.blacklist import BlackList
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from greps import Requires
@ -38,12 +38,13 @@ class Dependencies(object):
self.repo = repo
self.dep_results = []
self.packages = Utils().package_name(PACKAGES_TXT, repo)
self.meta = _meta_
def binary(self, name, resolve):
"""
Build all dependencies of a package
"""
if _m.rsl_deps in ["on", "ON"] and resolve:
if self.meta.rsl_deps in ["on", "ON"] and resolve:
try:
sys.setrecursionlimit(10000)
dependencies = []

View file

@ -27,7 +27,7 @@ import os
from slpkg.utils import Utils
from slpkg.toolbar import status
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.slack.slack_version import slack_ver
@ -40,7 +40,7 @@ def repo_data(PACKAGES_TXT, step, repo, resolve):
rname, rlocation, rsize, runsize) = ([] for i in range(8))
index, toolbar_width = 0, 100
for line in PACKAGES_TXT.splitlines():
if _m.rsl_deps in ["on", "ON"] and resolve:
if _meta_.rsl_deps in ["on", "ON"] and resolve:
index += 1
toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME:"):
@ -106,7 +106,7 @@ def alien_filter(name, location, size, unsize):
Filter Alien"s repository data
"""
ver = slack_ver()
if _m.slack_rel == "current":
if _meta_.slack_rel == "current":
ver = "current"
path_pkg = "pkg"
if os.uname()[4] == "x86_64":
@ -126,14 +126,15 @@ def ktown_filter(name, location, size, unsize):
Filter Alien"s ktown repository data
"""
ver = slack_ver()
if _m.slack_rel == "current":
if _meta_.slack_rel == "current":
ver = "current"
path_pkg = "x86"
if os.uname()[4] == "x86_64":
path_pkg = os.uname()[4]
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
if path_pkg in l and _m.ktown_kde_repo[1:-1] in l and l.startswith(ver):
if (path_pkg in l and _meta_.ktown_kde_repo[1:-1] in l and
l.startswith(ver)):
fname.append(n)
flocation.append(l)
fsize.append(s)
@ -146,7 +147,7 @@ def multi_filter(name, location, size, unsize):
Filter Alien"s multilib repository data
"""
ver = slack_ver()
if _m.slack_rel == "current":
if _meta_.slack_rel == "current":
ver = "current"
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
@ -165,7 +166,8 @@ def fix_slackers_pkg(name):
name in PACKAGES.TXT file use FILELIST.TXT to
get.
"""
FILELIST_TXT = Utils().read_file(_m.lib_path + "slackr_repo/FILELIST.TXT")
FILELIST_TXT = Utils().read_file(
_meta_.lib_path + "slackr_repo/FILELIST.TXT")
for line in FILELIST_TXT.splitlines():
if name in line and line.endswith(".txz"):
return line.split("/")[-1].strip()
@ -202,7 +204,7 @@ class Requires(object):
return ""
else:
PACKAGES_TXT = Utils().read_file("{0}{1}_repo/PACKAGES.TXT".format(
_m.lib_path, self.repo))
_meta_.lib_path, self.repo))
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"):
if self.repo == "slackr":

View file

@ -35,7 +35,7 @@ from slpkg.downloader import Download
from slpkg.log_deps import write_deps
from slpkg.grep_md5 import pkg_checksum
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import PackageManager
@ -54,8 +54,9 @@ class BinaryInstall(object):
self.packages = packages
self.repo = repo
self.resolve = resolve
self.version = _m.slack_rel
self.tmp_path = _m.slpkg_tmp_packages
self.meta = _meta_
self.version = self.meta.slack_rel
self.tmp_path = self.meta.slpkg_tmp_packages
self.dwn, self.dep_dwn = [], []
self.install, self.dep_install = [], []
self.comp_sum, self.dep_comp_sum = [], []
@ -83,7 +84,7 @@ class BinaryInstall(object):
self.packages = self.clear_masters()
(self.dwn, self.install, self.comp_sum,
self.uncomp_sum) = self.store(self.packages)
if _m.rsl_deps in ["on", "ON"] and self.resolve:
if self.meta.rsl_deps in ["on", "ON"] and self.resolve:
Msg().done()
if self.install:
print("\nThe following packages will be automatically "
@ -102,7 +103,8 @@ class BinaryInstall(object):
self.uncomp_sum + self.dep_uncomp_sum)
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2}.".format(_m.color["GREY"], sum(sums),
print("{0}Total {1} {2}.".format(self.meta.color["GREY"],
sum(sums),
Msg().pkg(sum(sums))))
print("{0} {1} will be installed, {2} will be upgraded and "
"{3} will be reinstalled.".format(sums[2],
@ -112,7 +114,7 @@ class BinaryInstall(object):
unit[0]))
print("After this process, {0} {1} of additional disk "
"space will be used.{2}".format(size[1], unit[1],
_m.color["ENDC"]))
self.meta.color["ENDC"]))
print("")
if Msg().answer() in ["y", "Y"]:
self.install.reverse()
@ -167,22 +169,20 @@ class BinaryInstall(object):
pkg_ver = "{0}-{1}".format(split_package(inst)[0],
split_package(inst)[1])
self.checksums(inst)
if os.path.isfile(_m.pkg_path + inst[:-4]):
print("[ {0}reinstalling{1} ] --> {2}".format(_m.color["GREEN"],
_m.color["ENDC"],
inst))
if os.path.isfile(self.meta.pkg_path + inst[:-4]):
print("[ {0}reinstalling{1} ] --> {2}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
installs.append(pkg_ver)
PackageManager(package).reinstall()
elif find_package(split_package(inst)[0] + "-", _m.pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format(_m.color["YELLOW"],
_m.color["ENDC"],
inst))
elif find_package(split_package(inst)[0] + self.meta.sp,
self.meta.pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format(
self.meta.color["YELLOW"], self.meta.color["ENDC"], inst))
upgraded.append(pkg_ver)
PackageManager(package).upgrade()
else:
print("[ {0}installing{1} ] --> {2}".format(_m.color["GREEN"],
_m.color["ENDC"],
inst))
print("[ {0}installing{1} ] --> {2}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
installs.append(pkg_ver)
PackageManager(package).upgrade()
return [installs, upgraded]
@ -205,11 +205,11 @@ class BinaryInstall(object):
Return package dependencies
"""
requires = []
if _m.rsl_deps in ["on", "ON"] and self.resolve:
if self.meta.rsl_deps in ["on", "ON"] and self.resolve:
Msg().resolving()
for dep in self.packages:
if self.if_upgrade:
dep = dep.split("-")[0]
dep = dep.split(self.meta.sp)[0]
dependencies = []
dependencies = Utils().dimensional_list(Dependencies(
self.PACKAGES_TXT, self.repo).binary(dep, self.resolve))
@ -226,17 +226,17 @@ class BinaryInstall(object):
repo = self.repo + (" " * (6 - (len(self.repo))))
for pkg, comp in zip(install, comp_sum):
pkg_split = split_package(pkg[:-4])
if find_package(pkg[:-4], _m.pkg_path):
if find_package(pkg[:-4], self.meta.pkg_path):
pkg_sum += 1
COLOR = _m.color["GREEN"]
elif find_package(pkg_split[0] + "-", _m.pkg_path):
COLOR = _m.color["YELLOW"]
COLOR = self.meta.color["GREEN"]
elif find_package(pkg_split[0] + self.meta.sp, self.meta.pkg_path):
COLOR = self.meta.color["YELLOW"]
upg_sum += 1
else:
COLOR = _m.color["RED"]
COLOR = self.meta.color["RED"]
uni_sum += 1
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
COLOR, pkg_split[0], _m.color["ENDC"],
COLOR, pkg_split[0], self.meta.color["ENDC"],
" " * (24-len(pkg_split[0])), pkg_split[1],
" " * (18-len(pkg_split[1])), pkg_split[2],
" " * (8-len(pkg_split[2])), pkg_split[3],

View file

@ -26,7 +26,7 @@ import os
from slpkg.utils import Utils
from slpkg.repositories import Repo
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver
@ -39,14 +39,16 @@ class RepoInit(object):
def __init__(self, repo):
self.repo = repo
self.meta = _meta_
self.mirror = ""
def fetch(self):
if self.repo in _m.default_repositories:
if self.repo in self.meta.default_repositories:
exec("self._init_{0}()".format(self.repo))
else:
exec("self._init_custom()")
self.lib = _m.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo)
self.lib = self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(
self.repo)
PACKAGES_TXT = Utils().read_file(self.lib)
return PACKAGES_TXT, self.mirror
@ -98,7 +100,7 @@ class RepoInit(object):
elif os.uname()[4] == "arm":
arch = "arm"
self.mirror = "{0}slacke{1}/slackware{2}-{3}/".format(
Repo().slacke(), _m.slacke_sub_repo[1:-1], arch, slack_ver())
Repo().slacke(), self.meta.slacke_sub_repo[1:-1], arch, slack_ver())
def _init_salix(self):
arch = "i486"

View file

@ -28,7 +28,7 @@ from slpkg.utils import Utils
from slpkg.toolbar import status
from slpkg.blacklist import BlackList
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
def search_pkg(name, repo):
@ -38,7 +38,7 @@ def search_pkg(name, repo):
"""
try:
blacklist = BlackList().packages()
PACKAGES_TXT = Utils().read_file(_m.lib_path + "{0}_repo/"
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
num_lines = sum(1 for line in PACKAGES_TXT)
toolbar_width, index, step = 2, 0, num_lines

View file

@ -32,6 +32,7 @@ class BlackList(object):
in blacklist file.
"""
def __init__(self):
self.meta = _meta_
self.quit = False
self.blackfile = "/etc/slpkg/blacklist"
self.black_conf = Utils().read_file(self.blackfile)
@ -55,8 +56,8 @@ class BlackList(object):
print("\nPackages in blacklist:\n")
for black in self.packages():
if black:
print("{0}{1}{2}".format(_meta_.color["GREEN"], black,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["GREEN"], black,
self.meta.color["ENDC"]))
self.quit = True
if self.quit:
print("") # new line at exit
@ -71,8 +72,8 @@ class BlackList(object):
with open(self.blackfile, "a") as black_conf:
for pkg in pkgs:
if pkg not in blacklist:
print("{0}{1}{2}".format(_meta_.color["GREEN"], pkg,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"]))
black_conf.write(pkg + "\n")
self.quit = True
black_conf.close()
@ -89,8 +90,8 @@ class BlackList(object):
if line not in pkgs:
remove.write(line + "\n")
else:
print("{0}{1}{2}".format(_meta_.color["RED"], line,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["RED"], line,
self.meta.color["ENDC"]))
self.quit = True
remove.close()
if self.quit:

View file

@ -32,6 +32,7 @@ class Config(object):
def __init__(self):
self.config_file = "/etc/slpkg/slpkg.conf"
self.meta = _meta_
def view(self):
"""
@ -63,8 +64,8 @@ class Config(object):
if not line.startswith("#") and line.split("=")[0] in conf_args:
print(line)
else:
print("{0}{1}{2}".format(_meta_.color["CYAN"], line,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["CYAN"], line,
self.meta.color["ENDC"]))
print("") # new line at end
def edit(self, editor):

View file

@ -33,22 +33,23 @@ class PkgDesc(object):
self.name = name
self.repo = repo
self.paint = paint
self.meta = _meta_
self.COLOR = ""
self.lib = ""
color_text = {
"red": _meta_.color["RED"],
"green": _meta_.color["GREEN"],
"yellow": _meta_.color["YELLOW"],
"cyan": _meta_.color["CYAN"],
"grey": _meta_.color["GREY"],
"red": self.meta.color["RED"],
"green": self.meta.color["GREEN"],
"yellow": self.meta.color["YELLOW"],
"cyan": self.meta.color["CYAN"],
"grey": self.meta.color["GREY"],
"": ""
}
self.COLOR = color_text[self.paint]
if self.repo in _meta_.repositories and self.repo != "sbo":
self.lib = _meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(
if self.repo in self.meta.repositories and self.repo != "sbo":
self.lib = self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(
self.repo)
else:
self.lib = _meta_.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
self.lib = self.meta.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
self.repo)
def view(self):
@ -59,7 +60,7 @@ class PkgDesc(object):
for line in PACKAGES_TXT.splitlines():
if line.startswith(self.name + ":"):
print(self.COLOR + line[len(self.name) + 1:] +
_meta_.color["ENDC"])
self.meta.color["ENDC"])
count += 1
if count == 11:
break
@ -68,7 +69,7 @@ class PkgDesc(object):
if (line.startswith(
"SLACKBUILD SHORT DESCRIPTION: " + self.name + " (")):
count += 1
print(self.COLOR + line[31:] + _meta_.color["ENDC"])
print(self.COLOR + line[31:] + self.meta.color["ENDC"])
if count == 0:
Msg().pkg_not_found("", self.name, "No matching", "\n")
else:

View file

@ -35,7 +35,8 @@ class Download(object):
def __init__(self, path, url):
self.path = path
self.url = url
self.wget_options = _meta_.wget_options
self.meta = _meta_
self.wget_options = self.meta.wget_options
def start(self):
"""
@ -45,8 +46,8 @@ class Download(object):
for dwn in self.url:
self.file_name = dwn.split("/")[-1]
print("\n[{0}/{1}][ {2}Download{3} ] --> {4}\n".format(
dwn_count, len(self.url), _meta_.color["GREEN"],
_meta_.color["ENDC"],
dwn_count, len(self.url), self.meta.color["GREEN"],
self.meta.color["ENDC"],
self.file_name))
try:
subprocess.call("wget {0} --directory-prefix={1} {2}".format(
@ -62,7 +63,8 @@ class Download(object):
print("")
Msg().template(78)
print("| Download '{0}' file {1}[ FAILED ]{2}".format(
self.file_name, _meta_.color["RED"], _meta_.color["ENDC"]))
self.file_name, self.meta.color["RED"],
self.meta.color["ENDC"]))
Msg().template(78)
print("")
if not Msg().answer() in ["y", "Y"]:

View file

@ -38,13 +38,14 @@ from slack.slack_version import slack_ver
class Initialization(object):
def __init__(self):
self.conf_path = _meta_.conf_path
self.log_path = _meta_.log_path
self.lib_path = _meta_.lib_path
self.tmp_path = _meta_.tmp_path
self.build_path = _meta_.build_path
self.slpkg_tmp_packages = _meta_.slpkg_tmp_packages
self.slpkg_tmp_patches = _meta_.slpkg_tmp_patches
self.meta = _meta_
self.conf_path = self.meta.conf_path
self.log_path = self.meta.log_path
self.lib_path = self.meta.lib_path
self.tmp_path = self.meta.tmp_path
self.build_path = self.meta.build_path
self.slpkg_tmp_packages = self.meta.slpkg_tmp_packages
self.slpkg_tmp_patches = self.meta.slpkg_tmp_patches
if not os.path.exists(self.conf_path):
os.mkdir(self.conf_path)
if not os.path.exists(self.log_path):
@ -384,12 +385,12 @@ class Initialization(object):
elif arch == "arm":
ar = "arm"
packages_txt = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, _meta_.slacke_sub_repo[1:-1], ar, slack_ver(), lib_file)
repo, self.meta.slacke_sub_repo[1:-1], ar, slack_ver(), lib_file)
# filelist_txt = ""
checksums_md5 = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, _meta_.slacke_sub_repo[1:-1], ar, slack_ver(), md5_file)
repo, self.meta.slacke_sub_repo[1:-1], ar, slack_ver(), md5_file)
changelog_txt = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, _meta_.slacke_sub_repo[1:-1], ar, slack_ver(), log_file)
repo, self.meta.slacke_sub_repo[1:-1], ar, slack_ver(), log_file)
self.write(lib, lib_file, packages_txt)
self.write(lib, md5_file, checksums_md5)
self.write(log, log_file, changelog_txt)
@ -555,7 +556,7 @@ class Initialization(object):
Remove all package lists with changelog and checksums files
and create lists again
"""
for repo in _meta_.repositories:
for repo in self.meta.repositories:
changelogs = "{0}{1}{2}".format(self.log_path, repo,
"/ChangeLog.txt")
if os.path.isfile(changelogs):
@ -578,16 +579,16 @@ class Update(object):
Update all repositories lists
"""
print("\nCheck and update repositories:\n")
for repo in _meta_.repositories:
for repo in self.meta.repositories:
sys.stdout.write("{0}Update repository {1} ...{2}".format(
_meta_.color["GREY"], repo, _meta_.color["ENDC"]))
self.meta.color["GREY"], repo, self.meta.color["ENDC"]))
sys.stdout.flush()
if repo in _meta_.default_repositories:
if repo in self.meta.default_repositories:
exec("{0}.{1}()".format(self._init, repo))
else:
Initialization().custom(repo)
sys.stdout.write("{0}Done{1}\n".format(_meta_.color["GREY"],
_meta_.color["ENDC"]))
sys.stdout.write("{0}Done{1}\n".format(self.meta.color["GREY"],
self.meta.color["ENDC"]))
print("") # new line at end
sys.exit(0)

View file

@ -62,6 +62,7 @@ class ArgParse(object):
def __init__(self, args):
self.args = args
self.meta = _meta_
self.packages = self.args[1:]
if len(self.args) > 1 and self.args[0] in ["-q", "--queue", "-b",
"--blacklist"]:
@ -82,7 +83,7 @@ class ArgParse(object):
elif (len(self.args) >= 3 and
self.args[0] in ["-s", "--sync", "-t", "--tracking", "-p",
"--print", "-F", "--FIND"] and
self.args[1] in _meta_.repositories and
self.args[1] in self.meta.repositories and
self.args[2].endswith(".pkg")):
self.packages = Utils().read_file_pkg(self.args[2])
elif (len(self.args) == 3 and self.args[0] in ["-q", "--queue",
@ -165,7 +166,7 @@ class ArgParse(object):
""" auto built tool """
options = ["-a", "--autobuild"]
if len(self.args) == 3 and self.args[0] in options:
BuildPackage(self.args[1], self.args[2:], _meta_.path).build()
BuildPackage(self.args[1], self.args[2:], self.meta.path).build()
else:
usage("")
@ -174,7 +175,7 @@ class ArgParse(object):
options = ["-l", "--list"]
flag = ["--index", "--installed"]
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in _meta_.repositories):
self.args[1] in self.meta.repositories):
if self.args[2] == flag[0]:
PackageManager(binary=None).package_list(self.args[1],
INDEX=True,
@ -186,11 +187,11 @@ class ArgParse(object):
else:
usage("")
elif (len(self.args) == 2 and self.args[0] in options and
self.args[1] in _meta_.repositories):
self.args[1] in self.meta.repositories):
PackageManager(None).package_list(self.args[1], INDEX=False,
installed=False)
elif (len(self.args) > 1 and self.args[0] in options and
self.args[1] not in _meta_.repositories):
self.args[1] not in self.meta.repositories):
usage(self.args[1])
else:
usage("")
@ -211,12 +212,12 @@ class ArgParse(object):
self.args.pop(3)
if (len(self.args) == 3 and self.args[0] in options and
self.args[2] == flag[0]):
if (self.args[1] in _meta_.repositories and
if (self.args[1] in self.meta.repositories and
self.args[1] not in ["slack", "sbo"]):
BinaryInstall(pkg_upgrade(self.args[1], skip),
self.args[1], resolve).start(if_upgrade=True)
elif self.args[1] == "slack":
if _meta_.only_installed in ["on", "ON"]:
if self.meta.only_installed in ["on", "ON"]:
BinaryInstall(pkg_upgrade("slack", skip),
"slack", resolve).start(if_upgrade=True)
else:
@ -236,7 +237,7 @@ class ArgParse(object):
if self.args[-1] == flag[0]:
resolve = False
if len(self.args) >= 3 and self.args[0] in options:
if (self.args[1] in _meta_.repositories and
if (self.args[1] in self.meta.repositories and
self.args[1] not in ["sbo"]):
BinaryInstall(self.packages, self.args[1], resolve).start(
if_upgrade=False)
@ -257,10 +258,10 @@ class ArgParse(object):
if self.args[2].endswith(".pkg"):
packages = self.packages[0]
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in _meta_.repositories):
self.args[1] in self.meta.repositories):
track_dep(packages, self.args[1])
elif (len(self.args) > 1 and self.args[0] in options and
self.args[1] not in _meta_.repositories):
self.args[1] not in self.meta.repositories):
usage(self.args[1])
else:
usage("")
@ -272,7 +273,7 @@ class ArgParse(object):
if len(self.packages) > 1:
packages = self.packages[0]
if (len(self.args) == 2 and self.args[0] in options and
"sbo" in _meta_.repositories):
"sbo" in self.meta.repositories):
SBoNetwork(packages).view()
else:
usage("")
@ -372,17 +373,17 @@ class ArgParse(object):
if len(self.packages) > 1:
packages = self.packages[0]
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in _meta_.repositories):
self.args[1] in self.meta.repositories):
PkgDesc(packages, self.args[1], "").view()
elif (len(self.args) == 4 and self.args[0] in options and
self.args[3].startswith(flag[0])):
tag = self.args[3][len(flag[0]):]
if self.args[1] in _meta_.repositories and tag in colors:
if self.args[1] in self.meta.repositories and tag in colors:
PkgDesc(packages, self.args[1], tag).view()
else:
usage("")
elif (len(self.args) > 1 and self.args[0] in options and
self.args[1] not in _meta_.repositories):
self.args[1] not in self.meta.repositories):
usage(self.args[1])
else:
usage("")

View file

@ -31,6 +31,9 @@ from slpkg.pkg.find import find_package
class Msg(object):
def __init__(self):
self.meta = _meta_
def pkg_not_found(self, bol, pkg, message, eol):
"""
Print message when package not found
@ -63,11 +66,11 @@ class Msg(object):
"""
self.template(78)
print("| Build package {0} [ {1}FAILED{2} ]".format(
prgnam, _meta_.color["RED"], _meta_.color["ENDC"]))
prgnam, self.meta.color["RED"], self.meta.color["ENDC"]))
self.template(78)
print("| See log file in '{0}/var/log/slpkg/sbo/build_logs{1}' "
"directory or read README".format(_meta_.color["CYAN"],
_meta_.color["ENDC"]))
"directory or read README".format(self.meta.color["CYAN"],
self.meta.color["ENDC"]))
print("| file: {0}{1}".format(sbo_url, "README"))
self.template(78)
print # new line at end
@ -82,8 +85,8 @@ class Msg(object):
"""
Message checking
"""
sys.stdout.write("{0}Checking ...{1}".format(_meta_.color["GREY"],
_meta_.color["ENDC"]))
sys.stdout.write("{0}Checking ...{1}".format(self.meta.color["GREY"],
self.meta.color["ENDC"]))
sys.stdout.flush()
def reading(self):
@ -91,7 +94,7 @@ class Msg(object):
Message reading
"""
sys.stdout.write("{0}Reading package lists ...{1}".format(
_meta_.color["GREY"], _meta_.color["ENDC"]))
self.meta.color["GREY"], self.meta.color["ENDC"]))
sys.stdout.flush()
def resolving(self):
@ -99,15 +102,15 @@ class Msg(object):
Message resolving
"""
sys.stdout.write("{0}Resolving dependencies ...{1}".format(
_meta_.color["GREY"], _meta_.color["ENDC"]))
self.meta.color["GREY"], self.meta.color["ENDC"]))
sys.stdout.flush()
def done(self):
"""
Message done
"""
sys.stdout.write("{0}Done{1}\n".format(_meta_.color["GREY"],
_meta_.color["ENDC"]))
sys.stdout.write("{0}Done{1}\n".format(self.meta.color["GREY"],
self.meta.color["ENDC"]))
def pkg(self, count):
"""
@ -140,8 +143,8 @@ class Msg(object):
"""
Message answer
"""
if _meta_.default_answer == "y":
answer = _meta_.default_answer
if self.meta.default_answer == "y":
answer = self.meta.default_answer
else:
answer = raw_input("Would you like to continue [Y/n]? ")
return answer
@ -158,7 +161,7 @@ class Msg(object):
self.template(78)
for installed in (install + upgrade):
name = "-".join(installed.split("-")[:-1])
if find_package(installed, _meta_.pkg_path):
if find_package(installed, self.meta.pkg_path):
if installed in upgrade:
print("| Package {0} upgraded successfully".format(name))
else:

View file

@ -32,7 +32,7 @@ import subprocess
from slpkg.messages import Msg
from slpkg.checksum import check_md5
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.sbo.greps import SBoGrep
@ -43,14 +43,15 @@ class BuildPackage(object):
self.script = script
self.sources = sources
self.path = path
self.meta = _meta_
self.prgnam = self.script[:-7]
self.log_file = "build_{0}_log".format(self.prgnam)
self.sbo_logs = _m.log_path + "sbo/"
self.sbo_logs = self.meta.log_path + "sbo/"
self.build_logs = self.sbo_logs + "build_logs/"
self.start_log_time = time.strftime("%H:%M:%S")
self.start_time = time.time()
if not os.path.exists(_m.log_path):
os.mkdir(_m.log_path)
if not os.path.exists(self.meta.log_path):
os.mkdir(self.meta.log_path)
if not os.path.exists(self.sbo_logs):
os.mkdir(self.sbo_logs)
if not os.path.exists(self.build_logs):
@ -78,7 +79,7 @@ class BuildPackage(object):
subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam),
shell=True)
pass_var = self._pass_variable()
if _m.sbo_build_log in ["on", "ON"]:
if self.meta.sbo_build_log in ["on", "ON"]:
if os.path.isfile(self.build_logs + self.log_file):
os.remove(self.build_logs + self.log_file)
# start log write

View file

@ -28,7 +28,7 @@ import subprocess
from slpkg.utils import Utils
from slpkg.messages import Msg
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
@ -42,6 +42,7 @@ class PackageManager(object):
"""
def __init__(self, binary):
self.binary = binary
self.meta = _meta_
def install(self):
"""
@ -90,7 +91,7 @@ class PackageManager(object):
"""
Remove Slackware binary packages
"""
dep_path = _m.log_path + "dep/"
dep_path = self.meta.log_path + "dep/"
dependencies, rmv_list = [], []
removed = self._view_removed()
if not removed:
@ -100,8 +101,8 @@ class PackageManager(object):
if len(removed) > 1:
msg = msg + "s"
try:
if _m.default_answer == "y":
remove_pkg = _m.default_answer
if self.meta.default_answer == "y":
remove_pkg = self.meta.default_answer
else:
remove_pkg = raw_input(
"\nAre you sure to remove {0} {1} [Y/n]? ".format(
@ -114,8 +115,8 @@ class PackageManager(object):
# If package build and install with "slpkg -s sbo <package>"
# then look log file for dependencies in /var/log/slpkg/dep,
# read and remove all else remove only the package.
if os.path.isfile(dep_path + rmv) and _m.del_deps in ["on",
"ON"]:
if (os.path.isfile(dep_path + rmv) and
self.meta.del_deps in ["on", "ON"]):
dependencies = self._view_deps(dep_path, rmv)
if self._rmv_deps_answer() in ["y", "Y"]:
rmv_list += (self._rmv_deps(dependencies, dep_path,
@ -132,8 +133,8 @@ class PackageManager(object):
"""
Remove dependencies answer
"""
if _m.remove_deps_answer == "y":
remove_dep = _m.remove_deps_answer
if self.meta.remove_deps_answer == "y":
remove_dep = self.meta.remove_deps_answer
else:
try:
remove_dep = raw_input(
@ -150,12 +151,13 @@ class PackageManager(object):
"""
removed = []
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
_m.color["CYAN"], ", ".join(self.binary), _m.color["ENDC"]))
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
for pkg in self.binary:
pkgs = find_package(pkg + _m.sp, _m.pkg_path)
pkgs = find_package(pkg + self.meta.sp, self.meta.pkg_path)
if pkgs:
print("[ {0}delete{1} ] --> {2}".format(
_m.color["RED"], _m.color["ENDC"],
self.meta.color["RED"], self.meta.color["ENDC"],
"\n ".join(pkgs)))
removed.append(pkg)
else:
@ -172,7 +174,8 @@ class PackageManager(object):
print("| Found dependencies for package {0}:".format(package))
Msg().template(78)
for dep in dependencies.splitlines():
print("| {0}{1}{2}".format(_m.color["RED"], dep, _m.color["ENDC"]))
print("| {0}{1}{2}".format(self.meta.color["RED"], dep,
self.meta.color["ENDC"]))
Msg().template(78)
return dependencies
@ -184,7 +187,7 @@ class PackageManager(object):
deps = dependencies.split()
deps.append(package)
for dep in deps:
if find_package(dep + _m.sp, _m.pkg_path):
if find_package(dep + self.meta.sp, self.meta.pkg_path):
print(subprocess.check_output("removepkg {0}".format(dep),
shell=True))
removes.append(dep)
@ -195,7 +198,7 @@ class PackageManager(object):
"""
Remove one signle package
"""
if find_package(package + _m.sp, _m.pkg_path):
if find_package(package + self.meta.sp, self.meta.pkg_path):
print(subprocess.check_output("removepkg {0}".format(package),
shell=True))
return package.split()
@ -208,7 +211,7 @@ class PackageManager(object):
print("| Total {0} packages removed".format(len(removes)))
Msg().template(78)
for pkg in removes:
if not find_package(pkg + _m.sp, _m.pkg_path):
if not find_package(pkg + self.meta.sp, self.meta.pkg_path):
print("| Package {0} removed".format(pkg))
else:
print("| Package {0} not found".format(pkg))
@ -221,14 +224,16 @@ class PackageManager(object):
"""
matching = size = 0
print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
_m.color["CYAN"], ", ".join(self.binary), _m.color["ENDC"]))
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
for pkg in self.binary:
for match in find_package("", _m.pkg_path):
for match in find_package("", self.meta.pkg_path):
if pkg in match:
matching += 1
print("[ {0}installed{1} ] - {2}".format(
_m.color["GREEN"], _m.color["ENDC"], match))
data = Utils().read_file(_m.pkg_path + match)
self.meta.color["GREEN"], self.meta.color["ENDC"],
match))
data = Utils().read_file(self.meta.pkg_path + match)
for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
if "M" in line[26:]:
@ -241,22 +246,23 @@ class PackageManager(object):
Msg().pkg_not_found("", ", ".join(self.binary), message, "\n")
else:
print("\n{0}Total found {1} matching packages.{2}".format(
_m.color["GREY"], matching, _m.color["ENDC"]))
self.meta.color["GREY"], matching, self.meta.color["ENDC"]))
unit = "Kb"
if size > 1024:
unit = "Mb"
size = (size / 1024)
print("{0}Size of installed packages {1} {2}.{3}\n".format(
_m.color["GREY"], round(size, 2), unit, _m.color["ENDC"]))
self.meta.color["GREY"], round(size, 2), unit,
self.meta.color["ENDC"]))
def display(self):
"""
Print the Slackware packages contents
"""
for pkg in self.binary:
find = find_package(pkg + _m.sp, _m.pkg_path)
find = find_package(pkg + self.meta.sp, self.meta.pkg_path)
if find:
package = Utils().read_file(_m.pkg_path + "".join(find))
package = Utils().read_file(self.meta.pkg_path + "".join(find))
for line in package.splitlines():
print(line).strip()
print("") # new line per file
@ -284,21 +290,22 @@ class PackageManager(object):
if INDEX:
index += 1
pkg = self.list_color_tag(pkg)
print("{0}{1}:{2} {3}".format(_m.color["GREY"], index,
_m.color["ENDC"], pkg))
print("{0}{1}:{2} {3}".format(
self.meta.color["GREY"], index,
self.meta.color["ENDC"], pkg))
if index == page:
read = raw_input("\nPress {0}Enter{1} to "
"continue... ".format(
_m.color["CYAN"],
_m.color["ENDC"]))
self.meta.color["CYAN"],
self.meta.color["ENDC"]))
if read in ["Q", "q"]:
break
print("") # new line after page
page += row
elif installed:
if self.list_of_installed(pkg):
print("{0}{1}{2}".format(_m.color["GREEN"], pkg,
_m.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"]))
else:
print(pkg)
print("") # new line at end
@ -329,13 +336,14 @@ class PackageManager(object):
"""
if repo == "sbo":
if (os.path.isfile(
_m.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(repo))):
packages = Utils().read_file(_m.lib_path + "{0}_repo/"
self.meta.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
repo))):
packages = Utils().read_file(self.meta.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))
else:
if (os.path.isfile(_m.lib_path + "{0}_repo/PACKAGES.TXT".format(
repo))):
packages = Utils().read_file(_m.lib_path + "{0}_repo/"
if (os.path.isfile(
self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(repo))):
packages = Utils().read_file(self.meta.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
return packages
@ -351,20 +359,20 @@ class PackageManager(object):
"""
Tag with color installed packages
"""
find = pkg + "-"
find = pkg + self.meta.sp
if pkg.endswith(".txz") or pkg.endswith(".tgz"):
find = pkg[:-4]
if find_package(find, _m.pkg_path):
pkg = "{0}{1}{2}".format(_m.color["GREEN"], pkg,
_m.color["ENDC"])
if find_package(find, self.meta.pkg_path):
pkg = "{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"])
return pkg
def list_of_installed(self, pkg):
"""
Return installed packages
"""
find = pkg + "-"
find = pkg + self.meta.sp
if pkg.endswith(".txz") or pkg.endswith(".tgz"):
find = pkg[:-4]
if find_package(find, _m.pkg_path):
if find_package(find, self.meta.pkg_path):
return pkg

View file

@ -48,11 +48,12 @@ class QueuePkgs(object):
"# packages you want to build or install.\n",
"#\n"
]
self.meta = _meta_
self.quit = False
self.queue = _meta_.lib_path + "queue/"
self.queue = self.meta.lib_path + "queue/"
self.queue_list = self.queue + "queue_list"
if not os.path.exists(_meta_.lib_path):
os.mkdir(_meta_.lib_path)
if not os.path.exists(self.meta.lib_path):
os.mkdir(self.meta.lib_path)
if not os.path.exists(self.queue):
os.mkdir(self.queue)
if not os.path.isfile(self.queue_list):
@ -81,8 +82,8 @@ class QueuePkgs(object):
print("\nPackages in queue:\n")
for pkg in self.packages():
if pkg:
print("{0}{1}{2}".format(_meta_.color["GREEN"], pkg,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"]))
self.quit = True
if self.quit:
print("") # new line at exit
@ -98,13 +99,13 @@ class QueuePkgs(object):
for pkg in pkgs:
find = sbo_search_pkg(pkg)
if pkg not in queue_list and find is not None:
print("{0}{1}{2}".format(_meta_.color["GREEN"], pkg,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"]))
queue.write(pkg + "\n")
self.quit = True
else:
print("{0}{1}{2}".format(_meta_.color["RED"], pkg,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["RED"], pkg,
self.meta.color["ENDC"]))
self.quit = True
queue.close()
if self.quit:
@ -122,8 +123,8 @@ class QueuePkgs(object):
if line not in pkgs:
queue.write(line + "\n")
else:
print("{0}{1}{2}".format(_meta_.color["RED"], line,
_meta_.color["ENDC"]))
print("{0}{1}{2}".format(self.meta.color["RED"], line,
self.meta.color["ENDC"]))
self.quit = True
queue.close()
if self.quit:
@ -136,19 +137,19 @@ class QueuePkgs(object):
packages = self.packages()
if packages:
for pkg in packages:
if not os.path.exists(_meta_.build_path):
os.mkdir(_meta_.build_path)
if not os.path.exists(self.meta.build_path):
os.mkdir(self.meta.build_path)
sbo_url = sbo_search_pkg(pkg)
sbo_dwn = SBoLink(sbo_url).tar_gz()
source_dwn = SBoGrep(pkg).source().split()
sources = []
os.chdir(_meta_.build_path)
os.chdir(self.meta.build_path)
script = sbo_dwn.split("/")[-1]
Download(_meta_.build_path, sbo_dwn.split()).start()
Download(self.meta.build_path, sbo_dwn.split()).start()
for src in source_dwn:
Download(_meta_.build_path, src.split()).start()
Download(self.meta.build_path, src.split()).start()
sources.append(src.split("/")[-1])
BuildPackage(script, sources, _meta_.build_path).build()
BuildPackage(script, sources, self.meta.build_path).build()
else:
print("\nPackages not found in the queue for building\n")
@ -161,13 +162,13 @@ class QueuePkgs(object):
print("") # new line at start
for pkg in packages:
# check if package exist in /tmp
find = find_package(pkg, _meta_.tmp)
find = find_package(pkg, self.meta.tmp)
try:
find = max(find)
except ValueError:
print("Package '{0}' not found in /tmp\n".format(pkg))
if pkg in find:
binary = "{0}{1}".format(_meta_.tmp, find)
binary = "{0}{1}".format(self.meta.tmp, find)
PackageManager(binary.split()).install()
else:
print("\nPackages not found in the queue for installation\n")

View file

@ -45,6 +45,7 @@ class RepoInfo(object):
"Total compressed packages:": "",
"Total uncompressed packages:": ""
}
self.meta = _meta_
self.all_repos = RepoList().all_repos
self.all_repos.update(Repo().custom_repository())
del RepoList().all_repos
@ -53,17 +54,17 @@ class RepoInfo(object):
"""
View repository information
"""
status = "{0}disabled{1}".format(_meta_.color["RED"],
_meta_.color["ENDC"])
status = "{0}disabled{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"])
self.form["Status:"] = status
self.form["Default:"] = "no"
if repo in _meta_.default_repositories:
if repo in self.meta.default_repositories:
self.form["Default:"] = "yes"
if (repo in _meta_.repositories and
os.path.isfile(_meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(
repo))):
status = "{0}enabled{1}".format(_meta_.color["GREEN"],
_meta_.color["ENDC"])
if (repo in self.meta.repositories and
os.path.isfile(self.meta.lib_path + "{0}_repo/PACKAGES."
"TXT".format(repo))):
status = "{0}enabled{1}".format(self.meta.color["GREEN"],
self.meta.color["ENDC"])
if repo != "sbo":
data = self.repository_data(repo)
size = units(data[1], data[2])
@ -76,17 +77,18 @@ class RepoInfo(object):
self.form["Number of packages:"] = data[0]
self.form["Status:"] = status
self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile(_meta_.lib_path + "{0}_repo/"
elif (repo == "sbo" and os.path.isfile(self.meta.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))):
status = "{0}enabled{1}".format(_meta_.color["GREEN"],
_meta_.color["ENDC"])
status = "{0}enabled{1}".format(self.meta.color["GREEN"],
self.meta.color["ENDC"])
sum_sbo_pkgs = 0
for line in (Utils().read_file(
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT").splitlines()):
self.meta.lib_path + "sbo_repo/SLACKBUILDS."
"TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1
changelog_txt = Utils().read_file(
_meta_.log_path + "sbo/ChangeLog.txt")
self.meta.log_path + "sbo/ChangeLog.txt")
last_upd = changelog_txt.split("\n", 1)[0]
self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo]
@ -97,7 +99,7 @@ class RepoInfo(object):
self.form["Last updated:"] = last_upd
print("")
for key, value in sorted(self.form.iteritems()):
print _meta_.color["GREY"] + key + _meta_.color["ENDC"], value
print self.meta.color["GREY"] + key + self.meta.color["ENDC"], value
print("")
sys.exit(0)
@ -107,7 +109,7 @@ class RepoInfo(object):
"""
sum_pkgs, size, unsize, last_upd = 0, [], [], ""
for line in (Utils().read_file(
_meta_.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()):
self.meta.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()):
if line.startswith("PACKAGES.TXT;"):
last_upd = line[14:].strip()
if line.startswith("PACKAGE NAME:"):
@ -118,6 +120,6 @@ class RepoInfo(object):
unsize.append(line[30:-2].strip())
if repo in ["salix", "slackl"]:
log = Utils().read_file(
_meta_.log_path + "{0}/ChangeLog.txt".format(repo))
self.meta.log_path + "{0}/ChangeLog.txt".format(repo))
last_upd = log.split("\n", 1)[0]
return [sum_pkgs, size, unsize, last_upd]

View file

@ -35,6 +35,7 @@ class RepoList(object):
"""
def __init__(self):
self.meta = _meta_
self.all_repos = {
"slack": Repo().slack(),
"sbo": Repo().sbo(),
@ -66,19 +67,19 @@ class RepoList(object):
"Status"))
Msg().template(78)
for repo_id, repo_URL in sorted(self.all_repos.iteritems()):
status, COLOR = "disabled", _meta_.color["RED"]
status, COLOR = "disabled", self.meta.color["RED"]
default = "yes"
if len(repo_URL) > 49:
repo_URL = repo_URL[:48] + "~"
if repo_id in _meta_.repositories:
status, COLOR = "enabled", _meta_.color["GREEN"]
if repo_id not in _meta_.default_repositories:
if repo_id in self.meta.repositories:
status, COLOR = "enabled", self.meta.color["GREEN"]
if repo_id not in self.meta.default_repositories:
default = "no"
print(" {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}".format(
repo_id, " " * (9 - len(repo_id)),
repo_URL, " " * (52 - len(repo_URL)),
default, " " * (8 - len(default)),
COLOR, status, _meta_.color["ENDC"]))
COLOR, status, self.meta.color["ENDC"]))
print("\nFor enable or disable default repositories edit "
"'/etc/slpkg/slpkg.conf' file\n")
sys.exit(0)

View file

@ -32,6 +32,7 @@ from __metadata__ import MetaData as _meta_
class Repo(object):
def __init__(self):
self.meta = _meta_
self.repo_file = "/etc/slpkg/custom-repositories"
self.repositories_list = Utils().read_file(self.repo_file)
@ -46,8 +47,8 @@ class Repo(object):
line = line.lstrip()
if line and not line.startswith("#"):
repo_name.append(line.split()[0])
if (repo in _meta_.repositories or repo in repo_name or
repo in _meta_.default_repositories):
if (repo in self.meta.repositories or repo in repo_name or
repo in self.meta.default_repositories):
print("\nRepository name '{0}' exist, select different name.\n"
"View all repositories with command 'repo-list'.\n".format(
repo))
@ -102,7 +103,8 @@ class Repo(object):
"""
default = "http://mirrors.slackware.com/slackware/"
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
mirrors = Utils().read_file(_meta_.conf_path + "slackware-mirrors")
mirrors = Utils().read_file(
self.meta.conf_path + "slackware-mirrors")
for line in mirrors.splitlines():
line = line.rstrip()
if not line.startswith("#") and line:

View file

@ -23,7 +23,7 @@
from slpkg.repositories import Repo
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slack_version import slack_ver
@ -33,10 +33,10 @@ def mirrors(name, location):
Select Slackware official mirror packages
based architecture and version.
"""
rel = _m.slack_rel
rel = _meta_.slack_rel
ver = slack_ver()
repo = Repo().slack()
if _m.arch == "x86_64":
if _meta_.arch == "x86_64":
if rel == "stable":
http = repo + "slackware64-{0}/{1}{2}".format(ver, location, name)
else:

View file

@ -37,7 +37,7 @@ from slpkg.blacklist import BlackList
from slpkg.downloader import Download
from slpkg.grep_md5 import pkg_checksum
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import PackageManager
@ -52,8 +52,9 @@ class Patches(object):
def __init__(self, skip):
self.skip = skip
self.version = _m.slack_rel
self.patch_path = _m.slpkg_tmp_patches
self.meta = _meta_
self.version = self.meta.slack_rel
self.patch_path = self.meta.slpkg_tmp_patches
self.pkg_for_upgrade = []
self.dwn_links = []
self.upgrade_all = []
@ -97,7 +98,7 @@ class Patches(object):
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2} will be upgraded and {3} will be "
"installed.".format(_m.color["GREY"],
"installed.".format(self.meta.color["GREY"],
self.count_upg,
Msg().pkg(self.upgrade_all),
self.count_added))
@ -105,7 +106,7 @@ class Patches(object):
unit[0]))
print("After this process, {0} {1} of additional disk space "
"will be used.{2}".format(size[1], unit[1],
_m.color["ENDC"]))
self.meta.color["ENDC"]))
print("")
if Msg().answer() in ["y", "Y"]:
Download(self.patch_path, self.dwn_links).start()
@ -113,7 +114,7 @@ class Patches(object):
self.patch_path, self.upgrade_all)
self.upgrade()
self.kernel()
if _m.slackpkg_log in ["on", "ON"]:
if self.meta.slackpkg_log in ["on", "ON"]:
self.slackpkg_update()
Msg().reference(self.installed, self.upgraded)
delete(self.patch_path, self.upgrade_all)
@ -135,7 +136,7 @@ class Patches(object):
black = BlackList().packages()
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
repo_pkg_name = split_package(name)[0]
if (not os.path.isfile(_m.pkg_path + name[:-4]) and
if (not os.path.isfile(self.meta.pkg_path + name[:-4]) and
repo_pkg_name not in black and
repo_pkg_name not in self.skip):
self.dwn_links.append("{0}{1}/{2}".format(mirrors("", ""),
@ -144,7 +145,7 @@ class Patches(object):
self.uncomp_sum.append(uncomp)
self.upgrade_all.append(name)
self.count_upg += 1
if not find_package(repo_pkg_name, _m.pkg_path):
if not find_package(repo_pkg_name, self.meta.pkg_path):
self.count_added += 1
self.count_upg -= 1
@ -154,11 +155,11 @@ class Patches(object):
"""
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
pkg_split = split_package(upg[:-4])
color = _m.color["YELLOW"]
if not find_package(pkg_split[0], _m.pkg_path):
color = _m.color["RED"]
color = self.meta.color["YELLOW"]
if not find_package(pkg_split[0], self.meta.pkg_path):
color = self.meta.color["RED"]
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format(
color, pkg_split[0], _m.color["ENDC"],
color, pkg_split[0], self.meta.color["ENDC"],
" " * (24-len(pkg_split[0])), pkg_split[1],
" " * (18-len(pkg_split[1])), pkg_split[2],
" " * (8-len(pkg_split[2])), pkg_split[3],
@ -173,16 +174,16 @@ class Patches(object):
check_md5(pkg_checksum(pkg, "slack_patches"), self.patch_path + pkg)
pkg_ver = "{0}-{1}".format(split_package(pkg)[0],
split_package(pkg)[1])
if find_package(split_package(pkg)[0] + "-", _m.pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format(_m.color["YELLOW"],
_m.color["ENDC"],
pkg[:-4]))
if find_package(split_package(pkg)[0] + "-", self.meta.pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format(
self.meta.color["YELLOW"], self.meta.color["ENDC"],
pkg[:-4]))
PackageManager((self.patch_path + pkg).split()).upgrade()
self.upgraded.append(pkg_ver)
else:
print("[ {0}installing{1} ] --> {2}".format(_m.color["GREEN"],
_m.color["ENDC"],
pkg[:-4]))
print("[ {0}installing{1} ] --> {2}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"],
pkg[:-4]))
PackageManager((self.patch_path + pkg).split()).upgrade()
self.installed.append(pkg_ver)
@ -193,13 +194,14 @@ class Patches(object):
"""
for core in self.upgrade_all:
if "kernel" in core:
if _m.default_answer == "y":
answer = _m.default_answer
if self.meta.default_answer == "y":
answer = self.meta.default_answer
else:
print("")
Msg().template(78)
print("| {0}*** HIGHLY recommended reinstall 'LILO' "
"***{1}".format(_m.color["RED"], _m.color["ENDC"]))
"***{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"]))
Msg().template(78)
answer = raw_input("\nThe kernel has been upgraded, "
"reinstall `LILO` [Y/n]? ")
@ -216,9 +218,10 @@ class Patches(object):
changelog_old = changelog_txt + ".old"
arch = "64" if os.uname()[4] == "x86_64" else ""
slackware_mirror = self.utils.read_config(self.utils.read_file(
_m.conf_path + "slackware-changelogs-mirror"))
self.meta.conf_path + "slackware-changelogs-mirror"))
slackpkg_mirror = self.utils.read_config(
self.utils.read_file("{0}{1}".format(_m.slackpkg_conf, "mirrors")))
self.utils.read_file("{0}{1}".format(self.meta.slackpkg_conf,
"mirrors")))
if slackpkg_mirror and "current" in slackpkg_mirror:
log_mirror = "{0}slackware{1}-current/{2}".format(slackware_mirror,
arch,
@ -229,12 +232,12 @@ class Patches(object):
slack_ver(),
changelog_txt)
slackware_log = URL(log_mirror).reading()
if os.path.isfile(_m.slackpkg_lib_path + changelog_txt):
if os.path.isfile(_m.slackpkg_lib_path + changelog_old):
os.remove(_m.slackpkg_lib_path + changelog_old)
shutil.copy2(_m.slackpkg_lib_path + changelog_txt,
_m.slackpkg_lib_path + changelog_old)
os.remove(_m.slackpkg_lib_path + changelog_txt)
with open(_m.slackpkg_lib_path + changelog_txt, "w") as log:
if os.path.isfile(self.meta.slackpkg_lib_path + changelog_txt):
if os.path.isfile(self.meta.slackpkg_lib_path + changelog_old):
os.remove(self.meta.slackpkg_lib_path + changelog_old)
shutil.copy2(self.meta.slackpkg_lib_path + changelog_txt,
self.meta.slackpkg_lib_path + changelog_old)
os.remove(self.meta.slackpkg_lib_path + changelog_txt)
with open(self.meta.slackpkg_lib_path + changelog_txt, "w") as log:
log.write(slackware_log)
log.close()

View file

@ -32,6 +32,7 @@ class URL(object):
def __init__(self, link):
self.link = link
self.meta = _meta_
def reading(self):
"""
@ -42,8 +43,8 @@ class URL(object):
return f.read()
except (urllib2.URLError, ValueError):
print("\n{0}Can't read file '{1}'{2}".format(
_meta_.color["RED"], self.link.split("/")[-1],
_meta_.color["ENDC"]))
self.meta.color["RED"], self.link.split("/")[-1],
self.meta.color["ENDC"]))
return " "
except KeyboardInterrupt:
print("") # new line at exit