Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2020-01-30 00:11:24 +01:00
commit f2665fcb2f
12 changed files with 62 additions and 61 deletions

View file

@ -68,11 +68,7 @@ class BinaryInstall:
self.msg = Msg() self.msg = Msg()
self.version = self.meta.slack_rel self.version = self.meta.slack_rel
self.tmp_path = self.meta.slpkg_tmp_packages self.tmp_path = self.meta.slpkg_tmp_packages
for fl in self.flag: self.init_flags()
if fl.startswith("--directory-prefix="):
self.tmp_path = fl.split("=")[1]
if not self.tmp_path.endswith("/"):
self.tmp_path += "/"
self.dwn, self.dep_dwn = [], [] self.dwn, self.dep_dwn = [], []
self.install, self.dep_install = [], [] self.install, self.dep_install = [], []
self.comp_sum, self.dep_comp_sum = [], [] self.comp_sum, self.dep_comp_sum = [], []
@ -89,6 +85,15 @@ class BinaryInstall:
self.blacklist = BlackList().packages(self.data[0], self.repo) self.blacklist = BlackList().packages(self.data[0], self.repo)
self.matching = False self.matching = False
def init_flags(self):
"""Flags initiliazation
"""
for fl in self.flag:
if fl.startswith("--directory-prefix="):
self.tmp_path = fl.split("=")[1]
if not self.tmp_path.endswith("/"):
self.tmp_path += "/"
def start(self, is_upgrade): def start(self, is_upgrade):
""" """
Install packages from official Slackware distribution Install packages from official Slackware distribution
@ -186,8 +191,7 @@ class BinaryInstall:
lowercase lowercase
""" """
if "--case-ins" in self.flag: if "--case-ins" in self.flag:
data = [] data = list(Utils().package_name(self.PACKAGES_TXT))
data = Utils().package_name(self.PACKAGES_TXT)
data_dict = Utils().case_sensitive(data) data_dict = Utils().case_sensitive(data)
for pkg in self.packages: for pkg in self.packages:
index = self.packages.index(pkg) index = self.packages.index(pkg)
@ -266,18 +270,16 @@ class BinaryInstall:
dependencies = [] dependencies = []
dependencies = Utils().dimensional_list(Dependencies( dependencies = Utils().dimensional_list(Dependencies(
self.repo, self.blacklist).binary(dep, self.flag)) self.repo, self.blacklist).binary(dep, self.flag))
requires += self._fix_deps_repos(dependencies) requires += list(self._fix_deps_repos(dependencies))
self.deps_dict[dep] = Utils().remove_dbs(requires) self.deps_dict[dep] = Utils().remove_dbs(requires)
return Utils().remove_dbs(requires) return Utils().remove_dbs(requires)
def _fix_deps_repos(self, dependencies): def _fix_deps_repos(self, dependencies):
"""Fix store deps include in repository """Fix store deps include in repository
""" """
requires = []
for dep in dependencies: for dep in dependencies:
if dep in self.repo_pkg_names: if dep in self.repo_pkg_names:
requires.append(dep) yield dep
return requires
def views(self, install, comp_sum): def views(self, install, comp_sum):
"""Views packages """Views packages

View file

@ -23,9 +23,7 @@
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.toolbar import status
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -34,11 +32,7 @@ def search_pkg(name, repo):
and return the name. and return the name.
""" """
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
names = Utils().package_name(PACKAGES_TXT) names = list(Utils().package_name(PACKAGES_TXT))
blacklist = BlackList().packages(pkgs=names, repo=repo) blacklist = BlackList().packages(pkgs=names, repo=repo)
for line in PACKAGES_TXT.splitlines(): if name in names and name not in blacklist:
status(0) return name
if line.startswith("PACKAGE NAME: ") and len(line) > 16:
pkg_name = split_package(line[15:])[0].strip()
if name == pkg_name and name not in blacklist:
return pkg_name

View file

@ -75,7 +75,6 @@ class BlackList:
print(f"{self.green}{pkg}{self.endc}") print(f"{self.green}{pkg}{self.endc}")
black_conf.write(pkg + "\n") black_conf.write(pkg + "\n")
self.quit = True self.quit = True
black_conf.close()
if self.quit: if self.quit:
print() # new line at exit print() # new line at exit
@ -90,7 +89,6 @@ class BlackList:
else: else:
print(f"{self.red}{line}{self.endc}") print(f"{self.red}{line}{self.endc}")
self.quit = True self.quit = True
remove.close()
if self.quit: if self.quit:
print() # new line at exit print() # new line at exit

View file

@ -108,7 +108,7 @@ class BuildPackage:
log_end(self.build_logs, self.log_file, sum_time) log_end(self.build_logs, self.log_file, sum_time)
print(f"Total build time for the package {self.prgnam} : {sum_time}\n") print(f"Total build time for the package {self.prgnam} : {sum_time}\n")
else: else:
subprocess.call(f"{' '.join(pass_ver)} ./{self.prgnam}.SlackBuild", shell=True) subprocess.call(f"{' '.join(pass_var)} ./{self.prgnam}.SlackBuild", shell=True)
os.chdir(self.path) os.chdir(self.path)
except KeyboardInterrupt: # (OSError, IOError): except KeyboardInterrupt: # (OSError, IOError):
self.msg.pkg_not_found("\n", self.prgnam, "Wrong file", "\n") self.msg.pkg_not_found("\n", self.prgnam, "Wrong file", "\n")
@ -171,7 +171,6 @@ def log_head(path, log_file, log_time):
log.write("Date : " + time.strftime("%d/%m/%Y") + "\n") log.write("Date : " + time.strftime("%d/%m/%Y") + "\n")
log.write("Time : " + log_time + "\n\n") log.write("Time : " + log_time + "\n\n")
log.write("#" * 79 + "\n\n") log.write("#" * 79 + "\n\n")
log.close()
def log_end(path, log_file, sum_time): def log_end(path, log_file, sum_time):
@ -185,7 +184,6 @@ def log_end(path, log_file, sum_time):
log.write(f"Total build time : {sum_time}\n") log.write(f"Total build time : {sum_time}\n")
log.write(" " * 38 + "E N D\n\n") log.write(" " * 38 + "E N D\n\n")
log.write("#" * 79 + "\n\n") log.write("#" * 79 + "\n\n")
log.close()
def build_time(start_time): def build_time(start_time):

View file

@ -27,16 +27,20 @@ from slpkg.blacklist import BlackList
from slpkg.splitting import split_package from slpkg.splitting import split_package
def find_package(find_pkg, directory): def searching(find_pkg, directory):
"""Find packages """Find packages
""" """
pkgs = []
if os.path.isdir(directory): if os.path.isdir(directory):
installed = sorted(os.listdir(directory)) installed = os.listdir(directory)
blacklist = BlackList().packages(pkgs=installed, repo="local") blacklist = BlackList().packages(pkgs=installed, repo="local")
if os.path.exists(directory): if os.path.exists(directory):
for pkg in installed: for pkg in installed:
if (not pkg.startswith(".") and pkg.startswith(find_pkg) and if (not pkg.startswith(".") and pkg.startswith(find_pkg) and
split_package(pkg)[0] not in blacklist): split_package(pkg)[0] not in blacklist):
pkgs.append(pkg) yield pkg
return pkgs
def find_package(pkg, path):
"""Generator allias
"""
return list(searching(pkg, path))

View file

@ -82,7 +82,6 @@ class Repo:
print("\nRepository '{0}' successfully " print("\nRepository '{0}' successfully "
"removed\n".format(repo)) "removed\n".format(repo))
rem_repo = True rem_repo = True
repos.close()
if not rem_repo: if not rem_repo:
print("\nRepository '{0}' doesn't exist\n".format(repo)) print("\nRepository '{0}' doesn't exist\n".format(repo))
raise SystemExit() raise SystemExit()

View file

@ -58,10 +58,15 @@ class Requires:
# if require in blacklist # if require in blacklist
if "%README%" not in req and req not in self.blacklist: if "%README%" not in req and req not in self.blacklist:
dependencies.append(req) dependencies.append(req)
if dependencies: self.deep_check(dependencies)
self.dep_results.append(dependencies)
for dep in dependencies:
self.sbo(dep)
return self.dep_results return self.dep_results
else: else:
return [] return []
def deep_check(self, dependencies):
"""Checking if dependencies are finnished
"""
if dependencies:
self.dep_results.append(dependencies)
for dep in dependencies:
self.sbo(dep)

View file

@ -47,14 +47,18 @@ class SBoGrep:
self.unst = ["UNSUPPORTED", "UNTESTED"] self.unst = ["UNSUPPORTED", "UNTESTED"]
self.SLACKBUILDS_TXT = Utils().read_file(self.sbo_txt) self.SLACKBUILDS_TXT = Utils().read_file(self.sbo_txt)
def names(self): def _names_grabbing(self):
"""Grab all packages name """Generator that collecting all packages names
""" """
pkg_names = []
for line in self.SLACKBUILDS_TXT.splitlines(): for line in self.SLACKBUILDS_TXT.splitlines():
if line.startswith(self.line_name): if line.startswith(self.line_name):
pkg_names.append(line[17:].strip()) yield line[17:].strip()
return pkg_names
def names(self):
"""Alias method convert generator and return
a list
"""
return list(self._names_grabbing())
def source(self): def source(self):
"""Grab sources downloads links """Grab sources downloads links
@ -138,7 +142,7 @@ class SBoGrep:
return md5sum64 return md5sum64
def description(self): def description(self):
"""Grab package verion """Grab package version
""" """
for line in self.SLACKBUILDS_TXT.splitlines(): for line in self.SLACKBUILDS_TXT.splitlines():
if line.startswith(self.line_name): if line.startswith(self.line_name):

View file

@ -65,7 +65,6 @@ class QueuePkgs:
with open(self.queue_list, "w") as queue: with open(self.queue_list, "w") as queue:
for line in queue_file: for line in queue_file:
queue.write(line) queue.write(line)
queue.close()
self.queued = Utils().read_file(self.queue_list) self.queued = Utils().read_file(self.queue_list)
def packages(self): def packages(self):
@ -106,7 +105,6 @@ class QueuePkgs:
else: else:
print(f"{self.red}{pkg}{self.endc}") print(f"{self.red}{pkg}{self.endc}")
self.quit = True self.quit = True
queue.close()
if self.quit: if self.quit:
print() # new line at exit print() # new line at exit
@ -121,7 +119,6 @@ class QueuePkgs:
else: else:
print(f"{self.red}{line}{self.endc}") print(f"{self.red}{line}{self.endc}")
self.quit = True self.quit = True
queue.close()
if self.quit: if self.quit:
print() # new line at exit print() # new line at exit

View file

@ -65,11 +65,7 @@ class SBoInstall:
self.arch = SBoArch().get() self.arch = SBoArch().get()
self.build_folder = self.meta.build_path self.build_folder = self.meta.build_path
self._SOURCES = self.meta.SBo_SOURCES self._SOURCES = self.meta.SBo_SOURCES
for fl in self.flag: self.init_flags()
if fl.startswith("--directory-prefix="):
self.build_folder = fl.split("=")[1]
if not self.build_folder.endswith("/"):
self.build_folder += "/"
self.unst = ["UNSUPPORTED", "UNTESTED"] self.unst = ["UNSUPPORTED", "UNTESTED"]
self.master_packages = [] self.master_packages = []
self.deps = [] self.deps = []
@ -86,6 +82,15 @@ class SBoInstall:
self.data = SBoGrep(name="").names() self.data = SBoGrep(name="").names()
self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo") self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo")
def init_flags(self):
"""Flags initialization
"""
for fl in self.flag:
if fl.startswith("--directory-prefix="):
self.build_folder = fl.split("=")[1]
if not self.build_folder.endswith("/"):
self.build_folder += "/"
def start(self, is_upgrade): def start(self, is_upgrade):
"""Start view, build and install SBo packages """Start view, build and install SBo packages
""" """
@ -307,10 +312,8 @@ class SBoInstall:
def filenames(self, sources): def filenames(self, sources):
"""Return filenames from sources links """Return filenames from sources links
""" """
filename = []
for src in sources: for src in sources:
filename.append(src.split("/")[-1]) yield src.split("/")[-1]
return filename
def build_install(self): def build_install(self):
"""Build and install packages if not already installed """Build and install packages if not already installed
@ -343,13 +346,14 @@ class SBoInstall:
sbo_link = SBoLink(sbo_url).tar_gz() sbo_link = SBoLink(sbo_url).tar_gz()
script = sbo_link.split("/")[-1] script = sbo_link.split("/")[-1]
if self.meta.sbosrcarch in ["on", "ON"]: if self.meta.sbosrcarch in ["on", "ON"]:
src_link = self.sbosrcarsh(prgnam, sbo_link, src_link) src_link = list(self.sbosrcarsh(prgnam, sbo_link, src_link))
Download(self.build_folder, sbo_link.split(), Download(self.build_folder, sbo_link.split(),
repo="sbo").start() repo="sbo").start()
Download(self._SOURCES, src_link, repo="sbo").start() Download(self._SOURCES, src_link, repo="sbo").start()
if "--download-only" in self.flag: if "--download-only" in self.flag:
continue continue
sources = self.filenames(src_link) sources = list(self.filenames(src_link))
print(sources)
BuildPackage(script, sources, self.build_folder, BuildPackage(script, sources, self.build_folder,
auto=False).build() auto=False).build()
binary = slack_package(prgnam) binary = slack_package(prgnam)
@ -384,10 +388,8 @@ class SBoInstall:
def sbosrcarsh(self, prgnam, sbo_link, src_link): def sbosrcarsh(self, prgnam, sbo_link, src_link):
"""Alternative repository for sbo sources""" """Alternative repository for sbo sources"""
sources = []
name = "-".join(prgnam.split("-")[:-1]) name = "-".join(prgnam.split("-")[:-1])
category = f"{sbo_link.split('/')[-2]}/{name}/" category = f"{sbo_link.split('/')[-2]}/{name}/"
for link in src_link: for link in src_link:
source = link.split("/")[-1] source = link.split("/")[-1]
sources.append(f"{self.meta.sbosrcarch_link}{category}{source}") yield f"{self.meta.sbosrcarch_link}{category}{source}"
return sources

View file

@ -125,7 +125,7 @@ class TrackingDeps:
else: else:
PACKAGES_TXT = Utils().read_file( PACKAGES_TXT = Utils().read_file(
self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT") self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT")
self.names = Utils().package_name(PACKAGES_TXT) self.names = list(Utils().package_name(PACKAGES_TXT))
self.bin_case_insensitive() self.bin_case_insensitive()
self.find_pkg = search_pkg(self.name, self.repo) self.find_pkg = search_pkg(self.name, self.repo)
if self.find_pkg: if self.find_pkg:

View file

@ -66,11 +66,9 @@ class Utils:
def package_name(self, PACKAGES_TXT): def package_name(self, PACKAGES_TXT):
"""Returns list with all the names of packages repository """Returns list with all the names of packages repository
""" """
packages = []
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"): if line.startswith("PACKAGE NAME:"):
packages.append(split_package(line[14:].strip())[0]) yield split_package(line[14:].strip())[0]
return packages
def check_downloaded(self, path, maybe_downloaded): def check_downloaded(self, path, maybe_downloaded):
"""Check if files downloaded and return downloaded """Check if files downloaded and return downloaded