Update metadata import

This commit is contained in:
Dimitris Zlatanidis 2015-06-07 08:26:42 +03:00
parent a96057888f
commit 47dc13f593
11 changed files with 100 additions and 97 deletions

View file

@ -23,13 +23,13 @@
from repolist import RepoList
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def header():
"""help header message"""
print("\nslpkg - version {0} | Slackware release: {1}\n".format(
_m.__version__, _m.slack_rel))
_meta_.__version__, _meta_.slack_rel))
def options():
@ -140,7 +140,7 @@ def usage(repo):
[-u [...]] [-o [...]] [-r [...]] [-d [...]]
"""
error_repo = ""
if repo and repo not in _m.repositories:
if repo and repo not in _meta_.repositories:
all_repos = RepoList().all_repos
del RepoList().all_repos
if repo in all_repos:

View file

@ -23,7 +23,7 @@
from utils import Utils
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class BlackList(object):
@ -55,8 +55,8 @@ class BlackList(object):
print("\nPackages in blacklist:\n")
for black in self.packages():
if black:
print("{0}{1}{2}".format(_m.color["GREEN"], black,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["GREEN"], black,
_meta_.color["ENDC"]))
self.quit = True
if self.quit:
print("") # new line at exit
@ -71,8 +71,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(_m.color["GREEN"], pkg,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["GREEN"], pkg,
_meta_.color["ENDC"]))
black_conf.write(pkg + "\n")
self.quit = True
black_conf.close()
@ -89,8 +89,8 @@ class BlackList(object):
if line not in pkgs:
remove.write(line + "\n")
else:
print("{0}{1}{2}".format(_m.color["RED"], line,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["RED"], line,
_meta_.color["ENDC"]))
self.quit = True
remove.close()
if self.quit:

View file

@ -26,20 +26,21 @@ import sys
from md5sum import md5
from messages import Msg
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def check_md5(pkg_md5, src_file):
"""
MD5 Checksum
"""
if _m.checkmd5 in ["on", "ON"]:
if _meta_.checkmd5 in ["on", "ON"]:
print("")
md5s = md5(src_file)
if pkg_md5 != md5s:
Msg().template(78)
print("| MD5SUM check for {0} [ {1}FAILED{2} ]".format(
src_file.split("/")[-1], _m.color["RED"], _m.color["ENDC"]))
src_file.split("/")[-1], _meta_.color["RED"],
_meta_.color["ENDC"]))
Msg().template(78)
print("| Expected: {0}".format(md5s))
print("| Found: {0}".format(pkg_md5))
@ -50,6 +51,7 @@ def check_md5(pkg_md5, src_file):
else:
Msg().template(78)
print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format(
src_file.split("/")[-1], _m.color["GREEN"], _m.color["ENDC"]))
src_file.split("/")[-1], _meta_.color["GREEN"],
_meta_.color["ENDC"]))
Msg().template(78)
print("") # new line after pass checksum

View file

@ -25,7 +25,7 @@
import subprocess
from utils import Utils
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class Config(object):
@ -63,8 +63,8 @@ class Config(object):
if not line.startswith("#") and line.split("=")[0] in conf_args:
print(line)
else:
print("{0}{1}{2}".format(_m.color["CYAN"], line,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["CYAN"], line,
_meta_.color["ENDC"]))
print("") # new line at end
def edit(self, editor):

View file

@ -24,7 +24,7 @@
from utils import Utils
from messages import Msg
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class PkgDesc(object):
@ -36,18 +36,19 @@ class PkgDesc(object):
self.COLOR = ""
self.lib = ""
color_text = {
"red": _m.color["RED"],
"green": _m.color["GREEN"],
"yellow": _m.color["YELLOW"],
"cyan": _m.color["CYAN"],
"grey": _m.color["GREY"],
"red": _meta_.color["RED"],
"green": _meta_.color["GREEN"],
"yellow": _meta_.color["YELLOW"],
"cyan": _meta_.color["CYAN"],
"grey": _meta_.color["GREY"],
"": ""
}
self.COLOR = color_text[self.paint]
if self.repo in _m.repositories and self.repo != "sbo":
self.lib = _m.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo)
if self.repo in _meta_.repositories and self.repo != "sbo":
self.lib = _meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(
self.repo)
else:
self.lib = _m.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
self.lib = _meta_.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
self.repo)
def view(self):
@ -58,7 +59,7 @@ class PkgDesc(object):
for line in PACKAGES_TXT.splitlines():
if line.startswith(self.name + ":"):
print(self.COLOR + line[len(self.name) + 1:] +
_m.color["ENDC"])
_meta_.color["ENDC"])
count += 1
if count == 11:
break
@ -67,7 +68,7 @@ class PkgDesc(object):
if (line.startswith(
"SLACKBUILD SHORT DESCRIPTION: " + self.name + " (")):
count += 1
print(self.COLOR + line[31:] + _m.color["ENDC"])
print(self.COLOR + line[31:] + _meta_.color["ENDC"])
if count == 0:
Msg().pkg_not_found("", self.name, "No matching", "\n")
else:

View file

@ -27,7 +27,7 @@ import sys
import subprocess
from messages import Msg
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class Download(object):
@ -35,7 +35,7 @@ class Download(object):
def __init__(self, path, url):
self.path = path
self.url = url
self.wget_options = _m.wget_options
self.wget_options = _meta_.wget_options
def start(self):
"""
@ -45,7 +45,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), _m.color["GREEN"], _m.color["ENDC"],
dwn_count, len(self.url), _meta_.color["GREEN"],
_meta_.color["ENDC"],
self.file_name))
try:
subprocess.call("wget {0} --directory-prefix={1} {2}".format(
@ -61,7 +62,7 @@ class Download(object):
print("")
Msg().template(78)
print("| Download '{0}' file {1}[ FAILED ]{2}".format(
self.file_name, _m.color["RED"], _m.color["ENDC"]))
self.file_name, _meta_.color["RED"], _meta_.color["ENDC"]))
Msg().template(78)
print("")
if not Msg().answer() in ["y", "Y"]:

View file

@ -25,7 +25,7 @@
from slack.mirrors import mirrors
from url_read import URL
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def pkg_checksum(binary, repo):
@ -33,14 +33,14 @@ def pkg_checksum(binary, repo):
Return checksum from CHECKSUMS.md5 file by repository
"""
md5, end = "None", "/"
if repo == "slack_patches" and _m.slack_rel == "stable":
if repo == "slack_patches" and _meta_.slack_rel == "stable":
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).reading()
elif repo == "slack_patches" and _m.slack_rel == "current":
elif repo == "slack_patches" and _meta_.slack_rel == "current":
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).reading()
elif repo == "slpkg":
CHECKSUMS_md5 = URL(_m.CHECKSUMS_link).reading()
CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).reading()
else:
lib = "{0}{1}_repo/CHECKSUMS.md5".format(_m.lib_path, repo)
lib = "{0}{1}_repo/CHECKSUMS.md5".format(_meta_.lib_path, repo)
f = open(lib, "r")
CHECKSUMS_md5 = f.read()
f.close()

View file

@ -29,7 +29,7 @@ from url_read import URL
from toolbar import status
from repositories import Repo
from file_size import FileSize
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
from slack.mirrors import mirrors
from slack.slack_version import slack_ver
@ -38,13 +38,13 @@ from slack.slack_version import slack_ver
class Initialization(object):
def __init__(self):
self.conf_path = _m.conf_path
self.log_path = _m.log_path
self.lib_path = _m.lib_path
self.tmp_path = _m.tmp_path
self.build_path = _m.build_path
self.slpkg_tmp_packages = _m.slpkg_tmp_packages
self.slpkg_tmp_patches = _m.slpkg_tmp_patches
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
if not os.path.exists(self.conf_path):
os.mkdir(self.conf_path)
if not os.path.exists(self.log_path):
@ -384,12 +384,12 @@ class Initialization(object):
elif arch == "arm":
ar = "arm"
packages_txt = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, _m.slacke_sub_repo[1:-1], ar, slack_ver(), lib_file)
repo, _meta_.slacke_sub_repo[1:-1], ar, slack_ver(), lib_file)
# filelist_txt = ""
checksums_md5 = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, _m.slacke_sub_repo[1:-1], ar, slack_ver(), md5_file)
repo, _meta_.slacke_sub_repo[1:-1], ar, slack_ver(), md5_file)
changelog_txt = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, _m.slacke_sub_repo[1:-1], ar, slack_ver(), log_file)
repo, _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 +555,7 @@ class Initialization(object):
Remove all package lists with changelog and checksums files
and create lists again
"""
for repo in _m.repositories:
for repo in _meta_.repositories:
changelogs = "{0}{1}{2}".format(self.log_path, repo,
"/ChangeLog.txt")
if os.path.isfile(changelogs):
@ -578,16 +578,16 @@ class Update(object):
Update all repositories lists
"""
print("\nCheck and update repositories:\n")
for repo in _m.repositories:
for repo in _meta_.repositories:
sys.stdout.write("{0}Update repository {1} ...{2}".format(
_m.color["GREY"], repo, _m.color["ENDC"]))
_meta_.color["GREY"], repo, _meta_.color["ENDC"]))
sys.stdout.flush()
if repo in _m.default_repositories:
if repo in _meta_.default_repositories:
exec("{0}.{1}()".format(self._init, repo))
else:
Initialization().custom(repo)
sys.stdout.write("{0}Done{1}\n".format(_m.color["GREY"],
_m.color["ENDC"]))
sys.stdout.write("{0}Done{1}\n".format(_meta_.color["GREY"],
_meta_.color["ENDC"]))
print("") # new line at end
sys.exit(0)
@ -598,11 +598,11 @@ def check_exists_repositories():
"""
update = False
pkg_list = "PACKAGES.TXT"
for repo in _m.repositories:
for repo in _meta_.repositories:
pkg_list = "PACKAGES.TXT"
if repo == "sbo":
pkg_list = "SLACKBUILDS.TXT"
if not os.path.isfile("{0}{1}{2}".format(_m.lib_path, repo,
if not os.path.isfile("{0}{1}{2}".format(_meta_.lib_path, repo,
"_repo/{0}".format(pkg_list))):
update = True
if update:

View file

@ -24,7 +24,7 @@
import os
from slpkg.__metadata__ import MetaData as _m
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
@ -35,8 +35,8 @@ def write_deps(deps_dict):
into directory `/var/log/slpkg/dep/`
"""
for name, dependencies in deps_dict.iteritems():
if find_package(name + "-", _m.pkg_path):
dep_path = _m.log_path + "dep/"
if find_package(name + "-", _meta_.pkg_path):
dep_path = _meta_.log_path + "dep/"
if not os.path.exists(dep_path):
os.mkdir(dep_path)
if os.path.isfile(dep_path + name):

View file

@ -44,7 +44,7 @@ from init import (
Initialization,
check_exists_repositories
)
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
from pkg.build import BuildPackage
from pkg.manager import PackageManager
@ -82,7 +82,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 _m.repositories and
self.args[1] in _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 +165,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:], _m.path).build()
BuildPackage(self.args[1], self.args[2:], _meta_.path).build()
else:
usage("")
@ -174,7 +174,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 _m.repositories):
self.args[1] in _meta_.repositories):
if self.args[2] == flag[0]:
PackageManager(binary=None).package_list(self.args[1],
INDEX=True,
@ -186,11 +186,11 @@ class ArgParse(object):
else:
usage("")
elif (len(self.args) == 2 and self.args[0] in options and
self.args[1] in _m.repositories):
self.args[1] in _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 _m.repositories):
self.args[1] not in _meta_.repositories):
usage(self.args[1])
else:
usage("")
@ -211,12 +211,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 _m.repositories and
if (self.args[1] in _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 _m.only_installed in ["on", "ON"]:
if _meta_.only_installed in ["on", "ON"]:
BinaryInstall(pkg_upgrade("slack", skip),
"slack", resolve).start(if_upgrade=True)
else:
@ -236,7 +236,8 @@ 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 _m.repositories and self.args[1] not in ["sbo"]:
if (self.args[1] in _meta_.repositories and
self.args[1] not in ["sbo"]):
BinaryInstall(self.packages, self.args[1], resolve).start(
if_upgrade=False)
elif self.args[1] == "sbo":
@ -256,10 +257,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 _m.repositories):
self.args[1] in _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 _m.repositories):
self.args[1] not in _meta_.repositories):
usage(self.args[1])
else:
usage("")
@ -271,7 +272,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 _m.repositories):
"sbo" in _meta_.repositories):
SBoNetwork(packages).view()
else:
usage("")
@ -371,17 +372,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 _m.repositories):
self.args[1] in _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 _m.repositories and tag in colors:
if self.args[1] in _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 _m.repositories):
self.args[1] not in _meta_.repositories):
usage(self.args[1])
else:
usage("")
@ -405,16 +406,15 @@ class ArgParse(object):
def congiguration(self):
""" manage slpkg configuration file """
options = ["-g", "--config"]
command = ["print", "edit"]
command = ["print", "edit="]
if (len(self.args) == 2 and self.args[0] in options and
self.args[1].startswith(command[0])):
self.args[1].startswith(command[1])):
editor = self.args[1][len(command[1]):]
if self.args[1] == command[0]:
Config().view()
elif editor:
Config().edit(editor)
else:
usage("")
print editor
Config().edit(editor)
elif (len(self.args) == 2 and self.args[0] in options and
self.args[1] == (command[0])):
Config().view()
else:
usage("")

View file

@ -24,7 +24,7 @@
import sys
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
@ -62,13 +62,12 @@ class Msg(object):
Print error message if build failed
"""
self.template(78)
print("| Build package {0} [ {1}FAILED{2} ]".format(prgnam,
_m.color["RED"],
_m.color["ENDC"]))
print("| Build package {0} [ {1}FAILED{2} ]".format(
prgnam, _meta_.color["RED"], _meta_.color["ENDC"]))
self.template(78)
print("| See log file in '{0}/var/log/slpkg/sbo/build_logs{1}' "
"directory or read README".format(_m.color["CYAN"],
_m.color["ENDC"]))
"directory or read README".format(_meta_.color["CYAN"],
_meta_.color["ENDC"]))
print("| file: {0}{1}".format(sbo_url, "README"))
self.template(78)
print # new line at end
@ -83,8 +82,8 @@ class Msg(object):
"""
Message checking
"""
sys.stdout.write("{0}Checking ...{1}".format(_m.color["GREY"],
_m.color["ENDC"]))
sys.stdout.write("{0}Checking ...{1}".format(_meta_.color["GREY"],
_meta_.color["ENDC"]))
sys.stdout.flush()
def reading(self):
@ -92,7 +91,7 @@ class Msg(object):
Message reading
"""
sys.stdout.write("{0}Reading package lists ...{1}".format(
_m.color["GREY"], _m.color["ENDC"]))
_meta_.color["GREY"], _meta_.color["ENDC"]))
sys.stdout.flush()
def resolving(self):
@ -100,15 +99,15 @@ class Msg(object):
Message resolving
"""
sys.stdout.write("{0}Resolving dependencies ...{1}".format(
_m.color["GREY"], _m.color["ENDC"]))
_meta_.color["GREY"], _meta_.color["ENDC"]))
sys.stdout.flush()
def done(self):
"""
Message done
"""
sys.stdout.write("{0}Done{1}\n".format(_m.color["GREY"],
_m.color["ENDC"]))
sys.stdout.write("{0}Done{1}\n".format(_meta_.color["GREY"],
_meta_.color["ENDC"]))
def pkg(self, count):
"""
@ -141,8 +140,8 @@ class Msg(object):
"""
Message answer
"""
if _m.default_answer == "y":
answer = _m.default_answer
if _meta_.default_answer == "y":
answer = _meta_.default_answer
else:
answer = raw_input("Would you like to continue [Y/n]? ")
return answer
@ -159,7 +158,7 @@ class Msg(object):
self.template(78)
for installed in (install + upgrade):
name = "-".join(installed.split("-")[:-1])
if find_package(installed, _m.pkg_path):
if find_package(installed, _meta_.pkg_path):
if installed in upgrade:
print("| Package {0} upgraded successfully".format(name))
else: