mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-24 19:58:31 +01:00
Merge branch 'develop'
This commit is contained in:
commit
77a5719aaf
67 changed files with 1489 additions and 168 deletions
|
@ -1,3 +1,7 @@
|
|||
4.0.1 - 30/05/2022
|
||||
Added:
|
||||
- SQLAlchemy Object Relational Mapper
|
||||
|
||||
4.0.0 - 29/05/2022
|
||||
Added:
|
||||
- sqlite3 database replaced the sbo repository
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
***********
|
||||
slpkg 4.0.0
|
||||
slpkg 4.0.1
|
||||
***********
|
||||
|
||||
Slpkg is a powerful software package manager that installs, updates, and removes packages on
|
||||
|
@ -35,9 +35,9 @@ Install from the official third party `SBo repository <https://slackbuilds.org/r
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ wget slpkg-4.0.0.tar.gz
|
||||
$ tar xvf slpkg-4.0.0.tar.gz
|
||||
$ cd slpkg-4.0.0
|
||||
$ wget slpkg-4.0.1.tar.gz
|
||||
$ tar xvf slpkg-4.0.1.tar.gz
|
||||
$ cd slpkg-4.0.1
|
||||
$ ./install.sh
|
||||
|
||||
|
||||
|
|
4
clean.py
4
clean.py
|
@ -39,6 +39,7 @@ class Clean:
|
|||
"/etc/bash_completion.d/slpkg.bash-completion",
|
||||
"/etc/fish/completions/slpkg.fish"
|
||||
]
|
||||
|
||||
self.dirs = [
|
||||
"/etc/slpkg/",
|
||||
"/var/log/slpkg/",
|
||||
|
@ -48,10 +49,13 @@ class Clean:
|
|||
|
||||
def start(self):
|
||||
for f in self.files:
|
||||
|
||||
if os.path.isfile(f):
|
||||
print(f"Remove file --> {f}")
|
||||
os.remove(f)
|
||||
|
||||
for d in self.dirs:
|
||||
|
||||
if os.path.exists(d):
|
||||
print(f"Remove directory --> {d}")
|
||||
shutil.rmtree(d)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# GNU coreutils
|
||||
# sqlite3
|
||||
# progress
|
||||
# SQLAlchemy
|
||||
#
|
||||
# [OPTIONAL]
|
||||
# aria2 (alternative downloader)
|
||||
|
|
5
setup.py
5
setup.py
|
@ -33,7 +33,10 @@ except ImportError:
|
|||
|
||||
docs_requires = []
|
||||
tests_requires = []
|
||||
install_requires = ["progress>=1.6"]
|
||||
install_requires = [
|
||||
"SQLAlchemy>=1.4.36",
|
||||
"progress>=1.6"
|
||||
]
|
||||
optional_requires = [
|
||||
"pythondialog>=3.5.1",
|
||||
"pygraphviz>=1.3.1"
|
||||
|
|
|
@ -77,7 +77,7 @@ class MetaData:
|
|||
|
||||
__all__ = "slpkg"
|
||||
__author__ = "dslackw"
|
||||
__version_info__ = (4, 0, 0)
|
||||
__version_info__ = (4, 0, 1)
|
||||
__version__ = "{0}.{1}.{2}".format(*__version_info__)
|
||||
__license__ = "GNU General Public License v3 (GPLv3)"
|
||||
__email__ = "d.zlatanidis@gmail.com"
|
||||
|
@ -238,7 +238,7 @@ class MetaData:
|
|||
slackpkg_lib_path = "/var/lib/slackpkg/"
|
||||
|
||||
# database name
|
||||
db = "/database/database.slpkg"
|
||||
db = "database/database.slpkg"
|
||||
|
||||
# computer architecture
|
||||
if comp_arch in ["off", "OFF"]:
|
||||
|
|
|
@ -48,32 +48,42 @@ class AutoInstall:
|
|||
"""Select Slackware command
|
||||
"""
|
||||
print("\nDetected Slackware binary package for installation:\n")
|
||||
|
||||
for pkg in self.packages:
|
||||
print(" " + pkg.split("/")[-1])
|
||||
|
||||
print()
|
||||
|
||||
self.msg.template(78)
|
||||
print("| Choose a Slackware command:")
|
||||
self.msg.template(78)
|
||||
|
||||
for com in sorted(self.commands):
|
||||
print(f"| {self.red}{com}{self.endc}) {self.green}"
|
||||
f"{self.commands[com]}{self.endc}")
|
||||
|
||||
self.msg.template(78)
|
||||
|
||||
try:
|
||||
self.choice = input(" > ")
|
||||
except EOFError:
|
||||
raise SystemExit("\n")
|
||||
|
||||
if self.choice in self.commands.keys():
|
||||
print(f" \x1b[1A{self.cyan}{self.commands[self.choice]}"
|
||||
f"{self.endc}", end="\n\n")
|
||||
print(end="", flush=True)
|
||||
|
||||
self.execute()
|
||||
|
||||
def execute(self):
|
||||
"""Executes Slackware command
|
||||
"""
|
||||
if self.choice in self.commands.keys():
|
||||
|
||||
if self.choice == "i":
|
||||
PackageManager(self.packages).install("")
|
||||
|
||||
elif self.choice in ["u", "r"]:
|
||||
PackageManager(self.packages).upgrade(
|
||||
self.commands[self.choice][11:])
|
||||
|
|
|
@ -42,25 +42,33 @@ def pkg_upgrade(repo, skip, flag):
|
|||
msg.checking()
|
||||
PACKAGES_TXT = RepoInit(repo).fetch()[0]
|
||||
pkgs_for_upgrade = []
|
||||
|
||||
# name = data[0]
|
||||
# location = data[1]
|
||||
# size = data[2]
|
||||
# unsize = data[3]
|
||||
data = repo_data(PACKAGES_TXT, repo, flag="")
|
||||
|
||||
for pkg in installed():
|
||||
inst_pkg = split_package(pkg)
|
||||
|
||||
for name in data[0]:
|
||||
|
||||
if name: # this tips because some pkg_name is empty
|
||||
repo_pkg = split_package(name[:-4])
|
||||
|
||||
if (repo_pkg[0] == inst_pkg[0] and
|
||||
parse_version(repo_pkg[1]) > parse_version(inst_pkg[1]) and
|
||||
repo_pkg[3] >= inst_pkg[3] and
|
||||
inst_pkg[0] not in skip and
|
||||
repo_pkg[1] != "blacklist"):
|
||||
pkgs_for_upgrade.append(repo_pkg[0])
|
||||
|
||||
msg.done()
|
||||
|
||||
if "--checklist" in flag:
|
||||
pkgs_for_upgrade = choose_upg(pkgs_for_upgrade)
|
||||
|
||||
return pkgs_for_upgrade
|
||||
|
||||
|
||||
|
|
|
@ -46,12 +46,18 @@ class Dependencies:
|
|||
sys.setrecursionlimit(10000)
|
||||
dependencies = []
|
||||
requires = Requires(name, self.repo).get_deps()
|
||||
|
||||
if requires:
|
||||
|
||||
for req in requires:
|
||||
|
||||
if req and req not in self.black:
|
||||
dependencies.append(req)
|
||||
|
||||
self.deep_check(tuple(dependencies), tuple(flag))
|
||||
|
||||
return self.dep_results
|
||||
|
||||
else:
|
||||
return []
|
||||
|
||||
|
|
|
@ -35,13 +35,18 @@ def repo_data(PACKAGES_TXT, repo, flag):
|
|||
"""
|
||||
(name, location, size, unsize,
|
||||
rname, rlocation, rsize, runsize) = ([] for i in range(8))
|
||||
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
name.append(line[15:].strip())
|
||||
|
||||
if line.startswith("PACKAGE LOCATION:"):
|
||||
location.append(line[21:].strip())
|
||||
|
||||
if line.startswith("PACKAGE SIZE (compressed):"):
|
||||
size.append(line[28:-2].strip())
|
||||
|
||||
if line.startswith("PACKAGE SIZE (uncompressed):"):
|
||||
unsize.append(line[30:-2].strip())
|
||||
|
||||
|
@ -51,32 +56,38 @@ def repo_data(PACKAGES_TXT, repo, flag):
|
|||
rsize,
|
||||
runsize
|
||||
) = slack_filter(name, location, size, unsize, flag)
|
||||
|
||||
elif repo == "rlw":
|
||||
(rname,
|
||||
rlocation,
|
||||
rsize,
|
||||
runsize
|
||||
) = rlw_filter(name, location, size, unsize)
|
||||
|
||||
elif repo == "alien":
|
||||
(rname,
|
||||
rlocation,
|
||||
rsize,
|
||||
runsize
|
||||
) = alien_filter(name, location, size, unsize)
|
||||
|
||||
elif repo == "rested":
|
||||
(rname,
|
||||
rlocation,
|
||||
rsize,
|
||||
runsize
|
||||
) = rested_filter(name, location, size, unsize)
|
||||
|
||||
elif repo == "ktown":
|
||||
(rname,
|
||||
rlocation,
|
||||
rsize,
|
||||
runsize
|
||||
) = ktown_filter(name, location, size, unsize)
|
||||
|
||||
else:
|
||||
rname, rlocation, rsize, runsize = name, location, size, unsize
|
||||
|
||||
return [rname, rlocation, rsize, runsize]
|
||||
|
||||
|
||||
|
@ -86,7 +97,9 @@ def slack_filter(name, location, size, unsize, flag):
|
|||
(fname, flocation, fsize, funsize) = ([] for i in range(4))
|
||||
|
||||
if "--patches" not in flag:
|
||||
|
||||
for n, l, s, u in zip(name, location, size, unsize):
|
||||
|
||||
if f"_slack{slack_ver()}" not in n:
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
|
@ -94,7 +107,9 @@ def slack_filter(name, location, size, unsize, flag):
|
|||
funsize.append(u)
|
||||
|
||||
if "--patches" in flag:
|
||||
|
||||
for n, l, s, u in zip(name, location, size, unsize):
|
||||
|
||||
if f"_slack{slack_ver()}" in n:
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
|
@ -108,16 +123,22 @@ def rlw_filter(name, location, size, unsize):
|
|||
"""Filter rlw repository data
|
||||
"""
|
||||
arch = _meta_.arch
|
||||
|
||||
if arch.startswith("i") and arch.endswith("86"):
|
||||
arch = "i486"
|
||||
|
||||
(fname, flocation, fsize, funsize) = ([] for i in range(4))
|
||||
|
||||
for n, l, s, u in zip(name, location, size, unsize):
|
||||
|
||||
loc = l.split("/")
|
||||
|
||||
if arch == loc[-1]:
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
fsize.append(s)
|
||||
funsize.append(u)
|
||||
|
||||
return [fname, flocation, fsize, funsize]
|
||||
|
||||
|
||||
|
@ -125,12 +146,15 @@ def alien_filter(name, location, size, unsize):
|
|||
"""Fix to avoid packages include in slackbuilds folder
|
||||
"""
|
||||
(fname, flocation, fsize, funsize) = ([] for i in range(4))
|
||||
|
||||
for n, l, s, u in zip(name, location, size, unsize):
|
||||
|
||||
if "slackbuilds" != l:
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
fsize.append(s)
|
||||
funsize.append(u)
|
||||
|
||||
return [fname, flocation, fsize, funsize]
|
||||
|
||||
|
||||
|
@ -140,16 +164,22 @@ def rested_filter(name, location, size, unsize):
|
|||
ver = slack_ver()
|
||||
if _meta_.slack_rel == "current":
|
||||
ver = "current"
|
||||
|
||||
path_pkg = "pkg"
|
||||
|
||||
if _meta_.arch == "x86_64":
|
||||
path_pkg = "pkg64"
|
||||
|
||||
(fname, flocation, fsize, funsize) = ([] for i in range(4))
|
||||
|
||||
for n, l, s, u in zip(name, location, size, unsize):
|
||||
|
||||
if path_pkg == l.split("/")[-2] and ver == l.split("/")[-1]:
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
fsize.append(s)
|
||||
funsize.append(u)
|
||||
|
||||
return [fname, flocation, fsize, funsize]
|
||||
|
||||
|
||||
|
@ -157,19 +187,26 @@ def ktown_filter(name, location, size, unsize):
|
|||
"""Filter Alien"s ktown repository data
|
||||
"""
|
||||
ver = slack_ver()
|
||||
|
||||
if _meta_.slack_rel == "current":
|
||||
ver = "current"
|
||||
|
||||
path_pkg = "x86"
|
||||
|
||||
if _meta_.arch == "x86_64":
|
||||
path_pkg = _meta_.arch
|
||||
|
||||
(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 _meta_.ktown_kde_repo[1:-1] in l and
|
||||
l.startswith(ver)):
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
fsize.append(s)
|
||||
funsize.append(u)
|
||||
|
||||
return [fname, flocation, fsize, funsize]
|
||||
|
||||
|
||||
|
@ -183,24 +220,35 @@ class Requires:
|
|||
"""Grabs package requirements from repositories
|
||||
"""
|
||||
if self.repo == "rlw":
|
||||
|
||||
dependencies = {}
|
||||
rlw_deps = Utils().read_file(_meta_.conf_path + "rlworkman.deps")
|
||||
|
||||
for line in rlw_deps.splitlines():
|
||||
|
||||
if line and not line.startswith("#"):
|
||||
pkgs = line.split(":")
|
||||
dependencies[pkgs[0]] = pkgs[1]
|
||||
|
||||
if self.name in dependencies.keys():
|
||||
return dependencies[self.name].split()
|
||||
|
||||
else:
|
||||
return ""
|
||||
|
||||
else:
|
||||
PACKAGES_TXT = Utils().read_file(f"{_meta_.lib_path}"
|
||||
f"{self.repo}_repo/PACKAGES.TXT")
|
||||
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
pkg_name = split_package(line[14:].strip())[0]
|
||||
|
||||
if line.startswith("PACKAGE REQUIRED:"):
|
||||
|
||||
if pkg_name == self.name:
|
||||
|
||||
if line[18:].strip():
|
||||
return self._req_fix(line)
|
||||
|
||||
|
@ -210,17 +258,27 @@ class Requires:
|
|||
splitting with "," and others with "|"
|
||||
"""
|
||||
deps = []
|
||||
|
||||
for dep in line[18:].strip().split(","):
|
||||
dep = dep.split("|")
|
||||
|
||||
if self.repo == "slacky":
|
||||
|
||||
if len(dep) > 1:
|
||||
|
||||
for d in dep:
|
||||
deps.append(d.split()[0])
|
||||
|
||||
dep = "".join(dep)
|
||||
deps.append(dep.split()[0])
|
||||
|
||||
else:
|
||||
|
||||
if len(dep) > 1:
|
||||
|
||||
for d in dep:
|
||||
deps.append(d)
|
||||
|
||||
deps.append(dep[0])
|
||||
|
||||
return deps
|
||||
|
|
|
@ -79,8 +79,10 @@ class BinaryInstall(BlackList, Utils):
|
|||
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
|
||||
self.data = repo_data(self.PACKAGES_TXT, self.repo, self.flag)
|
||||
self.repo_pkg_names = []
|
||||
|
||||
for name in self.data[0]:
|
||||
self.repo_pkg_names.append(split_package(name)[0])
|
||||
|
||||
self.blacklist = list(self.get_black())
|
||||
self.matching = False
|
||||
|
||||
|
@ -88,8 +90,10 @@ class BinaryInstall(BlackList, Utils):
|
|||
"""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 += "/"
|
||||
|
||||
|
@ -103,37 +107,51 @@ class BinaryInstall(BlackList, Utils):
|
|||
self.msg.done()
|
||||
self.dependencies = self.resolving_deps()
|
||||
self.update_deps()
|
||||
|
||||
(self.dep_dwn, self.dep_install, self.dep_comp_sum,
|
||||
self.dep_uncomp_sum) = self.store(self.dependencies)
|
||||
|
||||
self.clear_masters()
|
||||
|
||||
(self.dwn, self.install, self.comp_sum,
|
||||
self.uncomp_sum) = self.store(self.packages)
|
||||
|
||||
if (self.meta.rsl_deps in ["on", "ON"] and
|
||||
"--resolve-off" not in self.flag):
|
||||
self.msg.done()
|
||||
|
||||
if self.install:
|
||||
|
||||
if self.matching and [""] != self.packages:
|
||||
self.msg.matching(self.packages)
|
||||
|
||||
else:
|
||||
print("\nThe following packages will be automatically "
|
||||
"installed or upgraded \nwith new version:\n")
|
||||
self.top_view()
|
||||
|
||||
self.msg.upg_inst(self.is_upgrade)
|
||||
|
||||
mas_sum = self.views(self.install, self.comp_sum)
|
||||
|
||||
if self.dependencies:
|
||||
print("Installing for dependencies:")
|
||||
dep_sum = self.views(self.dep_install, self.dep_comp_sum)
|
||||
|
||||
# sums[0] --> total packages
|
||||
# sums[1] --> reinstall
|
||||
# sums[2] --> upgraded
|
||||
# sums[3] --> uninstall
|
||||
|
||||
sums = [sum(s) for s in zip_longest(mas_sum, dep_sum)]
|
||||
unit, size = units(self.comp_sum + self.dep_comp_sum,
|
||||
self.uncomp_sum + self.dep_uncomp_sum)
|
||||
|
||||
if self.matching and [""] != self.packages:
|
||||
print("\nMatching summary")
|
||||
print("=" * 79)
|
||||
raise SystemExit(f"Total {sums[0]} matching packages\n")
|
||||
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print(f"{self.grey}Total {sums[0]} {self.msg.pkg(sums[0])}.")
|
||||
|
@ -143,32 +161,46 @@ class BinaryInstall(BlackList, Utils):
|
|||
print(f"Need to get {size[0]} {unit[0]} of archives.")
|
||||
print(f"After this process, {size[1]} {unit[1]} of additional "
|
||||
f"disk space will be used.{self.endc}")
|
||||
|
||||
print()
|
||||
|
||||
self.if_all_installed()
|
||||
|
||||
if self.msg.answer() in ["y", "Y"]:
|
||||
|
||||
for inst, dwn in zip(self.dep_install + self.install,
|
||||
self.dep_dwn + self.dwn):
|
||||
|
||||
if (self.meta.not_downgrade == "on" and
|
||||
self.not_downgrade(inst) is True):
|
||||
continue
|
||||
|
||||
if (not os.path.isfile(self.meta.pkg_path + inst[:-4]) or
|
||||
"--download-only" in self.flag or
|
||||
"--reinstall" in self.flag):
|
||||
Download(self.tmp_path, dwn.split(), self.repo).start()
|
||||
|
||||
else:
|
||||
self.msg.template(78)
|
||||
self.msg.pkg_found(inst)
|
||||
self.msg.template(78)
|
||||
|
||||
if "--download-only" in self.flag:
|
||||
raise SystemExit()
|
||||
|
||||
self.dep_install = list(self.check_downloaded(
|
||||
self.tmp_path, self.dep_install))
|
||||
|
||||
self.install = list(self.check_downloaded(
|
||||
self.tmp_path, self.install))
|
||||
|
||||
ins, upg = self.install_packages()
|
||||
|
||||
self.msg.reference(ins, upg)
|
||||
|
||||
write_deps(self.deps_dict)
|
||||
delete_package(self.tmp_path, self.dep_install + self.install)
|
||||
|
||||
else:
|
||||
self.msg.not_found(self.is_upgrade)
|
||||
raise SystemExit(1)
|
||||
|
@ -177,10 +209,13 @@ class BinaryInstall(BlackList, Utils):
|
|||
"""Checks if all packages is already installed
|
||||
"""
|
||||
count_inst = 0
|
||||
|
||||
for inst in (self.dep_install + self.install):
|
||||
|
||||
if (os.path.isfile(self.meta.pkg_path + inst[:-4]) and
|
||||
"--download-only" not in self.flag):
|
||||
count_inst += 1
|
||||
|
||||
if (count_inst == len(self.dep_install + self.install) and
|
||||
"--reinstall" not in self.flag):
|
||||
raise SystemExit()
|
||||
|
@ -192,9 +227,12 @@ class BinaryInstall(BlackList, Utils):
|
|||
if "--case-ins" in self.flag:
|
||||
data = list(self.package_name(self.PACKAGES_TXT))
|
||||
data_dict = self.case_sensitive(data)
|
||||
|
||||
for pkg in self.packages:
|
||||
index = self.packages.index(pkg)
|
||||
|
||||
for key, value in data_dict.items():
|
||||
|
||||
if key == pkg.lower():
|
||||
self.packages[index] = value
|
||||
|
||||
|
@ -205,6 +243,7 @@ class BinaryInstall(BlackList, Utils):
|
|||
deps = self.dimensional_list(Dependencies(
|
||||
self.repo, self.blacklist).binary(
|
||||
dep, self.flag))
|
||||
|
||||
self.deps_dict[dep] = deps
|
||||
|
||||
def clear_masters(self):
|
||||
|
@ -213,8 +252,10 @@ class BinaryInstall(BlackList, Utils):
|
|||
"""
|
||||
packages = []
|
||||
for mas in self.remove_dbs(self.packages):
|
||||
|
||||
if mas not in self.dependencies:
|
||||
packages.append(mas)
|
||||
|
||||
self.packages = packages
|
||||
|
||||
def install_packages(self):
|
||||
|
@ -225,17 +266,22 @@ class BinaryInstall(BlackList, Utils):
|
|||
package = (self.tmp_path + inst).split()
|
||||
pkg_ver = f"{split_package(inst)[0]}-{split_package(inst)[1]}"
|
||||
self.checksums(inst)
|
||||
|
||||
if GetFromInstalled(split_package(inst)[0]).name():
|
||||
print(f"[ {self.yellow}upgrading{self.endc} ] --> {inst}")
|
||||
upgraded.append(pkg_ver)
|
||||
|
||||
if "--reinstall" in self.flag:
|
||||
PackageManager(package).upgrade("--reinstall")
|
||||
|
||||
else:
|
||||
PackageManager(package).upgrade("--install-new")
|
||||
|
||||
else:
|
||||
print(f"[ {self.green}installing{self.endc} ] --> {inst}")
|
||||
installs.append(pkg_ver)
|
||||
PackageManager(package).upgrade("--install-new")
|
||||
|
||||
return [installs, upgraded]
|
||||
|
||||
def not_downgrade(self, package):
|
||||
|
@ -244,8 +290,10 @@ class BinaryInstall(BlackList, Utils):
|
|||
name = split_package(package)[0]
|
||||
rep_ver = split_package(package)[1]
|
||||
ins_ver = GetFromInstalled(name).version()
|
||||
|
||||
if not ins_ver:
|
||||
ins_ver = "0"
|
||||
|
||||
if parse_version(rep_ver) < parse_version(ins_ver):
|
||||
self.msg.template(78)
|
||||
print(f"| Package {name} does not downgrade, setting by user")
|
||||
|
@ -261,21 +309,25 @@ class BinaryInstall(BlackList, Utils):
|
|||
"""Returns package dependencies
|
||||
"""
|
||||
requires = []
|
||||
|
||||
if (self.meta.rsl_deps in ["on", "ON"] and
|
||||
self.flag != "--resolve-off"):
|
||||
self.msg.resolving()
|
||||
|
||||
for dep in self.packages:
|
||||
dependencies = []
|
||||
dependencies = self.dimensional_list(Dependencies(
|
||||
self.repo, self.blacklist).binary(dep, self.flag))
|
||||
requires += list(self._fix_deps_repos(dependencies))
|
||||
self.deps_dict[dep] = self.remove_dbs(requires)
|
||||
|
||||
return self.remove_dbs(requires)
|
||||
|
||||
def _fix_deps_repos(self, dependencies):
|
||||
"""Fixes store deps include in the repository
|
||||
"""
|
||||
for dep in dependencies:
|
||||
|
||||
if dep in self.repo_pkg_names:
|
||||
yield dep
|
||||
|
||||
|
@ -289,24 +341,32 @@ class BinaryInstall(BlackList, Utils):
|
|||
for pkg, comp in zip(install, comp_sum):
|
||||
pkg_sum += 1
|
||||
pkg_repo = split_package(pkg[:-4])
|
||||
|
||||
if find_package(pkg[:-4], self.meta.pkg_path):
|
||||
|
||||
if "--reinstall" in self.flag:
|
||||
res_sum += 1
|
||||
COLOR = self.meta.color["GREEN"]
|
||||
|
||||
elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name():
|
||||
COLOR = self.meta.color["YELLOW"]
|
||||
upg_sum += 1
|
||||
|
||||
else:
|
||||
COLOR = self.meta.color["RED"]
|
||||
uni_sum += 1
|
||||
|
||||
ver = GetFromInstalled(pkg_repo[0]).version()
|
||||
|
||||
if ver:
|
||||
ver = f"-{ver}"
|
||||
|
||||
print(f" {COLOR}{pkg_repo[0] + ver}{self.endc}"
|
||||
f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}"
|
||||
f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}"
|
||||
f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}"
|
||||
f"{' ' * (7-len(pkg_repo[3]))}{repo}{comp:>11}{' K'}")
|
||||
|
||||
return [pkg_sum, res_sum, upg_sum, uni_sum]
|
||||
|
||||
def top_view(self):
|
||||
|
@ -321,13 +381,17 @@ class BinaryInstall(BlackList, Utils):
|
|||
"""Stores and returns packages for install
|
||||
"""
|
||||
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
|
||||
|
||||
# name = data[0]
|
||||
# location = data[1]
|
||||
# size = data[2]
|
||||
# unsize = data[3]
|
||||
|
||||
for pkg in packages:
|
||||
|
||||
for pk, loc, comp, uncomp in zip(self.data[0], self.data[1],
|
||||
self.data[2], self.data[3]):
|
||||
|
||||
if (pk and pkg == split_package(pk)[0] and
|
||||
pk not in install and
|
||||
split_package(pk)[0] not in self.blacklist):
|
||||
|
@ -337,10 +401,13 @@ class BinaryInstall(BlackList, Utils):
|
|||
uncomp_sum.append(uncomp)
|
||||
|
||||
if not install:
|
||||
|
||||
for pkg in packages:
|
||||
|
||||
for pk, loc, comp, uncomp in zip(self.data[0], self.data[1],
|
||||
self.data[2], self.data[3]):
|
||||
name = split_package(pk)[0]
|
||||
|
||||
if (pk and pkg in name and name not in self.blacklist):
|
||||
self.matching = True
|
||||
dwn.append(f"{self.mirror}{loc}/{pk}")
|
||||
|
|
|
@ -42,8 +42,10 @@ class RepoInit(Utils):
|
|||
def fetch(self):
|
||||
if self.repo in self.meta.default_repositories:
|
||||
getattr(self, f"_init_{self.repo}")()
|
||||
|
||||
else:
|
||||
self._init_custom()
|
||||
|
||||
self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT"
|
||||
PACKAGES_TXT = self.read_file(self.lib)
|
||||
return PACKAGES_TXT, self.mirror
|
||||
|
@ -63,14 +65,17 @@ class RepoInit(Utils):
|
|||
arch = "x86"
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = "x86_64"
|
||||
|
||||
if self.meta.slack_rel == "current":
|
||||
ver = self.meta.slack_rel
|
||||
|
||||
self.mirror = f"{self.def_repo_dict['alien']}{ver}/{arch}/"
|
||||
|
||||
def _init_slacky(self):
|
||||
arch = ""
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = "64"
|
||||
|
||||
self.mirror = f"{self.def_repo_dict}slackware{arch}-{slack_ver()}/"
|
||||
|
||||
def _init_conrad(self):
|
||||
|
@ -81,11 +86,15 @@ class RepoInit(Utils):
|
|||
arch = f"{ver}-x86"
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = f"{ver}-x86_64"
|
||||
|
||||
if self.meta.slack_rel == "current":
|
||||
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = f"{self.meta.slack_rel}-x86_64"
|
||||
|
||||
else:
|
||||
arch = f"{self.meat.slack_rel}-x86"
|
||||
|
||||
self.mirror = f"{self.def_repo_dict['slonly']}{arch}/"
|
||||
|
||||
def _init_ktown(self):
|
||||
|
@ -95,12 +104,14 @@ class RepoInit(Utils):
|
|||
ver = slack_ver()
|
||||
if self.meta.slack_rel == "current":
|
||||
ver = self.meta.slack_rel
|
||||
|
||||
self.mirror = self.def_repo_dict["multi"] + ver + "/"
|
||||
|
||||
def _init_slacke(self):
|
||||
arch = ""
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = "64"
|
||||
|
||||
self.mirror = (f"{self.def_repo_dict['slacke']}"
|
||||
f"slacke{self.meta.slacke_sub_repo[1:-1]}/slackware"
|
||||
f"{arch}-{slack_ver()}/")
|
||||
|
@ -109,12 +120,14 @@ class RepoInit(Utils):
|
|||
arch = "i486"
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = "x86_64"
|
||||
|
||||
self.mirror = f"{self.def_repo_dict['salix']}{arch}/{slack_ver()}/"
|
||||
|
||||
def _init_slackl(self):
|
||||
arch = "i486"
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = "x86_64"
|
||||
|
||||
self.mirror = f"{self.def_repo_dict['slackl']}{arch}/current/"
|
||||
|
||||
def _init_rested(self):
|
||||
|
@ -131,6 +144,7 @@ class RepoInit(Utils):
|
|||
arch = "x86"
|
||||
if self.meta.arch == "x86_64":
|
||||
arch = "x86_64"
|
||||
|
||||
self.mirror = f"{self.def_repo_dict['csb']}{slack_ver()}/{arch}"
|
||||
|
||||
def _init_connos(self):
|
||||
|
|
|
@ -33,8 +33,11 @@ def search_pkg(name, repo):
|
|||
"""
|
||||
utils = Utils()
|
||||
black = BlackList()
|
||||
|
||||
text = utils.read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
|
||||
|
||||
PACKAGES_TXT = list(utils.package_name(text))
|
||||
blacklist = list(black.get_black())
|
||||
|
||||
if name in PACKAGES_TXT and name not in blacklist:
|
||||
return name
|
||||
return name
|
||||
|
|
|
@ -32,12 +32,14 @@ from slpkg.__metadata__ import MetaData as _meta_
|
|||
class BlackList(Utils):
|
||||
"""Blacklist class to add, remove or list packages
|
||||
in blacklist file."""
|
||||
|
||||
def __init__(self):
|
||||
self.green = _meta_.color["GREEN"]
|
||||
self.red = _meta_.color["RED"]
|
||||
self.endc = _meta_.color["ENDC"]
|
||||
self.blackfile = "/etc/slpkg/blacklist"
|
||||
self.black_conf = ""
|
||||
|
||||
if os.path.isfile(self.blackfile):
|
||||
self.black_conf = self.read_file(self.blackfile)
|
||||
|
||||
|
@ -48,10 +50,14 @@ class BlackList(Utils):
|
|||
installed = os.listdir("/var/log/packages/")
|
||||
|
||||
for black in blacklist:
|
||||
|
||||
if black.endswith("*"):
|
||||
|
||||
for inst in installed:
|
||||
|
||||
if inst.startswith(black[:-1]):
|
||||
yield split_package(inst)[0]
|
||||
|
||||
else:
|
||||
yield black
|
||||
|
||||
|
@ -60,7 +66,9 @@ class BlackList(Utils):
|
|||
by the name
|
||||
"""
|
||||
for read in self.black_conf.splitlines():
|
||||
|
||||
read = read.lstrip()
|
||||
|
||||
if not read.startswith("#"):
|
||||
yield read.replace("\n", "")
|
||||
|
||||
|
@ -78,9 +86,13 @@ class BlackList(Utils):
|
|||
"""
|
||||
blacklist = list(self.black_filter())
|
||||
pkgs = set(pkgs)
|
||||
|
||||
print("Add packages in the blacklist:")
|
||||
|
||||
with open(self.blackfile, "a") as black_conf:
|
||||
|
||||
for pkg in pkgs:
|
||||
|
||||
if pkg not in blacklist:
|
||||
print(f"{self.green}{pkg}{self.endc}")
|
||||
black_conf.write(pkg + "\n")
|
||||
|
@ -90,10 +102,14 @@ class BlackList(Utils):
|
|||
"""Removes packages from blacklist
|
||||
"""
|
||||
print("Remove packages from the blacklist:")
|
||||
|
||||
with open(self.blackfile, "w") as remove:
|
||||
|
||||
for line in self.black_conf.splitlines():
|
||||
|
||||
if line not in pkgs:
|
||||
remove.write(line + "\n")
|
||||
|
||||
else:
|
||||
print(f"{self.red}{line}{self.endc}")
|
||||
print()
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
from slpkg.messages import Msg
|
||||
from slpkg.arguments import usage
|
||||
from slpkg.init import Initialization
|
||||
from slpkg.init import Init
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
|
||||
|
||||
|
@ -41,7 +41,8 @@ class Updates:
|
|||
self.st = ""
|
||||
self.count_repo = 0
|
||||
self.count_news = 0
|
||||
self._init = Initialization(True)
|
||||
self._init = Init(True)
|
||||
|
||||
self.all_repos = {
|
||||
"slack": self._init.slack,
|
||||
"sbo": self._init.sbo,
|
||||
|
@ -74,14 +75,18 @@ class Updates:
|
|||
"""
|
||||
if (self.repo in self.meta.default_repositories and
|
||||
self.repo in self.meta.repositories):
|
||||
|
||||
try:
|
||||
self.check = self.all_repos[self.repo]()
|
||||
except OSError:
|
||||
usage(self.repo, 1)
|
||||
|
||||
elif self.repo in self.meta.repositories:
|
||||
self.check = self._init.custom(self.repo)
|
||||
|
||||
else:
|
||||
usage(self.repo, 1)
|
||||
|
||||
self.status_bar()
|
||||
self.status()
|
||||
self.print_status(self.repo)
|
||||
|
@ -91,25 +96,34 @@ class Updates:
|
|||
"""Check ALL enabled repositories ChangeLogs
|
||||
"""
|
||||
self.status_bar()
|
||||
|
||||
for repo in self.meta.repositories:
|
||||
|
||||
if repo in self.meta.default_repositories:
|
||||
|
||||
try:
|
||||
self.check = self.all_repos[repo]()
|
||||
|
||||
except OSError:
|
||||
usage(self.repo, 1)
|
||||
|
||||
elif repo in self.meta.repositories:
|
||||
self.check = self._init.custom(repo)
|
||||
|
||||
self.status()
|
||||
self.print_status(repo)
|
||||
|
||||
self.summary()
|
||||
|
||||
def status(self):
|
||||
"""Set messages
|
||||
"""
|
||||
self.count_repo += 1
|
||||
|
||||
if self.check == 1:
|
||||
self.count_news += 1
|
||||
self.st = f"{self.green}News in ChangeLog.txt{self.endc}"
|
||||
|
||||
elif self.check == 0:
|
||||
self.st = "No changes in ChangeLog.txt"
|
||||
|
||||
|
@ -123,10 +137,14 @@ class Updates:
|
|||
"""
|
||||
print("\nSummary")
|
||||
print("=" * 79)
|
||||
|
||||
cmd = "All repositories are updated."
|
||||
|
||||
if self.count_repo == 1:
|
||||
cmd = "Repository is updated."
|
||||
|
||||
if self.count_news > 0:
|
||||
cmd = "Run the command 'slpkg update'."
|
||||
|
||||
print(f"From {self.count_repo} repositories need"
|
||||
f" {self.count_news} updating. {cmd}", end="\n")
|
||||
|
|
|
@ -34,23 +34,37 @@ def check_md5(pkg_md5, src_file):
|
|||
red = _meta_.color["RED"]
|
||||
green = _meta_.color["GREEN"]
|
||||
endc = _meta_.color["ENDC"]
|
||||
|
||||
if _meta_.checkmd5 in ["on", "ON"]:
|
||||
|
||||
print()
|
||||
|
||||
md5s = md5(src_file)
|
||||
|
||||
if pkg_md5 != md5s:
|
||||
|
||||
msg.template(78)
|
||||
|
||||
print(f"| MD5SUM check for {src_file.split('/')[-1]}"
|
||||
f" [ {red}FAILED{endc} ]")
|
||||
|
||||
msg.template(78)
|
||||
|
||||
print(f"| Expected: {pkg_md5}")
|
||||
print(f"| Found: {md5s}")
|
||||
|
||||
msg.template(78)
|
||||
|
||||
print()
|
||||
|
||||
if not msg.answer() in ["y", "Y"]:
|
||||
raise SystemExit()
|
||||
else:
|
||||
msg.template(78)
|
||||
|
||||
print(f"| MD5SUM check for {src_file.split('/')[-1]}"
|
||||
f" [ {green}PASSED{endc} ]")
|
||||
|
||||
msg.template(78)
|
||||
|
||||
print() # new line after pass checksum
|
||||
|
|
|
@ -36,13 +36,17 @@ def clean_tmp():
|
|||
_meta_.slpkg_tmp_packages, # /tmp/slpkg/packages/
|
||||
_meta_.slpkg_tmp_patches # /tmp/slpkg/patches/
|
||||
]
|
||||
|
||||
# Delete a whole slpkg folder from the tmp directory
|
||||
if os.path.exists(tmps[0]):
|
||||
shutil.rmtree(tmps[0])
|
||||
print(f"All packages and sources were deleted from: {tmps[0]}")
|
||||
|
||||
# Recreate the paths again
|
||||
if not os.path.exists(tmps[0]):
|
||||
|
||||
for tmp in tmps:
|
||||
os.mkdir(tmp)
|
||||
print(f"Created directory: {tmp}")
|
||||
|
||||
print("Done!")
|
||||
|
|
|
@ -70,10 +70,14 @@ class Config(Utils):
|
|||
"NOT_DOWNGRADE",
|
||||
"HTTP_PROXY",
|
||||
]
|
||||
|
||||
read_conf = self.read_file(self.config_file)
|
||||
|
||||
for line in read_conf.splitlines():
|
||||
|
||||
if not line.startswith("#") and line.split("=")[0] in conf_args:
|
||||
print(line)
|
||||
|
||||
else:
|
||||
print(f"{self.cyan}{line}{self.endc}", end="\n")
|
||||
|
||||
|
@ -86,7 +90,9 @@ class Config(Utils):
|
|||
"""Reset slpkg.conf file with default values
|
||||
"""
|
||||
shutil.copy2(f"{self.config_file}.orig", self.config_file)
|
||||
|
||||
if filecmp.cmp(f"{self.config_file}.orig", self.config_file):
|
||||
print(f"{self.green}The reset was done{self.endc}")
|
||||
|
||||
else:
|
||||
print(f"{self.red}Reset failed{self.endc}")
|
||||
print(f"{self.red}Reset failed{self.endc}")
|
||||
|
|
|
@ -47,6 +47,7 @@ class PkgDesc(Utils):
|
|||
"grey": self.meta.color["GREY"],
|
||||
"": ""
|
||||
}[self.paint]
|
||||
|
||||
if self.repo in self.meta.repositories and self.repo != "sbo":
|
||||
self.lib = f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT"
|
||||
|
||||
|
@ -54,17 +55,24 @@ class PkgDesc(Utils):
|
|||
"""Prints package description by repository
|
||||
"""
|
||||
description, count = "", 0
|
||||
|
||||
if self.repo == "sbo":
|
||||
description = SBoGrep(self.name).description()
|
||||
|
||||
else:
|
||||
PACKAGES_TXT = self.read_file(self.lib)
|
||||
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
|
||||
if line.startswith(self.name + ":"):
|
||||
description += f"{line[len(self.name) + 2:]}\n"
|
||||
count += 1
|
||||
|
||||
if count == 11:
|
||||
break
|
||||
|
||||
if description:
|
||||
print(f"{self.color}{description}{self.meta.color['ENDC']}")
|
||||
|
||||
else:
|
||||
self.msg.pkg_not_found("", self.name, "No matching", "")
|
||||
self.msg.pkg_not_found("", self.name, "No matching", "")
|
||||
|
|
|
@ -45,20 +45,25 @@ class DialogUtil:
|
|||
from dialog import Dialog
|
||||
except ImportError as er:
|
||||
raise SystemExit(er)
|
||||
|
||||
self.d = Dialog(dialog="dialog", autowidgetsize=True)
|
||||
|
||||
def checklist(self):
|
||||
"""Runs dialog checklist
|
||||
"""
|
||||
choice = []
|
||||
|
||||
for item in self.data:
|
||||
choice.append((item, "", self.status))
|
||||
|
||||
code, self.tags = self.d.checklist(
|
||||
text=self.text, height=20, width=65, list_height=13,
|
||||
choices=choice, title=self.title, backtitle=self.backtitle)
|
||||
|
||||
if code == "ok":
|
||||
self.unicode_to_string()
|
||||
return self.ununicode
|
||||
|
||||
if code in ["cancel", "esc"]:
|
||||
self.exit()
|
||||
|
||||
|
@ -66,17 +71,23 @@ class DialogUtil:
|
|||
"""Runs dialog buildlist
|
||||
"""
|
||||
choice = []
|
||||
|
||||
for item in self.data:
|
||||
choice.append((item, False))
|
||||
|
||||
for item in enabled:
|
||||
choice.append((item, True))
|
||||
|
||||
items = [(tag, tag, sta) for (tag, sta) in choice]
|
||||
|
||||
code, self.tags = self.d.buildlist(
|
||||
text=self.text, items=items, visit_items=True, item_help=False,
|
||||
title=self.title)
|
||||
|
||||
if code == "ok":
|
||||
self.unicode_to_string()
|
||||
return self.ununicode
|
||||
|
||||
if code in ["cancel", "esc"]:
|
||||
self.exit()
|
||||
|
||||
|
|
|
@ -55,8 +55,11 @@ class Download(Utils):
|
|||
Optional curl, aria2c and httpie
|
||||
"""
|
||||
dwn_count = 1
|
||||
|
||||
self._directory_prefix()
|
||||
|
||||
for dwn in self.url:
|
||||
|
||||
self.file_name = self.fix_file_name(dwn.split("/")[-1])
|
||||
|
||||
if dwn.startswith("file:///"):
|
||||
|
@ -64,21 +67,27 @@ class Download(Utils):
|
|||
self._make_tarfile(self.file_name, source_dir)
|
||||
|
||||
self._check_certificate()
|
||||
|
||||
print(f"\n[{dwn_count}/{len(self.url)}][ {self.green}"
|
||||
f"Download{self.endc} ] --> {self.file_name}\n")
|
||||
|
||||
if self.downder in ["wget"]:
|
||||
subprocess.call(f"{self.downder} {self.downder_options}"
|
||||
f" {self.dir_prefix}{self.path} {dwn}",
|
||||
shell=True)
|
||||
|
||||
if self.downder in ["aria2c"]:
|
||||
subprocess.call(f"{self.downder} {self.downder_options}"
|
||||
f" {self.dir_prefix}{self.path[:-1]} {dwn}",
|
||||
shell=True)
|
||||
|
||||
elif self.downder in ["curl", "http"]:
|
||||
subprocess.call(f"{self.downder} {self.downder_options}"
|
||||
f" {self.path}{self.file_name} {dwn}",
|
||||
shell=True)
|
||||
|
||||
self._check_if_downloaded()
|
||||
|
||||
dwn_count += 1
|
||||
|
||||
def _make_tarfile(self, output_filename, source_dir):
|
||||
|
@ -92,6 +101,7 @@ class Download(Utils):
|
|||
"""
|
||||
if self.downder == "wget":
|
||||
self.dir_prefix = "--directory-prefix="
|
||||
|
||||
elif self.downder == "aria2c":
|
||||
self.dir_prefix = "--dir="
|
||||
|
||||
|
@ -99,12 +109,18 @@ class Download(Utils):
|
|||
"""Checks if file downloaded
|
||||
"""
|
||||
if not os.path.isfile(self.path + self.file_name):
|
||||
|
||||
print()
|
||||
|
||||
self.msg.template(78)
|
||||
|
||||
print(f"| Download '{self.file_name}' file"
|
||||
f" [ {self.red}FAILED{self.endc} ]")
|
||||
|
||||
self.msg.template(78)
|
||||
|
||||
print()
|
||||
|
||||
if not self.msg.answer() in ["y", "Y"]:
|
||||
raise SystemExit()
|
||||
|
||||
|
@ -115,11 +131,17 @@ class Download(Utils):
|
|||
self.downder == "wget"):
|
||||
certificate = (' --no-check-certificate --header="Cookie: '
|
||||
'oraclelicense=accept-securebackup-cookie"')
|
||||
|
||||
self.msg.template(78)
|
||||
|
||||
print(f"| '{certificate[:23].strip()}' need to go"
|
||||
f" ahead downloading")
|
||||
|
||||
self.msg.template(78)
|
||||
|
||||
print()
|
||||
|
||||
self.downder_options += certificate
|
||||
|
||||
if not self.msg.answer() in ["y", "Y"]:
|
||||
raise SystemExit()
|
||||
|
|
|
@ -34,8 +34,10 @@ class FileSize:
|
|||
def __init__(self, registry):
|
||||
self.meta = _meta_
|
||||
self.registry = registry
|
||||
|
||||
if self.meta.http_proxy:
|
||||
self.http = urllib3.ProxyManager(self.meta.http_proxy)
|
||||
|
||||
else:
|
||||
self.http = urllib3.PoolManager()
|
||||
|
||||
|
|
|
@ -52,24 +52,33 @@ class Graph:
|
|||
try:
|
||||
import pygraphviz as pgv
|
||||
except ImportError:
|
||||
|
||||
if (self.image == "ascii"
|
||||
and not os.path.isfile("/usr/bin/graph-easy")):
|
||||
print("Require 'grap_easy': "
|
||||
"Install with 'slpkg -s sbo graph-easy'")
|
||||
|
||||
else:
|
||||
raise SystemExit("Require 'pygraphviz: "
|
||||
"Install with 'slpkg -s sbo pygraphviz'")
|
||||
|
||||
if self.image != "ascii":
|
||||
self.check_file()
|
||||
|
||||
try:
|
||||
G = pgv.AGraph(deps_dict)
|
||||
|
||||
G.layout(prog="fdp")
|
||||
|
||||
if self.image == "ascii":
|
||||
G.write(f"{self.image}.dot")
|
||||
self.graph_easy()
|
||||
|
||||
G.draw(self.image)
|
||||
|
||||
except IOError:
|
||||
raise SystemExit(1)
|
||||
|
||||
if os.path.isfile(self.image):
|
||||
print(f"Graph image file '{self.image}' created")
|
||||
raise SystemExit()
|
||||
|
@ -79,6 +88,7 @@ class Graph:
|
|||
"""
|
||||
try:
|
||||
image_type = f".{self.image.split('.')[1]}"
|
||||
|
||||
if image_type not in self.file_format:
|
||||
raise SystemExit(f"Format: '{self.image.split('.')[1]}' not "
|
||||
f"recognized. Use one of them:\n"
|
||||
|
@ -90,12 +100,17 @@ class Graph:
|
|||
"""Drawing ascii diagram. graph-easy perl module requires
|
||||
"""
|
||||
if not os.path.isfile("/usr/bin/graph-easy"):
|
||||
|
||||
print("Require 'graph-easy': Install with 'slpkg -s sbo"
|
||||
" graph-easy'")
|
||||
self.remove_dot()
|
||||
|
||||
raise SystemExit(1)
|
||||
|
||||
subprocess.call(f"graph-easy {self.image}.dot", shell=True)
|
||||
|
||||
self.remove_dot()
|
||||
|
||||
raise SystemExit(1)
|
||||
|
||||
def remove_dot(self):
|
||||
|
|
|
@ -32,18 +32,25 @@ def pkg_checksum(binary, repo):
|
|||
"""Returns checksum from CHECKSUMS.md5 file by repository
|
||||
"""
|
||||
md5 = "None"
|
||||
|
||||
if repo == "slack_patches" and _meta_.slack_rel == "stable":
|
||||
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).get_request()
|
||||
|
||||
elif repo == "slack_patches" and _meta_.slack_rel == "current":
|
||||
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).get_request()
|
||||
|
||||
elif repo == "slpkg":
|
||||
CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).get_request()
|
||||
|
||||
else:
|
||||
lib = f"{_meta_.lib_path}{repo}_repo/CHECKSUMS.md5"
|
||||
f = open(lib, "r")
|
||||
CHECKSUMS_md5 = f.read()
|
||||
f.close()
|
||||
|
||||
for line in CHECKSUMS_md5.splitlines():
|
||||
|
||||
if line.endswith(f"/{binary}"):
|
||||
md5 = line.split()[0]
|
||||
|
||||
return md5
|
||||
|
|
|
@ -53,16 +53,20 @@ class PackageHealth:
|
|||
def check(self, line, pkg):
|
||||
line = line.replace("\n", "")
|
||||
try:
|
||||
|
||||
if (not line.endswith("/") and
|
||||
not line.endswith(".new") and
|
||||
not line.startswith("dev/") and
|
||||
not line.startswith("install/") and
|
||||
"/incoming/" not in line):
|
||||
|
||||
if not os.path.isfile(r"/" + line):
|
||||
self.cn += 1
|
||||
print(f"Not installed: {self.red}/{line}{self.endc} --> {pkg}")
|
||||
|
||||
elif not self.mode:
|
||||
print(line)
|
||||
|
||||
except IOError:
|
||||
raise SystemExit("\n")
|
||||
|
||||
|
@ -71,16 +75,23 @@ class PackageHealth:
|
|||
"""
|
||||
self.packages()
|
||||
self.cf = 0
|
||||
|
||||
for pkg in self.installed:
|
||||
|
||||
if os.path.isfile(f"{self.meta.pkg_path}{pkg}"):
|
||||
self.lf = 0
|
||||
|
||||
with open(self.pkg_path + pkg, "r") as fopen:
|
||||
|
||||
for line in fopen:
|
||||
|
||||
if "\0" in line:
|
||||
print(f"Null: {line}")
|
||||
break
|
||||
|
||||
self.cf += 1 # count all files
|
||||
self.lf += 1 # count each package files
|
||||
|
||||
if self.lf > 19:
|
||||
self.check(line, pkg)
|
||||
self.results()
|
||||
|
@ -90,13 +101,18 @@ class PackageHealth:
|
|||
"""
|
||||
print()
|
||||
per = int(round((float(self.cf) / (self.cf + self.cn)) * 100))
|
||||
|
||||
if per > 90:
|
||||
color = self.green
|
||||
|
||||
elif per < 90 and per > 60:
|
||||
color = self.yellow
|
||||
|
||||
elif per < 60:
|
||||
color = self.red
|
||||
|
||||
health = f"{color}{str(per)}%{self.endc}"
|
||||
|
||||
self.msg.template(78)
|
||||
print(f"| Total files{' ' * 7}Not installed{' ' * 40}Health")
|
||||
self.msg.template(78)
|
||||
|
|
249
slpkg/init.py
249
slpkg/init.py
|
@ -24,20 +24,20 @@
|
|||
|
||||
import os
|
||||
import shutil
|
||||
import sqlite3
|
||||
|
||||
from slpkg.utils import Utils
|
||||
from slpkg.repositories import Repo
|
||||
from slpkg.file_size import FileSize
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.models.models import Database
|
||||
from slpkg.models.data import Database
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
|
||||
from slpkg.slack.mirrors import mirrors
|
||||
from slpkg.slack.slack_version import slack_ver
|
||||
from slpkg.models.models import SBoTable, session
|
||||
|
||||
|
||||
class Initialization(Utils):
|
||||
class Init(Utils):
|
||||
"""Slpkg initialization starts all from here.
|
||||
Creates local package lists and updates or upgrades these.
|
||||
"""
|
||||
|
@ -45,6 +45,7 @@ class Initialization(Utils):
|
|||
self.check = check
|
||||
self.meta = _meta_
|
||||
self.arch = _meta_.arch
|
||||
self.session = session
|
||||
self.conf_path = self.meta.conf_path
|
||||
self.log_path = self.meta.log_path
|
||||
self.lib_path = self.meta.lib_path
|
||||
|
@ -76,23 +77,16 @@ class Initialization(Utils):
|
|||
|
||||
self.make_dir(paths_basic)
|
||||
self.make_dirs(paths_extra)
|
||||
self.database()
|
||||
|
||||
def database(self):
|
||||
"""Initializing the database
|
||||
"""
|
||||
db_lib = self.lib_path + self.meta.db
|
||||
self.make_dirs([db_lib])
|
||||
self.con = sqlite3.connect(db_lib)
|
||||
self.cur = self.con.cursor()
|
||||
|
||||
def make_dir(self, path: list):
|
||||
for p in path:
|
||||
|
||||
if not os.path.exists(p):
|
||||
os.mkdir(p)
|
||||
|
||||
def make_dirs(self, path: list):
|
||||
for p in path:
|
||||
|
||||
if not os.path.exists(p):
|
||||
os.makedirs(p)
|
||||
|
||||
|
@ -102,49 +96,59 @@ class Initialization(Utils):
|
|||
repo = Repo().custom_repository()[name]
|
||||
log = self.log_path + name + "/"
|
||||
lib = self.lib_path + f"{name}_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
PACKAGES_TXT = f"{repo}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, name)
|
||||
self.down(lib, CHECKSUMS_MD5, name)
|
||||
self.down(log, ChangeLog_txt, name)
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
FILELIST_TXT, name)
|
||||
|
||||
def slack(self):
|
||||
"""Creating slack local libraries
|
||||
"""
|
||||
log = self.log_path + "slack/"
|
||||
lib = self.lib_path + "slack_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.slack.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
dirs = ["core/", "extra/", "patches/"]
|
||||
|
||||
self.make_dir([log, lib])
|
||||
self.make_dir([f"{lib}{dirs[0]}",
|
||||
f"{lib}{dirs[1]}",
|
||||
f"{lib}{dirs[2]}"])
|
||||
|
||||
PACKAGES_TXT = mirrors(lib_file, "")
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = mirrors(md5_file, "")
|
||||
|
||||
self.EXTRA = mirrors(lib_file, dirs[1])
|
||||
self.EXT_CHECKSUMS = mirrors(md5_file, dirs[1])
|
||||
self.PATCHES = mirrors(lib_file, dirs[2])
|
||||
self.PAT_CHECKSUMS = mirrors(md5_file, dirs[2])
|
||||
ChangeLog_txt = mirrors(log_file, "")
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib + dirs[0], PACKAGES_TXT, repo_name)
|
||||
self.down(lib + dirs[0], CHECKSUMS_MD5, repo_name)
|
||||
self.down(lib + dirs[1], self.EXTRA, repo_name)
|
||||
|
@ -154,6 +158,7 @@ class Initialization(Utils):
|
|||
self.down(log, ChangeLog_txt, repo_name)
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
self.merge(lib, "PACKAGES.TXT", ["core/PACKAGES.TXT",
|
||||
"extra/PACKAGES.TXT",
|
||||
"patches/PACKAGES.TXT"])
|
||||
|
@ -167,20 +172,26 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["sbo"]
|
||||
log = self.log_path + "sbo/"
|
||||
lib = self.lib_path + "sbo_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.sbo.__name__
|
||||
|
||||
lib_file = "SLACKBUILDS.TXT"
|
||||
# lst_file = ""
|
||||
# md5_file = ""
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
SLACKBUILDS_TXT = f"{repo}{self.slack_ver}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = ""
|
||||
ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, SLACKBUILDS_TXT, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, SLACKBUILDS_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -190,21 +201,27 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["rlw"]
|
||||
log = self.log_path + "rlw/"
|
||||
lib = self.lib_path + "rlw_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.rlw.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
PACKAGES_TXT = f"{repo}{self.slack_ver}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{self.slack_ver}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{self.slack_ver}/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -216,25 +233,33 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["alien"]
|
||||
log = self.log_path + "alien/"
|
||||
lib = self.lib_path + "alien_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.alien.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = self.arch
|
||||
|
||||
if self.meta.slack_rel == "current":
|
||||
ver = self.meta.slack_rel
|
||||
|
||||
PACKAGES_TXT = f"{repo}/{ver}/{ar}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}/{ver}/{ar}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -245,24 +270,31 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["slacky"]
|
||||
log = self.log_path + "slacky/"
|
||||
lib = self.lib_path + "slacky_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.slacky.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "64"
|
||||
|
||||
PACKAGES_TXT = f"{repo}slackware{ar}-{self.slack_ver}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}slackware{ar}-{self.slack_ver}/{md5_file}"
|
||||
|
||||
ChangeLog_txt = f"{repo}slackware{ar}-{self.slack_ver}/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -272,18 +304,23 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["conrad"]
|
||||
log = self.log_path + "conrad/"
|
||||
lib = self.lib_path + "conrad_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.conrad.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
PACKAGES_TXT = f"{repo}{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
@ -297,27 +334,36 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["slonly"]
|
||||
log = self.log_path + "slonly/"
|
||||
lib = self.lib_path + "slonly_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.slonly.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = f"{self.slack_ver}-x86_64"
|
||||
|
||||
if self.meta.slack_rel == "current":
|
||||
ar = f"{self.meta.slack_rel}-x86"
|
||||
|
||||
if self.meta.slack_rel == "current" and self.arch == "x86_64":
|
||||
ar = f"{self.meta.slack_rel}-x86_64"
|
||||
|
||||
PACKAGES_TXT = f"{repo}{ar}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{ar}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{ar}/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -327,21 +373,27 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["ktown"]
|
||||
log = self.log_path + "ktown/"
|
||||
lib = self.lib_path + "ktown_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.ktown.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
PACKAGES_TXT = f"{repo}{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -352,23 +404,30 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["multi"]
|
||||
log = self.log_path + "multi/"
|
||||
lib = self.lib_path + "multi_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.multi.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.meta.slack_rel == "current":
|
||||
ver = self.meta.slack_rel
|
||||
|
||||
PACKAGES_TXT = f"{repo}{ver}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{ver}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -379,14 +438,18 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["slacke"]
|
||||
log = self.log_path + "slacke/"
|
||||
lib = self.lib_path + "slacke_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.slacke.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "64"
|
||||
|
||||
version = self.meta.slacke_sub_repo[1:-1]
|
||||
PACKAGES_TXT = (f"{repo}slacke{version}/slackware{ar}-"
|
||||
f"{self.slack_ver}/{lib_file}")
|
||||
|
@ -395,11 +458,14 @@ class Initialization(Utils):
|
|||
f"{self.slack_ver}/{md5_file}")
|
||||
ChangeLog_txt = (f"{repo}slacke{version}/slackware{ar}-"
|
||||
f"{self.slack_ver}/{log_file}")
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -410,23 +476,30 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["salix"]
|
||||
log = self.log_path + "salix/"
|
||||
lib = self.lib_path + "salix_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.salix.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "x86_64"
|
||||
|
||||
PACKAGES_TXT = f"{repo}{ar}/{self.slack_ver}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{ar}/{self.slack_ver}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{ar}/{self.slack_ver}/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -437,23 +510,30 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["slackl"]
|
||||
log = self.log_path + "slackl/"
|
||||
lib = self.lib_path + "slackl_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.slackl.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "x86_64"
|
||||
|
||||
PACKAGES_TXT = f"{repo}{ar}/current/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{ar}/current/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{ar}/current/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -463,21 +543,27 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["rested"]
|
||||
log = self.log_path + "rested/"
|
||||
lib = self.lib_path + "rested_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.rested.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
PACKAGES_TXT = f"{repo}{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -489,26 +575,34 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["msb"]
|
||||
log = self.log_path + "msb/"
|
||||
lib = self.lib_path + "msb_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.msb.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "x86_64"
|
||||
|
||||
version = self.meta.msb_sub_repo[1:-1]
|
||||
|
||||
if self.meta.slack_rel == "current":
|
||||
ver_slack = self.meta.slack_rel
|
||||
|
||||
PACKAGES_TXT = f"{repo}{ver_slack}/{version}/{ar}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{ver_slack}/{version}/{ar}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -520,25 +614,33 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["csb"]
|
||||
log = self.log_path + "csb/"
|
||||
lib = self.lib_path + "csb_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.csb.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "x86_64"
|
||||
|
||||
if self.meta.slack_rel == "current":
|
||||
ver_slack = self.meta.slack_rel
|
||||
|
||||
PACKAGES_TXT = f"{repo}{ver_slack}/{ar}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{ver_slack}/{ar}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -550,23 +652,30 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["connos"]
|
||||
log = self.log_path + "connos/"
|
||||
lib = self.lib_path + "connos_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.connos.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "64"
|
||||
|
||||
PACKAGES_TXT = f"{repo}{nickname}{ar}-{self.slack_ver}/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{nickname}{ar}-{self.slack_ver}/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{nickname}{ar}-{self.slack_ver}/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -577,24 +686,31 @@ class Initialization(Utils):
|
|||
repo = self.def_repos_dict["mles"]
|
||||
log = self.log_path + "mles/"
|
||||
lib = self.lib_path + "mles_repo/"
|
||||
repo_name = log[:-1].split("/")[-1]
|
||||
repo_name = Init.mles.__name__
|
||||
|
||||
lib_file = "PACKAGES.TXT"
|
||||
# lst_file = ""
|
||||
md5_file = "CHECKSUMS.md5"
|
||||
log_file = "ChangeLog.txt"
|
||||
|
||||
self.make_dir([log, lib])
|
||||
|
||||
if self.arch == "x86_64":
|
||||
ar = "64"
|
||||
|
||||
version = self.meta.mles_sub_repo[1:-1]
|
||||
PACKAGES_TXT = f"{repo}{version}-{self.slack_ver}-{ar}bit/{lib_file}"
|
||||
FILELIST_TXT = ""
|
||||
CHECKSUMS_MD5 = f"{repo}{version}-{self.slack_ver}-{ar}bit/{md5_file}"
|
||||
ChangeLog_txt = f"{repo}{version}-{self.slack_ver}-{ar}bit/{log_file}"
|
||||
|
||||
if self.check:
|
||||
return self.checks_logs(log, ChangeLog_txt)
|
||||
|
||||
self.down(lib, PACKAGES_TXT, repo_name)
|
||||
self.down(lib, CHECKSUMS_MD5, repo_name)
|
||||
self.down(log, ChangeLog_txt, repo_name)
|
||||
|
||||
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
|
||||
FILELIST_TXT, repo_name)
|
||||
|
||||
|
@ -622,35 +738,48 @@ class Initialization(Utils):
|
|||
self.file_remove(lib_path, PACKAGES_TXT.split("/")[-1])
|
||||
self.file_remove(lib_path, CHECKSUMS_MD5.split("/")[-1])
|
||||
self.file_remove(lib_path, FILELIST_TXT.split("/")[-1])
|
||||
|
||||
if repo == "slack":
|
||||
|
||||
dirs = ["core/", "extra/"]
|
||||
|
||||
for d in dirs:
|
||||
self.file_remove(lib_path + d, "PACKAGES.TXT")
|
||||
self.file_remove(lib_path + d, "CHECKSUMS.md5")
|
||||
|
||||
self.down(lib_path + "core/", PACKAGES_TXT, repo)
|
||||
self.down(lib_path + "core/", CHECKSUMS_MD5, repo)
|
||||
self.down(lib_path + "extra/", self.EXTRA, repo)
|
||||
self.down(lib_path + "extra/", self.EXT_CHECKSUMS, repo)
|
||||
|
||||
# download new files
|
||||
if repo != "slack":
|
||||
self.down(lib_path, PACKAGES_TXT, repo)
|
||||
self.down(lib_path, CHECKSUMS_MD5, repo)
|
||||
|
||||
self.down(lib_path, FILELIST_TXT, repo)
|
||||
self.down(log_path, ChangeLog_txt, repo)
|
||||
|
||||
if repo == 'sbo':
|
||||
self.cur.execute("DROP TABLE IF EXISTS sbo")
|
||||
self.con.commit()
|
||||
self.session.query(SBoTable).delete() # delete all data
|
||||
self.session.commit()
|
||||
|
||||
def merge(self, path, outfile, infiles):
|
||||
"""Merging files
|
||||
"""
|
||||
code = "utf-8"
|
||||
|
||||
with open(path + outfile, 'w', encoding=code) as out_f:
|
||||
|
||||
for f in infiles:
|
||||
|
||||
if os.path.isfile(f"{path}{f}"):
|
||||
|
||||
# checking the encoding before read the file
|
||||
code = self.check_encoding(path, f)
|
||||
|
||||
with open(path + f, "r", encoding=code) as in_f:
|
||||
|
||||
for line in in_f:
|
||||
out_f.write(line)
|
||||
|
||||
|
@ -666,10 +795,13 @@ class Initialization(Utils):
|
|||
local = ""
|
||||
filename = url.split("/")[-1]
|
||||
server = FileSize(url).server()
|
||||
|
||||
if os.path.isfile(log_path + filename):
|
||||
local = FileSize(log_path + filename).local()
|
||||
|
||||
if server != local:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
|
@ -679,6 +811,7 @@ class Upgrade:
|
|||
self.meta = _meta_
|
||||
self.log_path = self.meta.log_path
|
||||
self.lib_path = self.meta.lib_path
|
||||
self.session = session
|
||||
|
||||
def run(self, repos):
|
||||
"""Removing and creating the packages lists
|
||||
|
@ -690,20 +823,34 @@ class Upgrade:
|
|||
repositories = repos
|
||||
|
||||
for repo in repositories:
|
||||
|
||||
changelogs = f"{self.log_path}{repo}/ChangeLog.txt"
|
||||
|
||||
self.del_tables(repo)
|
||||
|
||||
if os.path.isfile(changelogs):
|
||||
os.remove(changelogs)
|
||||
|
||||
if os.path.isdir(f"{self.lib_path}{repo}_repo/"):
|
||||
|
||||
for f in os.listdir(f"{self.lib_path}{repo}_repo/"):
|
||||
|
||||
files = f"{self.lib_path}{repo}_repo/{f}"
|
||||
|
||||
if os.path.isfile(files):
|
||||
os.remove(files)
|
||||
|
||||
elif os.path.isdir(files):
|
||||
shutil.rmtree(files)
|
||||
|
||||
update = Update()
|
||||
update.run(repos)
|
||||
|
||||
def del_tables(self, repo):
|
||||
if repo == 'sbo':
|
||||
self.session.query(SBoTable).delete() # delete all data
|
||||
self.session.commit()
|
||||
|
||||
|
||||
class Update:
|
||||
|
||||
|
@ -716,6 +863,7 @@ class Update:
|
|||
self.endc = _meta_.color["ENDC"]
|
||||
self.done = f"{self.green}Done{self.endc}\n"
|
||||
self.error = f"{self.red}Error{self.endc}\n"
|
||||
self.session = session
|
||||
|
||||
def run(self, repos):
|
||||
"""Updates repositories lists
|
||||
|
@ -730,31 +878,39 @@ class Update:
|
|||
enabled = repos
|
||||
|
||||
for repo in enabled:
|
||||
|
||||
if check_for_local_repos(repo) is True:
|
||||
continue
|
||||
|
||||
self.done_msg(repo)
|
||||
|
||||
if repo in default:
|
||||
getattr(Initialization(False), repo)()
|
||||
getattr(Init(False), repo)()
|
||||
print(self.done, end="")
|
||||
|
||||
elif repo in custom:
|
||||
Initialization(False).custom(repo)
|
||||
Init(False).custom(repo)
|
||||
print(self.done, end="")
|
||||
|
||||
else:
|
||||
print(self.error, end="")
|
||||
|
||||
print() # new line at end
|
||||
|
||||
self.check_db()
|
||||
|
||||
raise SystemExit()
|
||||
|
||||
def check_db(self):
|
||||
"""Checking if the table exists
|
||||
"""Checking if the table is empty
|
||||
"""
|
||||
sbo_db = Database("sbo", "SLACKBUILDS.TXT")
|
||||
if sbo_db.table_exists() == 0:
|
||||
sbo_db.create_sbo_table()
|
||||
sbo_db.insert_sbo_table()
|
||||
db = Database()
|
||||
|
||||
if self.session.query(SBoTable).first() is None:
|
||||
db.insert_sbo_table()
|
||||
|
||||
def done_msg(self, repo):
|
||||
print(f"{self.grey}Check repository "
|
||||
print(f"{self.grey}Checking repository "
|
||||
f"[{self.cyan}{repo}{self.grey}] ... "
|
||||
f"{self.endc}", end="", flush=True)
|
||||
|
||||
|
@ -763,10 +919,13 @@ def check_exists_repositories(repo):
|
|||
"""Checking if repositories exists by PACKAGES.TXT file
|
||||
"""
|
||||
pkg_list = "PACKAGES.TXT"
|
||||
|
||||
if repo == "sbo":
|
||||
pkg_list = "SLACKBUILDS.TXT"
|
||||
|
||||
elif check_for_local_repos(repo) is True:
|
||||
pkg_list = "PACKAGES.TXT"
|
||||
|
||||
if not os.path.isfile(f"{_meta_.lib_path}{repo}_repo/{pkg_list}"):
|
||||
return False
|
||||
|
||||
|
@ -776,6 +935,8 @@ def check_for_local_repos(repo):
|
|||
"""
|
||||
repos_dict = Repo().default_repository()
|
||||
if repo in repos_dict:
|
||||
|
||||
repo_url = repos_dict[repo]
|
||||
|
||||
if repo_url.startswith("file:///"):
|
||||
return True
|
||||
|
|
|
@ -36,25 +36,36 @@ def library(repo):
|
|||
"""
|
||||
utils = Utils()
|
||||
pkg_list, packages = [], ""
|
||||
|
||||
if repo == "sbo":
|
||||
|
||||
if (os.path.isfile(
|
||||
f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")):
|
||||
packages = utils.read_file(
|
||||
f"{_meta_.lib_path}{repo}_repo/SLACKBUILDS.TXT")
|
||||
|
||||
else:
|
||||
|
||||
if (os.path.isfile(
|
||||
f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")):
|
||||
packages = utils.read_file(
|
||||
f"{_meta_.lib_path}{repo}_repo/PACKAGES.TXT")
|
||||
|
||||
for line in packages.splitlines():
|
||||
|
||||
if repo == "sbo":
|
||||
|
||||
if line.startswith("SLACKBUILD NAME: "):
|
||||
pkg_list.append(line[17:].strip())
|
||||
|
||||
elif "local" not in repo:
|
||||
|
||||
if line.startswith("PACKAGE NAME: "):
|
||||
pkg_list.append(line[15:].strip())
|
||||
|
||||
if repo == "local":
|
||||
pkg_list = find_package("", _meta_.pkg_path)
|
||||
|
||||
return pkg_list
|
||||
|
||||
|
||||
|
@ -69,22 +80,33 @@ class Regex:
|
|||
|
||||
def get(self):
|
||||
lib, data = [], []
|
||||
|
||||
for pkg in self.pkgs.split(","):
|
||||
pr = pkg.split(":") # priotity by repository
|
||||
data = library(pr[0]) # load data
|
||||
|
||||
if len(pr) > 1:
|
||||
|
||||
for d in data:
|
||||
|
||||
if pr[1].startswith("*") and pr[1].endswith("*"):
|
||||
|
||||
if pr[1][1:-1] in d:
|
||||
lib.append(self.add(pr[0], d))
|
||||
|
||||
elif pr[1].endswith("*"):
|
||||
|
||||
if d.startswith(pr[1][:-1]):
|
||||
lib.append(self.add(pr[0], d))
|
||||
|
||||
elif pr[1].startswith("*"):
|
||||
|
||||
if d.endswith(pr[1][1:]):
|
||||
lib.append(self.add(pr[0], d))
|
||||
|
||||
else:
|
||||
lib.append(self.add(pr[0], d))
|
||||
|
||||
else:
|
||||
lib += pkg.split()
|
||||
return lib
|
||||
|
@ -94,5 +116,6 @@ class Regex:
|
|||
"""
|
||||
if repo == "sbo":
|
||||
return pkg
|
||||
|
||||
else:
|
||||
return split_package(pkg)[0]
|
||||
|
|
|
@ -34,13 +34,19 @@ def write_deps(deps_dict):
|
|||
into the directory `/var/log/slpkg/dep/`
|
||||
"""
|
||||
for name, dependencies in deps_dict.items():
|
||||
|
||||
if find_package(f"{name}-", _meta_.pkg_path):
|
||||
dep_path = f"{_meta_.log_path}dep/"
|
||||
|
||||
if not os.path.exists(dep_path):
|
||||
os.mkdir(dep_path)
|
||||
|
||||
if os.path.isfile(f"{dep_path}{name}"):
|
||||
os.remove(f"{dep_path}{name}")
|
||||
|
||||
if len(dependencies) >= 1:
|
||||
|
||||
with open(f"{dep_path}{name}", "w") as f:
|
||||
|
||||
for dep in dependencies:
|
||||
f.write(f"{dep}\n")
|
||||
f.write(f"{dep}\n")
|
||||
|
|
150
slpkg/main.py
150
slpkg/main.py
|
@ -108,9 +108,11 @@ class ArgParse(BlackList):
|
|||
|
||||
if (len(self.args) > 1 and self.args[0] in options
|
||||
and check is False and repo in enabled_repos):
|
||||
|
||||
print("\n Please update the packages lists. Run 'slpkg update'.\n"
|
||||
" This command should be used to synchronize the packages\n"
|
||||
" lists from the repositories that are enabled.\n")
|
||||
|
||||
raise SystemExit(1)
|
||||
|
||||
def help_version(self):
|
||||
|
@ -119,9 +121,11 @@ class ArgParse(BlackList):
|
|||
if (len(self.args) == 1 and self.args[0] in ["-h", "--help"] and
|
||||
self.args[1:] == []):
|
||||
options()
|
||||
|
||||
elif (len(self.args) == 1 and self.args[0] in ["-v", "--version"] and
|
||||
self.args[1:] == []):
|
||||
prog_version()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -132,13 +136,18 @@ class ArgParse(BlackList):
|
|||
|
||||
if len(self.args) == 1 and self.args[0] == "update":
|
||||
update.run(repos="")
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] == "update" and
|
||||
self.args[1].startswith("--repos=")):
|
||||
|
||||
repos = self.args[1].split("=")[-1].split(",")
|
||||
|
||||
for rp in repos:
|
||||
if rp not in self.meta.repositories:
|
||||
usage(rp, 1)
|
||||
|
||||
update.run(repos)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -149,13 +158,19 @@ class ArgParse(BlackList):
|
|||
|
||||
if len(self.args) == 1 and self.args[0] == "upgrade":
|
||||
upgrade.run(repos="")
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] == "upgrade" and
|
||||
self.args[1].startswith("--repos=")):
|
||||
|
||||
repos = self.args[1].split("=")[-1].split(",")
|
||||
|
||||
for rp in repos:
|
||||
|
||||
if rp not in self.meta.repositories:
|
||||
usage(rp, 1)
|
||||
|
||||
upgrade.run(repos)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -164,6 +179,7 @@ class ArgParse(BlackList):
|
|||
"""
|
||||
if len(self.args) == 2 and self.args[0] == "update-slpkg":
|
||||
it_self_update()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -173,6 +189,7 @@ class ArgParse(BlackList):
|
|||
self.if_checklist()
|
||||
if len(self.args) == 1 and self.args[0] == "repo-enable":
|
||||
RepoEnable().choose()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -181,6 +198,7 @@ class ArgParse(BlackList):
|
|||
"""
|
||||
if len(self.args) == 1 and self.args[0] == "repo-list":
|
||||
RepoList().repos()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -189,6 +207,7 @@ class ArgParse(BlackList):
|
|||
"""
|
||||
if len(self.args) == 3 and self.args[0] == "repo-add":
|
||||
Repo().add(self.args[1], self.args[2])
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -197,6 +216,7 @@ class ArgParse(BlackList):
|
|||
"""
|
||||
if len(self.args) == 2 and self.args[0] == "repo-remove":
|
||||
Repo().remove(self.args[1])
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -207,9 +227,11 @@ class ArgParse(BlackList):
|
|||
self.args[1] in RepoList().all_repos):
|
||||
del RepoList().all_repos
|
||||
RepoInfo().view(self.args[1])
|
||||
|
||||
elif (len(self.args) > 1 and self.args[0] == "repo-info" and
|
||||
self.args[1] not in RepoList().all_repos):
|
||||
usage(self.args[1], 1)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -218,9 +240,11 @@ class ArgParse(BlackList):
|
|||
"""
|
||||
if len(self.args) == 1 and self.args[0] == "health":
|
||||
PackageHealth(mode="").test()
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] == "health" and
|
||||
self.args[1] == "--silent"):
|
||||
PackageHealth(mode=self.args[1]).test()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -230,19 +254,24 @@ class ArgParse(BlackList):
|
|||
image = ""
|
||||
|
||||
for arg in self.args:
|
||||
|
||||
if arg.startswith("--graph="):
|
||||
image = arg.split("=")[1]
|
||||
|
||||
if len(self.args) == 1 and self.args[0] == "deps-status":
|
||||
DependenciesStatus(image).show()
|
||||
|
||||
elif len(self.args) == 2 and self.args[0] == "deps-status" and image:
|
||||
DependenciesStatus(image).show()
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] == "deps-status" and
|
||||
"--tree" in self.args):
|
||||
DependenciesStatus(image).tree()
|
||||
|
||||
elif (len(self.args) == 3 and self.args[0] == "deps-status" and
|
||||
"--tree" in self.args and image):
|
||||
DependenciesStatus(image).tree()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -251,6 +280,7 @@ class ArgParse(BlackList):
|
|||
"""
|
||||
if len(self.args) == 1 and self.args[0] == "new-config":
|
||||
NewConfig().run()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -258,6 +288,7 @@ class ArgParse(BlackList):
|
|||
"""Clean all downloaded packages and sources"""
|
||||
if len(self.args) == 1 and self.args[0] == "clean-tmp":
|
||||
clean_tmp()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -268,8 +299,10 @@ class ArgParse(BlackList):
|
|||
"-a",
|
||||
"--autobuild"
|
||||
]
|
||||
|
||||
if len(self.args) >= 3 and self.args[0] in options:
|
||||
AutoBuild(self.args[1], self.args[2:], self.meta.path).run()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -285,24 +318,31 @@ class ArgParse(BlackList):
|
|||
name = INDEX = installed = False
|
||||
|
||||
for arg in self.args[2:]:
|
||||
|
||||
if flag[0] == arg:
|
||||
INDEX = True
|
||||
|
||||
if flag[1] in arg:
|
||||
installed = True
|
||||
|
||||
if flag[2] == arg:
|
||||
name = True
|
||||
|
||||
if arg not in flag:
|
||||
usage("", 1)
|
||||
|
||||
if (len(self.args) > 1 and len(self.args) <= 5 and
|
||||
self.args[0] in options):
|
||||
|
||||
if self.args[1] in self.meta.repositories:
|
||||
PackageManager(binary=None).package_list(self.args[1],
|
||||
name,
|
||||
INDEX,
|
||||
installed)
|
||||
|
||||
else:
|
||||
usage(self.args[1], 1)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -330,23 +370,31 @@ class ArgParse(BlackList):
|
|||
if (len(self.args) >= 3 and self.args[0] in options and
|
||||
self.args[2] == flags[0] and
|
||||
self.args[1] in self.meta.repositories):
|
||||
|
||||
if self.args[1] not in ["slack", "sbo"]:
|
||||
BinaryInstall(pkg_upgrade(self.args[1], skip, flag),
|
||||
self.args[1], flag).start(is_upgrade=True)
|
||||
|
||||
elif self.args[1] == "slack":
|
||||
Patches(skip, flag).start()
|
||||
|
||||
elif self.args[1] == "sbo":
|
||||
SBoInstall(sbo_upgrade(skip, flag), flag).start(
|
||||
is_upgrade=True)
|
||||
|
||||
else:
|
||||
usage(self.args[1], 1)
|
||||
|
||||
elif len(self.args) == 1 and self.args[0] in options:
|
||||
Updates(repo="").ALL()
|
||||
|
||||
elif len(self.args) == 2 and self.args[0] in options:
|
||||
Updates(self.args[1]).run()
|
||||
|
||||
elif (len(self.args) >= 2 and self.args[0] in options and
|
||||
self.args[1] not in self.meta.repositories):
|
||||
usage(self.args[1], 1)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -355,21 +403,27 @@ class ArgParse(BlackList):
|
|||
"""
|
||||
# Check for typos or unssuported flags
|
||||
for arg in self.args[2:]:
|
||||
|
||||
if arg not in flags:
|
||||
usage("", 1)
|
||||
|
||||
flag, skip = [], ""
|
||||
if flags[0] in self.args:
|
||||
|
||||
for arg in self.args:
|
||||
|
||||
if arg.startswith(flags[1]):
|
||||
skip = Regex(arg.split("=")[1]).get()
|
||||
self.args.remove(arg)
|
||||
|
||||
if arg in flags:
|
||||
flag.append(arg)
|
||||
|
||||
if arg not in self.args:
|
||||
self.args.remove(arg)
|
||||
if "--checklist" in flag:
|
||||
self.if_checklist()
|
||||
|
||||
return flag, skip
|
||||
|
||||
def pkg_install(self):
|
||||
|
@ -389,26 +443,36 @@ class ArgParse(BlackList):
|
|||
"--reinstall",
|
||||
"--patches"
|
||||
]
|
||||
|
||||
for arg in self.args:
|
||||
|
||||
if arg.startswith(additional_options[2]):
|
||||
flag.append(arg)
|
||||
arg = ""
|
||||
|
||||
if arg in additional_options:
|
||||
flag.append(arg)
|
||||
|
||||
# clean from flags
|
||||
for ar in flag:
|
||||
|
||||
if ar in self.args:
|
||||
self.args.remove(ar)
|
||||
|
||||
if len(self.args) >= 3 and self.args[0] in options:
|
||||
|
||||
if (self.args[1] in self.meta.repositories and
|
||||
self.args[1] not in ["sbo"]):
|
||||
BinaryInstall(self.args[2:], self.args[1], flag).start(
|
||||
is_upgrade=False)
|
||||
|
||||
elif (self.args[1] == "sbo" and
|
||||
self.args[1] in self.meta.repositories):
|
||||
SBoInstall(self.args[2:], flag).start(is_upgrade=False)
|
||||
|
||||
else:
|
||||
usage(self.args[1], 1)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -426,27 +490,37 @@ class ArgParse(BlackList):
|
|||
"--case-ins"
|
||||
]
|
||||
for arg in self.args[2:]:
|
||||
|
||||
if arg.startswith(additional_options[1]):
|
||||
flag.append(arg)
|
||||
self.args.remove(arg)
|
||||
|
||||
if arg in additional_options:
|
||||
flag.append(arg)
|
||||
|
||||
# clean additional options from args
|
||||
for f in flag:
|
||||
|
||||
if f in self.args:
|
||||
self.args.remove(f)
|
||||
|
||||
# print usage message if wrong additional option
|
||||
for arg in self.args:
|
||||
|
||||
if arg.startswith("--"):
|
||||
|
||||
if arg not in additional_options:
|
||||
usage("", 1)
|
||||
|
||||
if (len(self.args) >= 3 and len(self.args) <= 3 and
|
||||
self.args[0] in options and
|
||||
self.args[1] in self.meta.repositories):
|
||||
TrackingDeps(self.args[2], self.args[1], flag).run()
|
||||
|
||||
elif (len(self.args) >= 2 and
|
||||
self.args[1] not in self.meta.repositories):
|
||||
usage(self.args[1], 1)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -462,19 +536,25 @@ class ArgParse(BlackList):
|
|||
"--checklist",
|
||||
"--case-ins"
|
||||
]
|
||||
|
||||
for add in additional_options:
|
||||
|
||||
if add in self.args:
|
||||
flag.append(add)
|
||||
self.args.remove(add)
|
||||
|
||||
if "--checklist" in flag:
|
||||
self.if_checklist()
|
||||
|
||||
if (len(self.args) == 2 and self.args[0] in options and
|
||||
"sbo" in self.meta.repositories):
|
||||
SBoNetwork(self.args[1], flag).view()
|
||||
|
||||
elif (len(self.args) == 1 and self.args[0] in options and
|
||||
"sbo" in self.meta.repositories and
|
||||
additional_options[0] in flag):
|
||||
SBoNetwork("", flag).view()
|
||||
|
||||
else:
|
||||
usage("sbo", 1)
|
||||
|
||||
|
@ -489,22 +569,28 @@ class ArgParse(BlackList):
|
|||
"--add",
|
||||
"--remove"
|
||||
]
|
||||
|
||||
command = ["list"]
|
||||
|
||||
if (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1] == command[0]):
|
||||
self.black_listed()
|
||||
|
||||
elif (len(self.args) > 2 and self.args[0] in options and
|
||||
flag[0] in self.args):
|
||||
self.args.remove(flag[0])
|
||||
self.black_add(self.args[1:])
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
flag[1] in self.args):
|
||||
self.args.remove(flag[1])
|
||||
self.black_remove(list(self.get_black()))
|
||||
|
||||
elif (len(self.args) > 2 and self.args[0] in options and
|
||||
flag[1] in self.args):
|
||||
self.args.remove(flag[1])
|
||||
self.black_remove(self.args[1:])
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -516,41 +602,51 @@ class ArgParse(BlackList):
|
|||
"-q",
|
||||
"--queue"
|
||||
]
|
||||
|
||||
flag = [
|
||||
"--add",
|
||||
"--remove"
|
||||
]
|
||||
|
||||
command = [
|
||||
"list",
|
||||
"build",
|
||||
"install",
|
||||
"build-install"
|
||||
]
|
||||
|
||||
if (len(self.args) > 2 and self.args[0] in options and
|
||||
flag[0] in self.args):
|
||||
self.args.remove(flag[0])
|
||||
queue.add(self.args[1:])
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
flag[1] in self.args):
|
||||
self.args.remove(flag[1])
|
||||
queue.remove(queue.packages())
|
||||
|
||||
elif (len(self.args) > 2 and self.args[0] in options and
|
||||
flag[1] in self.args):
|
||||
self.args.remove(flag[1])
|
||||
queue.remove(self.args[1:])
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1] == command[0]):
|
||||
queue.listed()
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1] == command[1]):
|
||||
queue.build()
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1] == command[2]):
|
||||
queue.install()
|
||||
|
||||
elif (len(self.args) == 2 and self.args[0] in options and
|
||||
self.args[1] == command[3]):
|
||||
queue.build()
|
||||
queue.install()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -558,11 +654,14 @@ class ArgParse(BlackList):
|
|||
"""Installs Slackware binary packages
|
||||
"""
|
||||
packages = self.args[1:]
|
||||
|
||||
options = [
|
||||
"-i",
|
||||
"--installpkg"
|
||||
]
|
||||
|
||||
flag = ""
|
||||
|
||||
flags = [
|
||||
"--warn",
|
||||
"--md5sum",
|
||||
|
@ -574,11 +673,15 @@ class ArgParse(BlackList):
|
|||
"--priority",
|
||||
"--tagfile"
|
||||
]
|
||||
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
|
||||
if self.args[1] in flags:
|
||||
flag = self.args[1]
|
||||
packages = self.args[2:]
|
||||
|
||||
PackageManager(packages).install(flag)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -586,22 +689,29 @@ class ArgParse(BlackList):
|
|||
"""Installs, upgrades Slackware binary packages
|
||||
"""
|
||||
packages = self.args[1:]
|
||||
|
||||
options = [
|
||||
"-u",
|
||||
"--upgradepkg"
|
||||
]
|
||||
|
||||
flag = ""
|
||||
|
||||
flags = [
|
||||
"--dry-run",
|
||||
"--install-new",
|
||||
"--reinstall",
|
||||
"--verbose"
|
||||
]
|
||||
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
|
||||
if self.args[1] in flags:
|
||||
flag = self.args[1]
|
||||
packages = self.args[2:]
|
||||
|
||||
PackageManager(packages).upgrade(flag)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -609,10 +719,12 @@ class ArgParse(BlackList):
|
|||
"""Remove Slackware packages
|
||||
"""
|
||||
packages = self.args[1:]
|
||||
|
||||
options = [
|
||||
"-r",
|
||||
"--removepkg"
|
||||
]
|
||||
|
||||
additional_options = [
|
||||
"--deps",
|
||||
"--check-deps",
|
||||
|
@ -620,33 +732,44 @@ class ArgParse(BlackList):
|
|||
"--checklist",
|
||||
"--third-party"
|
||||
]
|
||||
|
||||
flag, extra = "", []
|
||||
|
||||
flags = [
|
||||
"-warn",
|
||||
"-preserve",
|
||||
"-copy",
|
||||
"-keep"
|
||||
]
|
||||
|
||||
# merge --check-deps and --deps options
|
||||
if (additional_options[1] in self.args and
|
||||
additional_options[0] not in self.args):
|
||||
self.args.append(additional_options[0])
|
||||
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
|
||||
for additional in additional_options:
|
||||
|
||||
if additional in self.args:
|
||||
extra.append(additional)
|
||||
self.args.remove(additional)
|
||||
|
||||
packages = self.args[1:]
|
||||
|
||||
for fl in flags:
|
||||
|
||||
if fl in self.args:
|
||||
flag = self.args[1]
|
||||
packages = self.args[2:]
|
||||
|
||||
if "--checklist" in extra:
|
||||
self.if_checklist()
|
||||
|
||||
if not packages:
|
||||
packages = [""]
|
||||
PackageManager(packages).remove(flag, extra)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -665,9 +788,11 @@ class ArgParse(BlackList):
|
|||
]
|
||||
|
||||
for add in additional_options:
|
||||
|
||||
if add in self.args:
|
||||
flag.append(add)
|
||||
self.args.remove(add)
|
||||
|
||||
packages = self.args[1:]
|
||||
|
||||
if not packages:
|
||||
|
@ -675,8 +800,10 @@ class ArgParse(BlackList):
|
|||
|
||||
if len(self.args) == 1 and self.args[0] in options:
|
||||
PackageManager(packages).find(flag)
|
||||
|
||||
elif len(self.args) > 1 and self.args[0] in options:
|
||||
PackageManager(packages).find(flag)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -701,6 +828,7 @@ class ArgParse(BlackList):
|
|||
tag = ""
|
||||
|
||||
for arg in self.args:
|
||||
|
||||
if arg.startswith(flag[0]):
|
||||
tag = arg[len(flag[0]):]
|
||||
self.args.remove(arg)
|
||||
|
@ -712,12 +840,15 @@ class ArgParse(BlackList):
|
|||
if (len(self.args) == 3 and self.args[0] in options and
|
||||
self.args[1] in self.meta.repositories and tag in colors):
|
||||
PkgDesc(self.args[2], self.args[1], tag).view()
|
||||
|
||||
elif (len(self.args) == 3 and self.args[0] in options and
|
||||
self.args[1] in self.meta.repositories):
|
||||
PkgDesc(self.args[2], self.args[1], paint="").view()
|
||||
|
||||
elif (len(self.args) > 1 and self.args[0] in options and
|
||||
self.args[1] not in self.meta.repositories):
|
||||
usage(self.args[1], 1)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -729,16 +860,20 @@ class ArgParse(BlackList):
|
|||
"-F",
|
||||
"--FIND"
|
||||
]
|
||||
|
||||
additional_options = ["--case-ins"]
|
||||
|
||||
for arg in self.args:
|
||||
|
||||
if arg in additional_options:
|
||||
flag.append(arg)
|
||||
self.args.remove(arg)
|
||||
|
||||
packages = self.args[1:]
|
||||
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
FindFromRepos().find(packages, flag)
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -746,6 +881,7 @@ class ArgParse(BlackList):
|
|||
"""Prints packages contents
|
||||
"""
|
||||
packages = self.args[1:]
|
||||
|
||||
options = [
|
||||
"-d",
|
||||
"--display"
|
||||
|
@ -753,6 +889,7 @@ class ArgParse(BlackList):
|
|||
|
||||
if len(self.args) > 1 and self.args[0] in options:
|
||||
PackageManager(packages).display()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -763,21 +900,27 @@ class ArgParse(BlackList):
|
|||
"-g",
|
||||
"--config"
|
||||
]
|
||||
|
||||
command = [
|
||||
"print",
|
||||
"edit",
|
||||
"reset"
|
||||
]
|
||||
|
||||
conf = Config()
|
||||
|
||||
if (len(self.args) == 2 and self.args[0] in options
|
||||
and self.args[1] in command):
|
||||
|
||||
if self.args[1] == command[0]:
|
||||
conf.view()
|
||||
|
||||
if self.args[1] == command[1]:
|
||||
conf.edit()
|
||||
|
||||
if self.args[1] == command[2]:
|
||||
conf.reset()
|
||||
|
||||
else:
|
||||
usage("", 1)
|
||||
|
||||
|
@ -790,19 +933,26 @@ class ArgParse(BlackList):
|
|||
".tbz",
|
||||
".tlz"
|
||||
]
|
||||
|
||||
if (not args[0].startswith("-") and args[0] not in self.commands and
|
||||
args[0].endswith(tuple(suffixes))):
|
||||
packages, not_found = [], []
|
||||
|
||||
for pkg in args:
|
||||
|
||||
if pkg.endswith(tuple(suffixes)):
|
||||
|
||||
if os.path.isfile(pkg):
|
||||
packages.append(pkg)
|
||||
|
||||
else:
|
||||
not_found.append(pkg)
|
||||
|
||||
if packages:
|
||||
AutoInstall(packages).select()
|
||||
|
||||
if not_found:
|
||||
|
||||
for ntf in not_found:
|
||||
self.msg.pkg_not_found("", ntf, "Not installed", "")
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ def md5(source):
|
|||
"""
|
||||
# fix passing char '+' from source
|
||||
source = source.replace("%2B", "+")
|
||||
|
||||
with open(source, "rb") as file_to_check:
|
||||
data = file_to_check.read()
|
||||
return hashlib.md5(data).hexdigest()
|
||||
|
||||
return hashlib.md5(data).hexdigest()
|
||||
|
|
|
@ -79,23 +79,27 @@ class Msg:
|
|||
message = "package"
|
||||
if count > 1:
|
||||
message = message + "s"
|
||||
|
||||
return message
|
||||
|
||||
def not_found(self, if_upgrade):
|
||||
if if_upgrade:
|
||||
print("\nNot found packages for upgrade\n")
|
||||
|
||||
else:
|
||||
print("\nNot found packages for installation\n")
|
||||
|
||||
def upg_inst(self, if_upgrade):
|
||||
if not if_upgrade:
|
||||
print("Installing:")
|
||||
|
||||
else:
|
||||
print("Upgrading:")
|
||||
|
||||
def answer(self):
|
||||
if self.meta.default_answer in ["y", "Y"]:
|
||||
answer = self.meta.default_answer
|
||||
|
||||
else:
|
||||
try:
|
||||
answer = input("Would you like to continue [y/N]? ")
|
||||
|
@ -119,11 +123,15 @@ class Msg:
|
|||
print(f"| Total {len(install)} {self.pkg(len(install))} installed and "
|
||||
f"{len(upgrade)} {self.pkg(len(upgrade))} upgraded")
|
||||
self.template(78)
|
||||
|
||||
for installed, upgraded in itertools.zip_longest(install, upgrade):
|
||||
|
||||
if upgraded:
|
||||
print(f"| Package {upgraded} upgraded successfully")
|
||||
|
||||
if installed:
|
||||
print(f"| Package {installed} installed successfully")
|
||||
|
||||
self.template(78)
|
||||
print()
|
||||
|
||||
|
|
84
slpkg/models/data.py
Normal file
84
slpkg/models/data.py
Normal file
|
@ -0,0 +1,84 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# models.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014-2022 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Slpkg is a user-friendly package manager for Slackware installations
|
||||
|
||||
# https://gitlab.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from progress.bar import Bar
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
from slpkg.models.models import SBoTable, session
|
||||
|
||||
|
||||
class Database:
|
||||
|
||||
def __init__(self):
|
||||
self.lib_path = _meta_.lib_path
|
||||
self.session = session
|
||||
|
||||
def insert_sbo_table(self):
|
||||
"""Grabbing data line by line and inserting them into the database
|
||||
"""
|
||||
|
||||
sbo_tags = [
|
||||
"SLACKBUILD NAME:",
|
||||
"SLACKBUILD LOCATION:",
|
||||
"SLACKBUILD FILES:",
|
||||
"SLACKBUILD VERSION:",
|
||||
"SLACKBUILD DOWNLOAD:",
|
||||
"SLACKBUILD DOWNLOAD_x86_64:",
|
||||
"SLACKBUILD MD5SUM:",
|
||||
"SLACKBUILD MD5SUM_x86_64:",
|
||||
"SLACKBUILD REQUIRES:",
|
||||
"SLACKBUILD SHORT DESCRIPTION:"
|
||||
]
|
||||
|
||||
sbo_file = self.open_file(f"{self.lib_path}sbo_repo/SLACKBUILDS.TXT")
|
||||
|
||||
bar = Bar("Creating sbo database", max=len(sbo_file),
|
||||
suffix="%(percent)d%% - %(eta)ds")
|
||||
|
||||
cache = [] # init cache
|
||||
|
||||
for i, line in enumerate(sbo_file, 1):
|
||||
|
||||
for s in sbo_tags:
|
||||
if line.startswith(s):
|
||||
line = line.replace(s, "").strip()
|
||||
cache.append(line)
|
||||
|
||||
if (i % 11) == 0:
|
||||
data = SBoTable(name=cache[0], location=cache[1],
|
||||
files=cache[2], version=cache[3],
|
||||
download=cache[4], download64=cache[5],
|
||||
md5sum=cache[6], md5sum64=cache[7],
|
||||
requires=cache[8], short_description=cache[9])
|
||||
self.session.add(data)
|
||||
|
||||
cache = [] # reset cache after 11 lines
|
||||
|
||||
bar.next()
|
||||
bar.finish()
|
||||
|
||||
self.session.commit()
|
||||
|
||||
def open_file(self, file):
|
||||
with open(file, "r", encoding="utf-8") as f:
|
||||
return f.readlines()
|
|
@ -22,82 +22,37 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import sqlite3
|
||||
from progress.bar import Bar
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy import create_engine, Column, Integer, Text
|
||||
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
|
||||
lib_path = _meta_.lib_path
|
||||
db = _meta_.db
|
||||
|
||||
class Database:
|
||||
DATABASE_URI = f"sqlite:///{lib_path}{db}"
|
||||
engine = create_engine(DATABASE_URI)
|
||||
|
||||
def __init__(self, table_name, text_file):
|
||||
self.lib_path = _meta_.lib_path
|
||||
self.table_name = table_name
|
||||
self.text_file = text_file
|
||||
self.db = _meta_.db
|
||||
self.con = sqlite3.connect(f"{self.lib_path}{self.db}")
|
||||
self.cur = self.con.cursor()
|
||||
session = sessionmaker(engine)()
|
||||
Base = declarative_base()
|
||||
|
||||
def table_exists(self):
|
||||
"""Checking if the table exists
|
||||
"""
|
||||
self.cur.execute("""SELECT count(name)
|
||||
FROM sqlite_master
|
||||
WHERE type='table'
|
||||
AND name='{}'""".format(self.table_name))
|
||||
return self.cur.fetchone()[0]
|
||||
|
||||
def create_sbo_table(self):
|
||||
self.cur.execute("""CREATE TABLE IF NOT EXISTS {}
|
||||
(name text, location text, files text, version text,
|
||||
download text, download64 text, md5sum text,
|
||||
md5sum64 text, requires text, short_desc text)
|
||||
""".format(self.table_name))
|
||||
self.con.commit()
|
||||
class SBoTable(Base):
|
||||
|
||||
def insert_sbo_table(self):
|
||||
"""Grabbing data line by line and inserting them into the database
|
||||
"""
|
||||
self.sbo = [
|
||||
"SLACKBUILD NAME:",
|
||||
"SLACKBUILD LOCATION:",
|
||||
"SLACKBUILD FILES:",
|
||||
"SLACKBUILD VERSION:",
|
||||
"SLACKBUILD DOWNLOAD:",
|
||||
"SLACKBUILD DOWNLOAD_x86_64:",
|
||||
"SLACKBUILD MD5SUM:",
|
||||
"SLACKBUILD MD5SUM_x86_64:",
|
||||
"SLACKBUILD REQUIRES:",
|
||||
"SLACKBUILD SHORT DESCRIPTION:"
|
||||
]
|
||||
__tablename__ = "sbotable"
|
||||
|
||||
sbo_file = self.open_file(f"{self.lib_path}sbo_repo/SLACKBUILDS.TXT")
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(Text)
|
||||
location = Column(Text)
|
||||
files = Column(Text)
|
||||
version = Column(Text)
|
||||
download = Column(Text)
|
||||
download64 = Column(Text)
|
||||
md5sum = Column(Text)
|
||||
md5sum64 = Column(Text)
|
||||
requires = Column(Text)
|
||||
short_description = Column(Text)
|
||||
|
||||
bar = Bar("Creating sbo database", max=len(sbo_file),
|
||||
suffix="%(percent)d%% - %(eta)ds")
|
||||
|
||||
cache = [] # init cache
|
||||
|
||||
for i, line in enumerate(sbo_file, 1):
|
||||
|
||||
for s in self.sbo:
|
||||
if line.startswith(s):
|
||||
line = line.replace(s, "").strip()
|
||||
cache.append(line)
|
||||
|
||||
if (i % 11) == 0:
|
||||
values = [
|
||||
(cache[0], cache[1], cache[2], cache[3], cache[4],
|
||||
cache[5], cache[6], cache[7], cache[8], cache[9]),
|
||||
]
|
||||
self.cur.executemany("""INSERT INTO {} VALUES
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""".format(
|
||||
self.table_name), values)
|
||||
self.con.commit()
|
||||
cache = [] # reset cache after 11 lines
|
||||
bar.next()
|
||||
bar.finish()
|
||||
self.con.close()
|
||||
|
||||
def open_file(self, file):
|
||||
with open(file, "r", encoding="utf-8") as f:
|
||||
return f.readlines()
|
||||
Base.metadata.create_all(engine)
|
||||
|
|
|
@ -41,8 +41,10 @@ class NewConfig(Utils):
|
|||
self.green = self.meta.color["GREEN"]
|
||||
self.endc = self.meta.color["ENDC"]
|
||||
self.br = ""
|
||||
|
||||
if self.meta.use_colors in ["off", "OFF"]:
|
||||
self.br = ")"
|
||||
|
||||
self.etc = "/etc/"
|
||||
self.news = []
|
||||
|
||||
|
@ -50,11 +52,14 @@ class NewConfig(Utils):
|
|||
"""prints .new configuration files
|
||||
"""
|
||||
self.find_new()
|
||||
|
||||
for n in self.news:
|
||||
print(n)
|
||||
|
||||
print()
|
||||
self.msg.template(78)
|
||||
print(f"| Installed {len(self.news)} new configuration files:")
|
||||
|
||||
self.msg.template(78)
|
||||
self.choices()
|
||||
|
||||
|
@ -63,11 +68,15 @@ class NewConfig(Utils):
|
|||
and subfolders
|
||||
"""
|
||||
print("Search for .new configuration files:\n")
|
||||
|
||||
for path, dirs, files in os.walk(self.etc):
|
||||
del dirs # delete unsed
|
||||
|
||||
for f in files:
|
||||
|
||||
if f.endswith(".new"):
|
||||
self.news.append(os.path.join(path, f))
|
||||
|
||||
if not self.news:
|
||||
print(" No new configuration files\n")
|
||||
raise SystemExit()
|
||||
|
@ -82,17 +91,23 @@ class NewConfig(Utils):
|
|||
print(f"| {self.red}P{self.endc}{self.br}rompt K, O, R, D, M option for each single file")
|
||||
print(f"| {self.red}Q{self.endc}{self.br}uit from menu")
|
||||
self.msg.template(78)
|
||||
|
||||
try:
|
||||
choose = input("\nWhat would you like to do [K/O/R/P/Q]? ")
|
||||
except EOFError:
|
||||
raise SystemExit("\n")
|
||||
|
||||
print()
|
||||
|
||||
if choose in ("K", "k"):
|
||||
self.keep()
|
||||
|
||||
elif choose in ("O", "o"):
|
||||
self.overwrite_all()
|
||||
|
||||
elif choose in ("R", "r"):
|
||||
self.remove_all()
|
||||
|
||||
elif choose in ("P", "p"):
|
||||
self.prompt()
|
||||
|
||||
|
@ -122,7 +137,9 @@ class NewConfig(Utils):
|
|||
self.red, self.endc, self.br, self.red, self.endc, self.br))
|
||||
self.msg.template(78)
|
||||
print()
|
||||
|
||||
self.i = 0
|
||||
|
||||
try:
|
||||
while self.i < len(self.news):
|
||||
self.question(self.news[self.i])
|
||||
|
@ -136,17 +153,23 @@ class NewConfig(Utils):
|
|||
print()
|
||||
prompt_ask = input(f"{n} [K/O/R/D/M/Q]? ")
|
||||
print()
|
||||
|
||||
if prompt_ask in ("K", "k"):
|
||||
self.keep()
|
||||
|
||||
elif prompt_ask in ("O", "o"):
|
||||
self._overwrite(n)
|
||||
|
||||
elif prompt_ask in ("R", "r"):
|
||||
self._remove(n)
|
||||
|
||||
elif prompt_ask in ("D", "d"):
|
||||
self.diff(n)
|
||||
self.i -= 1
|
||||
|
||||
elif prompt_ask in ("M", "m"):
|
||||
self.merge(n)
|
||||
|
||||
elif prompt_ask in ("Q", "q", "quit"):
|
||||
self.quit()
|
||||
|
||||
|
@ -155,6 +178,7 @@ class NewConfig(Utils):
|
|||
"""
|
||||
if os.path.isfile(n):
|
||||
os.remove(n)
|
||||
|
||||
if not os.path.isfile(n):
|
||||
print(f"File '{n}' removed")
|
||||
|
||||
|
@ -165,6 +189,7 @@ class NewConfig(Utils):
|
|||
shutil.copy2(n[:-4], n[:-4] + ".old")
|
||||
print("Old file {0} saved as {1}.old".format(
|
||||
n[:-4].split("/")[-1], n[:-4].split("/")[-1]))
|
||||
|
||||
if os.path.isfile(n):
|
||||
shutil.move(n, n[:-4])
|
||||
print("New file {0} overwrite as {1}".format(
|
||||
|
@ -178,27 +203,39 @@ class NewConfig(Utils):
|
|||
"""
|
||||
if os.path.isfile(n[:-4]):
|
||||
diff1 = self.read_file(n[:-4]).splitlines()
|
||||
|
||||
if os.path.isfile(n):
|
||||
diff2 = self.read_file(n).splitlines()
|
||||
|
||||
lines, ln, c = [], 0, 0
|
||||
|
||||
for a, b in itertools.izip_longest(diff1, diff2):
|
||||
ln += 1
|
||||
|
||||
if a != b:
|
||||
|
||||
for s1, s2 in itertools.izip_longest(str(a), str(b)):
|
||||
c += 1
|
||||
|
||||
if s1 != s2:
|
||||
break
|
||||
print(f"@@ -{ln},{c} +{ln},{c} @@\n")
|
||||
|
||||
for line in lines[-3:]:
|
||||
print(f"{line}")
|
||||
|
||||
if a is None:
|
||||
a = ""
|
||||
|
||||
print(f"{self.red}-{self.endc}{a}")
|
||||
|
||||
if b is None:
|
||||
b = ""
|
||||
|
||||
print(f"{self.green}+{self.endc}{b}")
|
||||
lines = []
|
||||
c = 0
|
||||
|
||||
else:
|
||||
lines.append(a)
|
||||
|
||||
|
@ -207,18 +244,26 @@ class NewConfig(Utils):
|
|||
"""
|
||||
if os.path.isfile(n[:-4]):
|
||||
old = self.read_file(n[:-4]).splitlines()
|
||||
|
||||
if os.path.isfile(n):
|
||||
new = self.read_file(n).splitlines()
|
||||
|
||||
with open(n[:-4], "w") as out:
|
||||
|
||||
for l1, l2 in itertools.izip_longest(old, new):
|
||||
|
||||
if l1 is None:
|
||||
l1 = ""
|
||||
|
||||
if l2 is None:
|
||||
l2 = ""
|
||||
|
||||
if l1 != l2:
|
||||
out.write(l2 + "\n")
|
||||
|
||||
else:
|
||||
out.write(l1 + "\n")
|
||||
|
||||
print("The file {0} merged in file {1}".format(
|
||||
n.split("/")[-1], n[:-4].split("/")[-1]))
|
||||
|
||||
|
|
|
@ -58,10 +58,13 @@ class BuildPackage(Utils):
|
|||
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(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):
|
||||
os.mkdir(self.build_logs)
|
||||
|
||||
|
@ -72,18 +75,24 @@ class BuildPackage(Utils):
|
|||
"""
|
||||
try:
|
||||
self._delete_dir()
|
||||
|
||||
try:
|
||||
tar = tarfile.open(self.script)
|
||||
except Exception as err:
|
||||
raise SystemExit(err)
|
||||
|
||||
tar.extractall()
|
||||
tar.close()
|
||||
|
||||
self._makeflags()
|
||||
self._delete_sbo_tar_gz()
|
||||
self._create_md5_dict()
|
||||
|
||||
if not self.auto:
|
||||
os.chdir(self._SOURCES)
|
||||
|
||||
for src in self.sources:
|
||||
|
||||
if not os.path.isfile(src):
|
||||
continue
|
||||
# fix build sources with spaces
|
||||
|
@ -91,24 +100,34 @@ class BuildPackage(Utils):
|
|||
check_md5(self.sbo_md5[src], src)
|
||||
# copy source and fix passing char '+' from file name
|
||||
shutil.copy2(src, self.path + self.prgnam)
|
||||
|
||||
os.chdir(self.path + self.prgnam)
|
||||
|
||||
# change permissions
|
||||
subprocess.call(f"chmod +x {self.prgnam}.SlackBuild", shell=True)
|
||||
|
||||
pass_var = self._pass_variable()
|
||||
|
||||
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
|
||||
log_head(self.build_logs, self.log_file, self.start_log_time)
|
||||
subprocess.Popen(f"{' '.join(pass_var)} ./{self.prgnam}.SlackBuild 2>&1 | tee -a "
|
||||
f"{self.build_logs}{self.log_file}", shell=True, stdout=sys.stdout).communicate()
|
||||
|
||||
sum_time = build_time(self.start_time)
|
||||
|
||||
# write end in log file
|
||||
log_end(self.build_logs, self.log_file, sum_time)
|
||||
print(f"Total build time for the package {self.prgnam} : {sum_time}\n")
|
||||
|
||||
else:
|
||||
subprocess.call(f"{' '.join(pass_var)} ./{self.prgnam}.SlackBuild", shell=True)
|
||||
os.chdir(self.path)
|
||||
|
||||
except (KeyboardInterrupt, KeyError) as e:
|
||||
print(e) # (OSError, IOError, KeyError):
|
||||
self.msg.pkg_not_found("\n", self.prgnam, "Wrong file", "\n")
|
||||
|
@ -119,13 +138,16 @@ class BuildPackage(Utils):
|
|||
new_sources = []
|
||||
for src in self.sources:
|
||||
new_sources.append(self.fix_file_name(src))
|
||||
|
||||
self.sources = new_sources
|
||||
|
||||
def _create_md5_dict(self):
|
||||
"""Creates md5 dictionary per source
|
||||
"""
|
||||
self.sbo_md5 = {}
|
||||
|
||||
md5_lists = SBoGrep(self.prgnam).checksum()
|
||||
|
||||
for src, md5 in itertools.zip_longest(self.sources, md5_lists):
|
||||
self.sbo_md5[src] = md5
|
||||
|
||||
|
@ -141,10 +163,13 @@ class BuildPackage(Utils):
|
|||
"""Returns enviroment variables
|
||||
"""
|
||||
pass_var = []
|
||||
|
||||
for var in os.environ.keys():
|
||||
expVAR = var.split("_")
|
||||
|
||||
if expVAR[0] == self.prgnam.upper() and expVAR[1] != "PATH":
|
||||
pass_var.append(f"{expVAR[1]}={os.environ[var]}")
|
||||
|
||||
return pass_var
|
||||
|
||||
def _delete_sbo_tar_gz(self):
|
||||
|
@ -190,12 +215,15 @@ def build_time(start_time):
|
|||
diff_time = round(time.time() - start_time, 2)
|
||||
if diff_time <= 59.99:
|
||||
sum_time = str(diff_time) + " Sec"
|
||||
|
||||
elif diff_time > 59.99 and diff_time <= 3599.99:
|
||||
sum_time = round(diff_time / 60, 2)
|
||||
sum_time_list = re.findall(r"\d+", str(sum_time))
|
||||
sum_time = (f"{sum_time_list[0]} Min {sum_time_list[1]} Sec")
|
||||
|
||||
elif diff_time > 3599.99:
|
||||
sum_time = round(diff_time / 3600, 2)
|
||||
sum_time_list = re.findall(r"\d+", str(sum_time))
|
||||
sum_time = (f"{sum_time_list[0]} Hours {sum_time_list[1]} Min")
|
||||
|
||||
return sum_time
|
||||
|
|
|
@ -31,17 +31,22 @@ def searching(find_pkg, directory):
|
|||
"""Find packages
|
||||
"""
|
||||
black = BlackList()
|
||||
|
||||
if os.path.isdir(directory):
|
||||
installed = os.listdir(directory)
|
||||
blacklist = list(black.get_black())
|
||||
|
||||
if os.path.exists(directory):
|
||||
|
||||
for pkg in installed:
|
||||
|
||||
if (not pkg.startswith(".") and pkg.startswith(find_pkg) and
|
||||
split_package(pkg)[0] not in blacklist):
|
||||
|
||||
yield pkg
|
||||
|
||||
|
||||
def find_package(pkg, path):
|
||||
"""Generator allias
|
||||
"""
|
||||
return list(searching(pkg, path))
|
||||
return list(searching(pkg, path))
|
||||
|
|
|
@ -37,7 +37,9 @@ class GetFromInstalled:
|
|||
self.meta = _meta_
|
||||
self.files = find_package(f"{self.package}-", self.meta.pkg_path)
|
||||
self.find = ""
|
||||
|
||||
for file in self.files:
|
||||
|
||||
if split_package(file)[0] == self.package:
|
||||
self.find = file
|
||||
|
||||
|
@ -46,6 +48,7 @@ class GetFromInstalled:
|
|||
"""
|
||||
if self.find:
|
||||
return split_package(self.find)[1]
|
||||
|
||||
return self.find
|
||||
|
||||
def name(self):
|
||||
|
@ -53,4 +56,5 @@ class GetFromInstalled:
|
|||
"""
|
||||
if self.find:
|
||||
return self.package
|
||||
|
||||
return self.find
|
||||
|
|
|
@ -63,11 +63,15 @@ class PackageManager(Utils):
|
|||
for pkg in self.binary:
|
||||
try:
|
||||
subprocess.call(f"installpkg {flag} {pkg}", shell=True)
|
||||
|
||||
check = pkg[:-4].split("/")[-1]
|
||||
|
||||
if os.path.isfile(self.meta.pkg_path + check):
|
||||
print("Completed!\n")
|
||||
|
||||
else:
|
||||
raise SystemExit(1)
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
self._not_found("Can't install", self.binary, pkg)
|
||||
raise SystemExit(1)
|
||||
|
@ -78,11 +82,15 @@ class PackageManager(Utils):
|
|||
for pkg in self.binary:
|
||||
try:
|
||||
subprocess.call(f"upgradepkg {flag} {pkg}", shell=True)
|
||||
|
||||
check = pkg[:-4].split("/")[-1]
|
||||
|
||||
if os.path.isfile(self.meta.pkg_path + check):
|
||||
print("Completed!\n")
|
||||
|
||||
else:
|
||||
raise SystemExit(1)
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
self._not_found("Can't upgrade", self.binary, pkg)
|
||||
raise SystemExit(1)
|
||||
|
@ -90,8 +98,10 @@ class PackageManager(Utils):
|
|||
def _not_found(self, message, binary, pkg):
|
||||
if len(binary) > 1:
|
||||
bol = eol = ""
|
||||
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
|
||||
self.msg.pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def remove(self, flag, extra):
|
||||
|
@ -102,40 +112,53 @@ class PackageManager(Utils):
|
|||
self.dep_path = self.meta.log_path + "dep/"
|
||||
dependencies, rmv_list = [], []
|
||||
self.removed = self._view_removed()
|
||||
|
||||
if not self.removed:
|
||||
print() # new line at end
|
||||
|
||||
else:
|
||||
msg = "package"
|
||||
|
||||
if len(self.removed) > 1:
|
||||
msg = msg + "s"
|
||||
|
||||
try:
|
||||
if self.meta.default_answer in ["y", "Y"]:
|
||||
remove_pkg = self.meta.default_answer
|
||||
|
||||
else:
|
||||
remove_pkg = input(
|
||||
"\nAre you sure to remove {0} {1} [y/N]? ".format(
|
||||
str(len(self.removed)), msg))
|
||||
|
||||
except EOFError:
|
||||
raise SystemExit(1)
|
||||
|
||||
if remove_pkg in ["y", "Y"]:
|
||||
self._check_if_used(self.binary)
|
||||
|
||||
for rmv in self.removed:
|
||||
'''If package build and install with "slpkg -s sbo <package>"
|
||||
then looks in the log file for dependencies "/var/log/slpkg/dep",
|
||||
reads and removes all but remove only the package.
|
||||
'''
|
||||
|
||||
if (os.path.isfile(self.dep_path + rmv) and
|
||||
self.meta.del_deps in ["on", "ON"] or
|
||||
os.path.isfile(self.dep_path + rmv) and
|
||||
"--deps" in self.extra):
|
||||
dependencies = self._view_deps(self.dep_path, rmv)
|
||||
|
||||
if dependencies and self._rmv_deps_answer() in ["y",
|
||||
"Y"]:
|
||||
rmv_list += self._rmv_deps(dependencies, rmv)
|
||||
|
||||
else:
|
||||
rmv_list += self._rmv_pkg(rmv)
|
||||
|
||||
else:
|
||||
rmv_list += self._rmv_pkg(rmv)
|
||||
|
||||
# Prints all removed packages
|
||||
self._reference_rmvs(rmv_list)
|
||||
|
||||
|
@ -144,6 +167,7 @@ class PackageManager(Utils):
|
|||
"""
|
||||
if self.meta.remove_deps_answer in ["y", "Y"]:
|
||||
remove_dep = self.meta.remove_deps_answer
|
||||
|
||||
else:
|
||||
try:
|
||||
remove_dep = input(
|
||||
|
@ -152,6 +176,7 @@ class PackageManager(Utils):
|
|||
print()
|
||||
except EOFError:
|
||||
raise SystemExit("\n")
|
||||
|
||||
return remove_dep
|
||||
|
||||
def _get_removed(self):
|
||||
|
@ -159,38 +184,50 @@ class PackageManager(Utils):
|
|||
"""
|
||||
extra = self.extra
|
||||
removed, packages, pkg = [], [], ""
|
||||
|
||||
if "--tag" in extra:
|
||||
|
||||
for pkg in find_package("", self.meta.pkg_path):
|
||||
|
||||
for tag in self.binary:
|
||||
|
||||
if pkg.endswith(tag):
|
||||
removed.append(split_package(pkg)[0])
|
||||
packages.append(pkg)
|
||||
pkg = ""
|
||||
extra = ""
|
||||
|
||||
elif "--third-party" in extra:
|
||||
slack_packages, slack_names = slackware_repository()
|
||||
slpkg_pkg = self.meta.__all__ + "-" + self.meta.__version__
|
||||
binary = self.binary
|
||||
|
||||
for pkg in find_package("", self.meta.pkg_path):
|
||||
slack_name = split_package(pkg)[0]
|
||||
|
||||
for tag in binary:
|
||||
|
||||
if (slack_name not in slack_names and
|
||||
slpkg_pkg not in pkg and tag in pkg):
|
||||
removed.append(split_package(pkg)[0])
|
||||
packages.append(pkg)
|
||||
pkg = ""
|
||||
extra = ""
|
||||
|
||||
else:
|
||||
for pkg in self.binary:
|
||||
name = GetFromInstalled(pkg).name()
|
||||
ver = GetFromInstalled(pkg).version()
|
||||
package = find_package(f"{name}-{ver}-", self.meta.pkg_path)
|
||||
|
||||
if pkg and name == pkg:
|
||||
removed.append(pkg)
|
||||
packages.append(package[0])
|
||||
|
||||
if not removed:
|
||||
self.msg.pkg_not_found("", pkg, "Can't remove", "\n")
|
||||
raise SystemExit(1)
|
||||
|
||||
return removed, packages
|
||||
|
||||
def _view_removed(self):
|
||||
|
@ -199,6 +236,7 @@ class PackageManager(Utils):
|
|||
print("Packages with name matching [ {0}{1}{2} ]\n".format(
|
||||
self.cyan, ", ".join(self.binary), self.endc))
|
||||
removed, packages = self._get_removed()
|
||||
|
||||
if packages and "--checklist" in self.extra:
|
||||
removed = []
|
||||
text = "Press 'spacebar' to unchoose packages from the remove"
|
||||
|
@ -210,13 +248,16 @@ class PackageManager(Utils):
|
|||
for rmv in pkgs:
|
||||
removed.append(split_package(rmv)[0])
|
||||
self.meta.default_answer = "y"
|
||||
|
||||
else:
|
||||
for rmv, pkg in zip(removed, packages):
|
||||
self._sizes(pkg)
|
||||
print(f"[ {self.red}delete{self.endc} ] --> "
|
||||
f"[ {self.file_size} ] - {pkg}")
|
||||
|
||||
self._calc_sizes()
|
||||
self._remove_summary()
|
||||
|
||||
if "--third-party" in self.extra:
|
||||
print()
|
||||
self.msg.template(78)
|
||||
|
@ -225,6 +266,7 @@ class PackageManager(Utils):
|
|||
" updated the packages \n| lists. Run the command"
|
||||
" 'slpkg update' and 'slpkg -c slack --upgrade'")
|
||||
self.msg.template(78)
|
||||
|
||||
return removed
|
||||
|
||||
def _calc_sizes(self):
|
||||
|
@ -233,6 +275,7 @@ class PackageManager(Utils):
|
|||
if self.size > 1024:
|
||||
self.unit = "Mb"
|
||||
self.size = (self.size / 1024)
|
||||
|
||||
if self.size > 1024:
|
||||
self.unit = "Gb"
|
||||
self.size = (self.size / 1024)
|
||||
|
@ -252,13 +295,18 @@ class PackageManager(Utils):
|
|||
self.size = 0
|
||||
packages = []
|
||||
dependencies = (self.read_file(path + package)).splitlines()
|
||||
|
||||
for dep in dependencies:
|
||||
|
||||
if GetFromInstalled(dep).name():
|
||||
ver = GetFromInstalled(dep).version()
|
||||
packages.append(f"{dep}-{ver}")
|
||||
|
||||
else:
|
||||
dependencies.remove(dep)
|
||||
|
||||
if packages:
|
||||
|
||||
if "--checklist" in self.extra:
|
||||
deps, dependencies = [], []
|
||||
text = "Found dependencies for the package {0}".format(package)
|
||||
|
@ -269,6 +317,7 @@ class PackageManager(Utils):
|
|||
for d in deps:
|
||||
dependencies.append("-".join(d.split("-")[:-1]))
|
||||
self.meta.remove_deps_answer = "y"
|
||||
|
||||
else:
|
||||
print() # new line at start
|
||||
self.msg.template(78)
|
||||
|
@ -283,6 +332,7 @@ class PackageManager(Utils):
|
|||
print("| {0}Size of removed dependencies {1} {2}{3}".format(
|
||||
self.grey, round(self.size, 2), self.unit, self.endc))
|
||||
self.msg.template(78)
|
||||
|
||||
return dependencies
|
||||
|
||||
def _removepkg(self, package):
|
||||
|
@ -290,8 +340,10 @@ class PackageManager(Utils):
|
|||
"""
|
||||
try:
|
||||
subprocess.call(f"removepkg {self.flag} {package}", shell=True)
|
||||
|
||||
if os.path.isfile(self.dep_path + package):
|
||||
os.remove(self.dep_path + package) # remove log
|
||||
|
||||
except subprocess.CalledProcessError as er:
|
||||
raise SystemExit(er)
|
||||
|
||||
|
@ -300,22 +352,28 @@ class PackageManager(Utils):
|
|||
"""
|
||||
removes = []
|
||||
dependencies.append(package)
|
||||
|
||||
self._check_if_used(dependencies)
|
||||
|
||||
for dep in dependencies:
|
||||
|
||||
if dep not in self.skip and GetFromInstalled(dep).name():
|
||||
ver = GetFromInstalled(dep).version()
|
||||
removes.append(f"{dep}-{ver}")
|
||||
self._removepkg(dep)
|
||||
|
||||
return removes
|
||||
|
||||
def _rmv_pkg(self, package):
|
||||
"""Removes one signle package
|
||||
"""
|
||||
removes = []
|
||||
|
||||
if GetFromInstalled(package).name() and package not in self.skip:
|
||||
ver = GetFromInstalled(package).version()
|
||||
removes.append(f"{package}-{ver}")
|
||||
self._removepkg(package)
|
||||
|
||||
return removes
|
||||
|
||||
def _skip_remove(self):
|
||||
|
@ -329,7 +387,9 @@ class PackageManager(Utils):
|
|||
self.skip = input(" > ").split()
|
||||
except EOFError:
|
||||
raise SystemExit("\n")
|
||||
|
||||
for s in self.skip:
|
||||
|
||||
if s in self.removed:
|
||||
self.removed.remove(s)
|
||||
|
||||
|
@ -338,15 +398,20 @@ class PackageManager(Utils):
|
|||
before removed"""
|
||||
if "--check-deps" in self.extra:
|
||||
package, dependency, pkg_dep = [], [], []
|
||||
|
||||
for pkg in find_package("", self.dep_path):
|
||||
deps = self.read_file(self.dep_path + pkg)
|
||||
|
||||
for rmv in removes:
|
||||
|
||||
if GetFromInstalled(rmv).name() and rmv in deps.split():
|
||||
pkg_dep.append(f"{rmv} is dependency of the "
|
||||
f"package --> {pkg}")
|
||||
package.append(pkg)
|
||||
dependency.append(rmv)
|
||||
|
||||
if package:
|
||||
|
||||
if "--checklist" in self.extra:
|
||||
text = ("Press 'spacebar' to choose packages for the"
|
||||
" remove exception")
|
||||
|
@ -354,13 +419,16 @@ class PackageManager(Utils):
|
|||
status = False
|
||||
choose = DialogUtil(pkg_dep, text, " !!! WARNING !!! ",
|
||||
backtitle, status).checklist()
|
||||
|
||||
for pkg in choose:
|
||||
self.skip.append(pkg.split()[0])
|
||||
|
||||
else:
|
||||
self.msg.template(78)
|
||||
print("| {0}{1}{2}".format(
|
||||
self.red, " " * 30 + "!!! WARNING !!!", self.endc))
|
||||
self.msg.template(78)
|
||||
|
||||
for p, d in zip(package, dependency):
|
||||
print(f"| {self.yellow}{d}{self.endc} is dependency "
|
||||
f"of the package --> {self.green}{p}{self.endc}")
|
||||
|
@ -373,15 +441,21 @@ class PackageManager(Utils):
|
|||
print()
|
||||
self.msg.template(78)
|
||||
msg_pkg = "package"
|
||||
|
||||
if len(removes) > 1:
|
||||
msg_pkg = "packages"
|
||||
|
||||
print(f"| Total {len(removes)} {msg_pkg} removed")
|
||||
self.msg.template(78)
|
||||
|
||||
for pkg in removes:
|
||||
|
||||
if not GetFromInstalled(pkg).name():
|
||||
print(f"| Package {pkg} removed")
|
||||
|
||||
else:
|
||||
print(f"| Package {pkg} not found")
|
||||
|
||||
self.msg.template(78)
|
||||
print() # new line at end
|
||||
|
||||
|
@ -391,36 +465,47 @@ class PackageManager(Utils):
|
|||
matching, packages = 0, []
|
||||
pkg_cache, match_cache = "", ""
|
||||
slack_packages, slack_names = slackware_repository()
|
||||
|
||||
print("Packages with matching name [ {0}{1}{2} ]\n".format(
|
||||
self.cyan, ", ".join(self.binary), self.endc))
|
||||
|
||||
for pkg in self.binary:
|
||||
|
||||
for match in find_package("", self.meta.pkg_path):
|
||||
pkg_cache = pkg
|
||||
match_cache = match
|
||||
split_name = split_package(match)[0]
|
||||
|
||||
if "--case-ins" in flag:
|
||||
pkg_cache = pkg.lower()
|
||||
match_cache = match.lower()
|
||||
|
||||
if ("--third-party" in flag and not self.binary and
|
||||
split_name not in slack_names):
|
||||
packages.append(match)
|
||||
|
||||
if ("--third-party" in flag and pkg_cache in match_cache and
|
||||
split_name not in slack_names):
|
||||
packages.append(match)
|
||||
|
||||
if pkg_cache in match_cache and not flag:
|
||||
packages.append(match)
|
||||
|
||||
if ("--case-ins" in flag and "--third-party" not in flag and
|
||||
pkg_cache in match_cache):
|
||||
packages.append(match)
|
||||
|
||||
for pkgs in packages:
|
||||
matching += 1
|
||||
self._sizes(pkgs)
|
||||
print(f"[ {self.green}installed{self.endc} ] "
|
||||
f"[ {self.file_size} ] - {pkgs}")
|
||||
|
||||
if matching == 0:
|
||||
message = "Can't find"
|
||||
self.msg.pkg_not_found("", ", ".join(self.binary), message, "\n")
|
||||
raise SystemExit(1)
|
||||
|
||||
else:
|
||||
self._calc_sizes()
|
||||
print("\nFound summary")
|
||||
|
@ -435,12 +520,15 @@ class PackageManager(Utils):
|
|||
"""
|
||||
data = self.read_file(self.meta.pkg_path + package)
|
||||
for line in data.splitlines():
|
||||
|
||||
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
|
||||
digit = float((''.join(re.findall(
|
||||
r"[-+]?\d+[\.]?\d*[eE]?[-+]?\d*", line[26:]))))
|
||||
self.file_size = line[26:].strip()
|
||||
|
||||
if "M" in line[26:]:
|
||||
self.size += digit * 1024
|
||||
|
||||
else:
|
||||
self.size += digit
|
||||
break
|
||||
|
@ -452,16 +540,21 @@ class PackageManager(Utils):
|
|||
name = GetFromInstalled(pkg).name()
|
||||
ver = GetFromInstalled(pkg).version()
|
||||
find = find_package(f"{name}-{ver}-", self.meta.pkg_path)
|
||||
|
||||
if find:
|
||||
package = self.read_file(
|
||||
self.meta.pkg_path + "".join(find))
|
||||
print(package)
|
||||
|
||||
else:
|
||||
message = "Can't dislpay"
|
||||
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = ""
|
||||
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
|
||||
self.msg.pkg_not_found(bol, pkg, message, eol)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
@ -470,16 +563,21 @@ class PackageManager(Utils):
|
|||
"""
|
||||
tty_size = os.popen("stty size", "r").read().split()
|
||||
row = int(tty_size[0]) - 2
|
||||
|
||||
try:
|
||||
all_installed_names = []
|
||||
index, page, pkg_list = 0, row, []
|
||||
r = self.list_lib(repo)
|
||||
pkg_list = self.list_greps(repo, r)[0]
|
||||
all_installed_names = self.list_of_installed(repo, name)
|
||||
|
||||
print()
|
||||
|
||||
for pkg in sorted(pkg_list):
|
||||
pkg = self._splitting_packages(pkg, repo, name)
|
||||
|
||||
if installed and repo:
|
||||
|
||||
if pkg in all_installed_names:
|
||||
pkg = f"{self.green}{pkg}{self.endc}"
|
||||
|
||||
|
@ -487,16 +585,20 @@ class PackageManager(Utils):
|
|||
index += 1
|
||||
pkg = self.list_color_tag(pkg)
|
||||
print(f"{self.grey}{index}:{self.endc} {pkg}")
|
||||
|
||||
if index == page:
|
||||
read = input(f"\nPress {self.cyan}Enter{self.endc} to "
|
||||
f"continue... ")
|
||||
|
||||
if read in ["Q", "q"]:
|
||||
break
|
||||
print() # new line after page
|
||||
page += row
|
||||
|
||||
else:
|
||||
print(pkg)
|
||||
print() # new line at end
|
||||
|
||||
except (EOFError, KeyboardInterrupt, BrokenPipeError, IOError):
|
||||
raise SystemExit(1)
|
||||
|
||||
|
@ -505,8 +607,10 @@ class PackageManager(Utils):
|
|||
"""
|
||||
if name and repo != "sbo":
|
||||
pkg = split_package(pkg)[0]
|
||||
|
||||
elif not name and repo != "sbo":
|
||||
pkg = pkg[:-4]
|
||||
|
||||
return pkg
|
||||
|
||||
def list_greps(self, repo, packages):
|
||||
|
@ -514,29 +618,40 @@ class PackageManager(Utils):
|
|||
"""
|
||||
pkg_list, pkg_size = [], []
|
||||
for line in packages.splitlines():
|
||||
|
||||
if repo == "sbo":
|
||||
|
||||
if line.startswith("SLACKBUILD NAME: "):
|
||||
pkg_list.append(line[17:].strip())
|
||||
pkg_size.append("0 K")
|
||||
|
||||
else:
|
||||
|
||||
if line.startswith("PACKAGE NAME: "):
|
||||
pkg_list.append(line[15:].strip())
|
||||
|
||||
if line.startswith("PACKAGE SIZE (compressed): "):
|
||||
pkg_size.append(line[26:].strip())
|
||||
|
||||
if repo == "alien" or repo == "ktown":
|
||||
return alien_filter(pkg_list, pkg_size)
|
||||
|
||||
return pkg_list, pkg_size
|
||||
|
||||
def list_lib(self, repo):
|
||||
"""Returns package lists
|
||||
"""
|
||||
packages = ""
|
||||
|
||||
if repo == "sbo":
|
||||
|
||||
if (os.path.isfile(
|
||||
self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT")):
|
||||
packages = self.read_file(f"{self.meta.lib_path}"
|
||||
"sbo_repo/SLACKBUILDS.TXT")
|
||||
|
||||
else:
|
||||
|
||||
if (os.path.isfile(
|
||||
self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):
|
||||
packages = self.read_file(f"{self.meta.lib_path}"
|
||||
|
@ -548,10 +663,13 @@ class PackageManager(Utils):
|
|||
"""
|
||||
name = GetFromInstalled(pkg).name()
|
||||
find = f"{name}-"
|
||||
|
||||
if pkg.endswith(".txz") or pkg.endswith(".tgz"):
|
||||
find = pkg[:-4]
|
||||
|
||||
if find_package(find, self.meta.pkg_path):
|
||||
pkg = f"{self.green}{pkg}{self.endc}"
|
||||
|
||||
return pkg
|
||||
|
||||
def list_of_installed(self, repo, name):
|
||||
|
@ -559,15 +677,21 @@ class PackageManager(Utils):
|
|||
"""
|
||||
all_installed_names = []
|
||||
all_installed_packages = find_package("", self.meta.pkg_path)
|
||||
|
||||
for inst in all_installed_packages:
|
||||
|
||||
if repo == "sbo" and inst.endswith("_SBo"):
|
||||
name = split_package(inst)[0]
|
||||
all_installed_names.append(name)
|
||||
|
||||
else:
|
||||
|
||||
if name:
|
||||
all_installed_names.append(split_package(inst)[0])
|
||||
|
||||
else:
|
||||
all_installed_names.append(inst)
|
||||
|
||||
return all_installed_names
|
||||
|
||||
|
||||
|
@ -576,10 +700,13 @@ def alien_filter(packages, sizes):
|
|||
alien repository
|
||||
"""
|
||||
cache, npkg, nsize = [], [], []
|
||||
|
||||
for p, s in zip(packages, sizes):
|
||||
name = split_package(p)[0]
|
||||
|
||||
if name not in cache:
|
||||
cache.append(name)
|
||||
npkg.append(p)
|
||||
nsize.append(s)
|
||||
|
||||
return npkg, nsize
|
||||
|
|
|
@ -51,27 +51,35 @@ class FindFromRepos:
|
|||
self.msg.template(78)
|
||||
print(f"| Repository Package {' ' * 54}Size")
|
||||
self.msg.template(78)
|
||||
|
||||
for repo in _meta_.repositories:
|
||||
PACKAGES_TXT = PackageManager(pkg).list_lib(repo)
|
||||
packages, sizes = PackageManager(pkg).list_greps(repo,
|
||||
PACKAGES_TXT)
|
||||
for find, size in zip(packages, sizes):
|
||||
|
||||
for p in pkg:
|
||||
|
||||
if "--case-ins" in flag:
|
||||
self.p_cache = p.lower()
|
||||
self.find_cache = find.lower()
|
||||
|
||||
else:
|
||||
self.p_cache = p
|
||||
self.find_cache = find
|
||||
|
||||
if self.p_cache in self.find_cache:
|
||||
|
||||
if self.cache != repo:
|
||||
self.count_repo += 1
|
||||
self.cache = repo
|
||||
self.count_pkg += 1
|
||||
ver = self.sbo_version(repo, find)
|
||||
|
||||
print(f" {self.cyan}{repo}{self.endc}"
|
||||
f"{' ' * (11 - len(repo))}{find + ver} "
|
||||
f"{' ' * (54 -len(find + ver))}{size:>11}")
|
||||
|
||||
print("\nFound summary")
|
||||
print("=" * 79)
|
||||
print(f"{self.grey}Total found {self.count_pkg} packages in "
|
||||
|
@ -81,6 +89,8 @@ class FindFromRepos:
|
|||
"""Adds version to SBo packages
|
||||
"""
|
||||
ver = ""
|
||||
|
||||
if repo == "sbo":
|
||||
ver = f"-{SBoGrep(find).version()}"
|
||||
|
||||
return ver
|
||||
|
|
|
@ -33,6 +33,7 @@ def delete_package(path, packages):
|
|||
"""Deletes downloaded packages
|
||||
"""
|
||||
if _meta_.del_all in ["on", "ON"]:
|
||||
|
||||
for pkg in packages:
|
||||
os.remove(f"{path}{pkg}")
|
||||
|
||||
|
|
|
@ -64,15 +64,21 @@ Keys: SPACE select or deselect the highlighted repositories,
|
|||
ENTER press the focused button
|
||||
|
||||
Disabled <---------------- REPOSITORIES ----------------> Enabled"""
|
||||
|
||||
self.read_enabled()
|
||||
self.read_disabled()
|
||||
|
||||
text, title, backtitle, status = keys, " Repositories ", "", False
|
||||
|
||||
self.selected = DialogUtil(self.disabled, text, title, backtitle,
|
||||
status).buildlist(self.enabled)
|
||||
|
||||
if self.selected is not None:
|
||||
self.update_repos()
|
||||
|
||||
else:
|
||||
self.selected = self.enabled
|
||||
|
||||
self.clear_screen()
|
||||
self.reference()
|
||||
|
||||
|
@ -81,11 +87,14 @@ Keys: SPACE select or deselect the highlighted repositories,
|
|||
"""
|
||||
for line in self.conf.splitlines():
|
||||
line = line.lstrip()
|
||||
|
||||
if self.tag in line:
|
||||
self.tag_line = True
|
||||
|
||||
if (line and self.tag_line and not line.startswith("#") and
|
||||
self.tag not in line):
|
||||
self.enabled.append(line)
|
||||
|
||||
self.tag_line = False
|
||||
|
||||
def read_disabled(self):
|
||||
|
@ -93,11 +102,14 @@ Keys: SPACE select or deselect the highlighted repositories,
|
|||
"""
|
||||
for line in self.conf.splitlines():
|
||||
line = line.lstrip()
|
||||
|
||||
if self.tag in line:
|
||||
self.tag_line = True
|
||||
|
||||
if self.tag_line and line.startswith("#"):
|
||||
line = "".join(line.split("#")).strip()
|
||||
self.disabled.append(line)
|
||||
|
||||
self.tag_line = False
|
||||
|
||||
def update_repos(self):
|
||||
|
@ -106,21 +118,28 @@ Keys: SPACE select or deselect the highlighted repositories,
|
|||
"""
|
||||
with open(f"{self.meta.conf_path}"
|
||||
f"{self.repositories_conf}", "w") as new_conf:
|
||||
|
||||
for line in self.conf.splitlines():
|
||||
line = line.lstrip()
|
||||
|
||||
if self.tag in line:
|
||||
self.tag_line = True
|
||||
|
||||
if self.tag_line and line.startswith("#"):
|
||||
repo = "".join(line.split("#")).strip()
|
||||
|
||||
if repo in self.selected:
|
||||
new_conf.write(line.replace(line, f"{repo}\n"))
|
||||
continue
|
||||
|
||||
if (self.tag_line and not line.startswith("#") and
|
||||
line != self.tag):
|
||||
repo = line.strip()
|
||||
|
||||
if repo not in self.selected:
|
||||
new_conf.write(line.replace(line, f"# {line}\n"))
|
||||
continue
|
||||
|
||||
new_conf.write(f"{line}\n")
|
||||
|
||||
def clear_screen(self):
|
||||
|
@ -132,12 +151,15 @@ Keys: SPACE select or deselect the highlighted repositories,
|
|||
"""Reference enable repositories
|
||||
"""
|
||||
total_enabled = ", ".join(self.selected)
|
||||
|
||||
if len(total_enabled) < 1:
|
||||
total_enabled = (f"{self.red}Are you crazy? This is a package "
|
||||
f"manager for packages :p{self.endc}")
|
||||
|
||||
self.msg.template(78)
|
||||
print("| Enabled repositories:")
|
||||
self.msg.template(78)
|
||||
|
||||
print(f"| {total_enabled}")
|
||||
self.msg.template(78)
|
||||
print(f"{self.grey}Total {len(self.selected)}/"
|
||||
|
|
|
@ -39,6 +39,7 @@ class RepoInfo(Utils):
|
|||
self.red = _meta_.color["RED"]
|
||||
self.endc = _meta_.color["ENDC"]
|
||||
self.repo = Repo()
|
||||
|
||||
self.form = {
|
||||
"Last updated:": "",
|
||||
"Number of packages:": "",
|
||||
|
@ -49,10 +50,12 @@ class RepoInfo(Utils):
|
|||
"Total compressed packages:": "",
|
||||
"Total uncompressed packages:": ""
|
||||
}
|
||||
|
||||
self.meta = _meta_
|
||||
self.all_repos = self.repo.default_repository()
|
||||
self.all_repos["slack"] = self.repo.slack()
|
||||
self.all_repos.update(self.repo.custom_repository())
|
||||
|
||||
del RepoList().all_repos
|
||||
|
||||
def view(self, repo):
|
||||
|
@ -89,11 +92,13 @@ class RepoInfo(Utils):
|
|||
for line in (self.read_file(
|
||||
f"{self.meta.lib_path}sbo_repo/SLACKBUILDS."
|
||||
"TXT").splitlines()):
|
||||
|
||||
if line.startswith("SLACKBUILD NAME: "):
|
||||
sum_sbo_pkgs += 1
|
||||
|
||||
changelog_txt = self.read_file(
|
||||
f"{self.meta.log_path}sbo/ChangeLog.txt")
|
||||
|
||||
last_upd = changelog_txt.split("\n", 1)[0]
|
||||
|
||||
self.form["Repo id:"] = repo
|
||||
|
@ -114,18 +119,23 @@ class RepoInfo(Utils):
|
|||
f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT"
|
||||
|
||||
for line in self.read_file(f).splitlines():
|
||||
|
||||
if line.startswith("PACKAGES.TXT;"):
|
||||
last_upd = line[14:].strip()
|
||||
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
sum_pkgs += 1
|
||||
|
||||
if line.startswith("PACKAGE SIZE (compressed): "):
|
||||
size.append(line[28:-2].strip())
|
||||
|
||||
if line.startswith("PACKAGE SIZE (uncompressed): "):
|
||||
unsize.append(line[30:-2].strip())
|
||||
|
||||
if repo in ["salix", "slackl"]:
|
||||
log = self.read_file(
|
||||
f"{self.meta.log_path}{repo}/ChangeLog.txt")
|
||||
|
||||
last_upd = log.split("\n", 1)[0]
|
||||
|
||||
return [sum_pkgs, size, unsize, last_upd]
|
||||
|
|
|
@ -52,17 +52,22 @@ class RepoList:
|
|||
"Default", " " * 3,
|
||||
"Status"))
|
||||
self.msg.template(78)
|
||||
|
||||
for repo_id, repo_URL in sorted(self.all_repos.items()):
|
||||
status, COLOR = "disabled", self.red
|
||||
default = "yes"
|
||||
|
||||
if len(repo_URL) > 49:
|
||||
repo_URL = repo_URL[:48] + "~"
|
||||
|
||||
if repo_id in self.meta.repositories:
|
||||
def_cnt += 1
|
||||
status, COLOR = "enabled", self.green
|
||||
|
||||
if repo_id not in self.meta.default_repositories:
|
||||
cus_cnt += 1
|
||||
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)),
|
||||
|
@ -73,6 +78,7 @@ class RepoList:
|
|||
print("=" * 79)
|
||||
print(f"{self.grey}{def_cnt}/{len(self.all_repos)} enabled default "
|
||||
f"repositories and {cus_cnt} custom.")
|
||||
|
||||
print("Edit the file '/etc/slpkg/repositories.conf' for enable "
|
||||
"and disable default\nrepositories or run 'slpkg "
|
||||
f"repo-enable' command.{self.endc}")
|
||||
|
|
|
@ -48,37 +48,50 @@ class Repo(Utils):
|
|||
repo_name = []
|
||||
if not url.endswith("/"):
|
||||
url += "/"
|
||||
|
||||
for line in self.custom_repositories_list.splitlines():
|
||||
line = line.lstrip()
|
||||
|
||||
if line and not line.startswith("#"):
|
||||
repo_name.append(line.split()[0])
|
||||
|
||||
if (repo in self.meta.repositories or repo in repo_name or
|
||||
repo in self.meta.default_repositories):
|
||||
|
||||
raise SystemExit(f"\nRepository name '{repo}' exist, "
|
||||
f"select different name.\n"
|
||||
f"View all repositories with command 'slpkg "
|
||||
f"repo-list'.\n")
|
||||
|
||||
elif len(repo) > 6:
|
||||
|
||||
raise SystemExit("\nslpkg: Error: Maximum repository name length "
|
||||
"must be six (6) characters\n")
|
||||
|
||||
with open(self.custom_repo_file, "a") as repos:
|
||||
new_line = f" {repo}{' ' * (10 - len(repo))}{url}\n"
|
||||
repos.write(new_line)
|
||||
|
||||
print(f"\nRepository '{repo}' successfully added\n")
|
||||
|
||||
def remove(self, repo):
|
||||
"""Removes custom repository
|
||||
"""
|
||||
rem_repo = False
|
||||
|
||||
with open(self.custom_repo_file, "w") as repos:
|
||||
|
||||
for line in self.custom_repositories_list.splitlines():
|
||||
repo_name = line.split()[0]
|
||||
|
||||
if repo_name != repo:
|
||||
repos.write(f"{line}\n")
|
||||
|
||||
else:
|
||||
print(f"\nRepository '{repo}' successfully "
|
||||
"removed\n")
|
||||
rem_repo = True
|
||||
|
||||
if not rem_repo:
|
||||
print(f"\nRepository '{repo}' doesn't exist\n")
|
||||
|
||||
|
@ -88,19 +101,25 @@ class Repo(Utils):
|
|||
custom_dict_repo = {}
|
||||
for line in self.custom_repositories_list.splitlines():
|
||||
line = line.lstrip()
|
||||
|
||||
if not line.startswith("#"):
|
||||
custom_dict_repo[line.split()[0]] = line.split()[1]
|
||||
|
||||
return custom_dict_repo
|
||||
|
||||
def default_repository(self):
|
||||
"""Returns dictionary with default repo name and url
|
||||
"""
|
||||
default_dict_repo = {}
|
||||
|
||||
for line in self.default_repositories_list.splitlines():
|
||||
line = line.lstrip()
|
||||
|
||||
if not line.startswith("#"):
|
||||
|
||||
if line.split()[0] in self.DEFAULT_REPOS_NAMES:
|
||||
default_dict_repo[line.split()[0]] = line.split()[1]
|
||||
|
||||
else:
|
||||
raise SystemExit(f"\nslpkg: Error: Repository name "
|
||||
f"'{line.split()[0]}'"
|
||||
|
@ -113,15 +132,21 @@ class Repo(Utils):
|
|||
"""Official slackware repository
|
||||
"""
|
||||
default = "http://mirrors.slackware.com/slackware/"
|
||||
|
||||
if self.meta.arch.startswith("arm"):
|
||||
default = "http://ftp.arm.slackware.com/slackwarearm/"
|
||||
|
||||
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
|
||||
mirrors = self.read_file(
|
||||
f"{self.meta.conf_path}slackware-mirrors")
|
||||
|
||||
for line in mirrors.splitlines():
|
||||
line = line.rstrip()
|
||||
|
||||
if not line.startswith("#") and line:
|
||||
default = line.split()[-1]
|
||||
|
||||
if not default.endswith("/"):
|
||||
default += "/"
|
||||
|
||||
return default
|
||||
|
|
|
@ -46,11 +46,13 @@ class AutoBuild:
|
|||
self.files_exist()
|
||||
self.info_file()
|
||||
sources = self.sources
|
||||
|
||||
if len(sources) > 1 and self.sbo_sources != sources:
|
||||
sources = self.sbo_sources
|
||||
# If the list does not have the same order uses from .info
|
||||
# order.
|
||||
BuildPackage(self.script, sources, self.path, auto=True).build()
|
||||
|
||||
raise SystemExit()
|
||||
|
||||
def info_file(self):
|
||||
|
@ -66,7 +68,9 @@ class AutoBuild:
|
|||
if not os.path.isfile(self.path + self.script):
|
||||
raise SystemExit("\nslpkg: Error: SlackBuild archive.tar.gz "
|
||||
"not found\n")
|
||||
|
||||
for src in self.sources:
|
||||
|
||||
if not os.path.isfile(self.path + src):
|
||||
raise SystemExit(f"\nslpkg: Error: Source file '{src}' "
|
||||
f"not found\n")
|
||||
|
|
|
@ -39,15 +39,21 @@ class BuildNumber(Utils):
|
|||
|
||||
def get(self):
|
||||
num = "NO_BUILD"
|
||||
|
||||
if self.sbo_url:
|
||||
SlackBuild = URL(f"{self.sbo_url}"
|
||||
f"{self.pkg}.SlackBuild").get_request()
|
||||
|
||||
else:
|
||||
SlackBuild = self.read_file(f"{self.meta.build_path}{self.pkg}/"
|
||||
f"{self.pkg}.SlackBuild")
|
||||
|
||||
for line in SlackBuild.splitlines():
|
||||
|
||||
line = line.lstrip()
|
||||
|
||||
if line.startswith("BUILD="):
|
||||
num = re.findall(r"\d+", line)
|
||||
break
|
||||
|
||||
return "".join(num)
|
||||
|
|
|
@ -43,17 +43,22 @@ def sbo_upgrade(skip, flag):
|
|||
upgrade_names = []
|
||||
data = SBoGrep(name="").names()
|
||||
blacklist = list(black.get_black())
|
||||
|
||||
for pkg in sbo_list():
|
||||
name = split_package(pkg)[0]
|
||||
ver = split_package(pkg)[1]
|
||||
|
||||
if (name in data and name not in skip and name not in blacklist):
|
||||
sbo_package = f"{name}-{SBoGrep(name).version()}"
|
||||
package = f"{name}-{ver}"
|
||||
|
||||
if parse_version(sbo_package) > parse_version(package):
|
||||
upgrade_names.append(name)
|
||||
msg.done()
|
||||
|
||||
if "--checklist" in flag:
|
||||
upgrade_names = choose_upg(upgrade_names)
|
||||
|
||||
return upgrade_names
|
||||
|
||||
|
||||
|
@ -61,5 +66,6 @@ def sbo_list():
|
|||
"""Returns all SBo packages
|
||||
"""
|
||||
for pkg in os.listdir(_meta_.pkg_path):
|
||||
|
||||
if pkg.endswith("_SBo"):
|
||||
yield pkg
|
||||
|
|
|
@ -51,14 +51,20 @@ class Requires(BlackList):
|
|||
sys.setrecursionlimit(10000)
|
||||
dependencies = []
|
||||
requires = SBoGrep(name).requires()
|
||||
|
||||
if requires:
|
||||
|
||||
for req in requires:
|
||||
|
||||
# avoids adding %README% as dependency and if
|
||||
# requires in the blacklist
|
||||
if "%README%" not in req and req not in self.blacklist:
|
||||
dependencies.append(req)
|
||||
|
||||
self.deep_check(tuple(dependencies))
|
||||
|
||||
return self.dep_results
|
||||
|
||||
else:
|
||||
return []
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import sqlite3
|
||||
from slpkg.utils import Utils
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
from slpkg.models.models import SBoTable, session
|
||||
|
||||
|
||||
class SBoGrep(Utils):
|
||||
|
@ -35,14 +35,12 @@ class SBoGrep(Utils):
|
|||
self.meta = _meta_
|
||||
self.db = self.meta.db
|
||||
self.arch64 = "x86_64"
|
||||
self.sbo_db = f"{self.meta.lib_path}{self.db}"
|
||||
self.con = sqlite3.connect(self.sbo_db)
|
||||
self.cur = self.con.cursor()
|
||||
self.session = session
|
||||
|
||||
def _names_grabbing(self):
|
||||
"""Generator that collecting all packages names
|
||||
"""
|
||||
names = self.cur.execute("SELECT name FROM sbo").fetchall()
|
||||
names = self.session.query(SBoTable.name).all()
|
||||
for n in names:
|
||||
yield n[0]
|
||||
|
||||
|
@ -55,60 +53,61 @@ class SBoGrep(Utils):
|
|||
def source(self):
|
||||
"""Grabs sources downloads links
|
||||
"""
|
||||
source, source64 = self.cur.execute("""SELECT download, download64
|
||||
FROM sbo
|
||||
WHERE name = '{}'""".format(
|
||||
self.name)).fetchone()
|
||||
source, source64 = self.session.query(
|
||||
SBoTable.download, SBoTable.download64).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
return self._sorting_arch(source, source64)
|
||||
|
||||
def requires(self):
|
||||
"""Grabs package requirements
|
||||
"""
|
||||
requires = self.cur.execute("""SELECT requires
|
||||
FROM sbo
|
||||
WHERE name = '{}'""".format(
|
||||
self.name)).fetchone()
|
||||
requires = self.session.query(
|
||||
SBoTable.requires).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
return requires[0].split()
|
||||
|
||||
def version(self):
|
||||
"""Grabs package version
|
||||
"""
|
||||
version = self.cur.execute("""SELECT version
|
||||
FROM sbo
|
||||
WHERE name = '{}'""".format(
|
||||
self.name)).fetchone()
|
||||
version = self.session.query(
|
||||
SBoTable.version).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
return version[0]
|
||||
|
||||
def checksum(self):
|
||||
"""Grabs checksum string
|
||||
"""
|
||||
md5sum, md5sum64, = [], []
|
||||
mds5, md5s64 = self.cur.execute("""SELECT md5sum, md5sum64
|
||||
FROM sbo
|
||||
WHERE name = '{}'""".format(
|
||||
self.name)).fetchone()
|
||||
mds5, md5s64 = self.session.query(
|
||||
SBoTable.md5sum, SBoTable.md5sum64).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
if mds5:
|
||||
md5sum.append(mds5)
|
||||
if md5s64:
|
||||
md5sum64.append(md5s64)
|
||||
|
||||
return self._sorting_arch(md5sum, md5sum64)
|
||||
|
||||
def description(self):
|
||||
"""Grabs package description
|
||||
"""
|
||||
desc = self.cur.execute("""SELECT short_desc
|
||||
FROM sbo
|
||||
WHERE name = '{}'""".format(
|
||||
self.name)).fetchone()
|
||||
desc = self.session.query(
|
||||
SBoTable.short_description).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
return desc[0]
|
||||
|
||||
def files(self):
|
||||
"""Grabs files
|
||||
"""
|
||||
files = self.cur.execute("""SELECT files
|
||||
FROM sbo
|
||||
WHERE name = '{}'""".format(
|
||||
self.name)).fetchone()
|
||||
files = self.session.query(
|
||||
SBoTable.files).filter(
|
||||
SBoTable.name == self.name).first()
|
||||
|
||||
return files[0]
|
||||
|
||||
def _sorting_arch(self, arch, arch64):
|
||||
|
@ -116,4 +115,5 @@ class SBoGrep(Utils):
|
|||
"""
|
||||
if self.meta.arch == self.arch64 and arch64:
|
||||
return arch64
|
||||
|
||||
return arch
|
||||
|
|
|
@ -74,11 +74,14 @@ class SBoNetwork(BlackList, Utils):
|
|||
self._SOURCES = self.meta.SBo_SOURCES
|
||||
self.msg.reading()
|
||||
self.case_insensitive()
|
||||
|
||||
if "--checklist" in self.flag:
|
||||
self.with_checklist()
|
||||
|
||||
grep = SBoGrep(self.name)
|
||||
self.sbo_files = grep.files()
|
||||
self.sbo_url = sbo_search_pkg(self.name)
|
||||
|
||||
if self.sbo_url:
|
||||
self.sbo_desc = grep.description()[len(self.name) + 2:-1]
|
||||
self.source_dwn = grep.source().split()
|
||||
|
@ -86,6 +89,7 @@ class SBoNetwork(BlackList, Utils):
|
|||
self.sbo_dwn = SBoLink(self.sbo_url).tar_gz()
|
||||
self.sbo_version = grep.version()
|
||||
self.dwn_srcs = self.sbo_dwn.split() + self.source_dwn
|
||||
|
||||
if "--checklist" not in self.flag or not self.sbo_url and self.name:
|
||||
self.msg.done()
|
||||
|
||||
|
@ -101,8 +105,11 @@ class SBoNetwork(BlackList, Utils):
|
|||
if self.sbo_url and self.name not in self.get_black():
|
||||
self.prgnam = f"{self.name}-{self.sbo_version}"
|
||||
self.view_sbo()
|
||||
|
||||
while True:
|
||||
|
||||
self.read_choice()
|
||||
|
||||
choice = {
|
||||
"r": self.choice_README,
|
||||
"R": self.choice_README,
|
||||
|
@ -128,10 +135,12 @@ class SBoNetwork(BlackList, Utils):
|
|||
"quit": self.choice_quit,
|
||||
"Q": self.choice_quit
|
||||
}
|
||||
|
||||
try:
|
||||
choice[self.choice]()
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
else:
|
||||
self.msg.pkg_not_found("\n", self.name, "Can't view", "\n")
|
||||
raise SystemExit(1)
|
||||
|
@ -140,9 +149,12 @@ class SBoNetwork(BlackList, Utils):
|
|||
"""Matching packages distinguish between uppercase and
|
||||
lowercase
|
||||
"""
|
||||
|
||||
if "--case-ins" in self.flag:
|
||||
data_dict = self.case_sensitive(self.data)
|
||||
|
||||
for key, value in data_dict.items():
|
||||
|
||||
if key == self.name.lower():
|
||||
self.name = value
|
||||
|
||||
|
@ -174,11 +186,13 @@ class SBoNetwork(BlackList, Utils):
|
|||
"quit": "quit",
|
||||
"Q": "quit"
|
||||
}
|
||||
|
||||
try:
|
||||
message = " Choose an option > "
|
||||
self.choice = input(f"{self.grey}{message}{self.endc}")
|
||||
except EOFError:
|
||||
raise SystemExit('\n')
|
||||
|
||||
try:
|
||||
print("{0}\x1b[1A{1}{2}{3}\n".format(
|
||||
" " * len(message), self.cyan, commands[self.choice],
|
||||
|
@ -233,15 +247,19 @@ class SBoNetwork(BlackList, Utils):
|
|||
"""Download, build and install the package
|
||||
"""
|
||||
pkg_security([self.name])
|
||||
|
||||
if not find_package(self.prgnam, self.meta.pkg_path):
|
||||
self.build()
|
||||
self.install()
|
||||
delete_folder(self.build_folder)
|
||||
|
||||
raise SystemExit()
|
||||
|
||||
else:
|
||||
self.msg.template(78)
|
||||
self.msg.pkg_found(self.prgnam)
|
||||
self.msg.template(78)
|
||||
|
||||
raise SystemExit()
|
||||
|
||||
def choice_clear_screen(self):
|
||||
|
@ -260,10 +278,12 @@ class SBoNetwork(BlackList, Utils):
|
|||
"""
|
||||
sbo_url = self.sbo_url.replace("/slackbuilds/", "/repository/")
|
||||
br1, br2, fix_sp = "", "", " "
|
||||
|
||||
if self.meta.use_colors in ["off", "OFF"]:
|
||||
br1 = "("
|
||||
br2 = ")"
|
||||
fix_sp = ""
|
||||
|
||||
print() # new line at start
|
||||
self.msg.template(78)
|
||||
print(f"| {' ' * 28}{self.grey}SlackBuilds Repository{self.endc}")
|
||||
|
@ -280,8 +300,10 @@ class SBoNetwork(BlackList, Utils):
|
|||
print(f"| {self.red}R{self.endc}{br2}EADME View the README file")
|
||||
print(f"| {self.red}S{self.endc}{br2}lackBuild View the .SlackBuild file")
|
||||
print(f"| In{br1}{self.red}f{self.endc}{br2}o{fix_sp} View the .info file")
|
||||
|
||||
if "doinst.sh" in self.sbo_files.split():
|
||||
print(f"| D{br1}{self.red}o{self.endc}{br2}inst.sh{fix_sp} View the doinst.sh file")
|
||||
|
||||
print(f"| {self.red}D{self.endc}{br2}ownload Download this package")
|
||||
print(f"| {self.red}B{self.endc}{br2}uild Download and build")
|
||||
print(f"| {self.red}I{self.endc}{br2}nstall Download/Build/Install")
|
||||
|
@ -293,23 +315,29 @@ class SBoNetwork(BlackList, Utils):
|
|||
"""Using dialog and checklist option
|
||||
"""
|
||||
data = []
|
||||
|
||||
if not self.name:
|
||||
data = self.data
|
||||
|
||||
else:
|
||||
for name in self.data:
|
||||
if self.name in name:
|
||||
data.append(name)
|
||||
|
||||
if data:
|
||||
text = "Press 'spacebar' to choose SlackBuild for view"
|
||||
title = " SlackBuilds.org "
|
||||
backtitle = f"{_meta_.__all__} {_meta_.__version__}"
|
||||
status = False
|
||||
pkg = DialogUtil(data, text, title, backtitle, status).checklist()
|
||||
|
||||
if pkg and len(pkg) > 1:
|
||||
os.system("clear")
|
||||
raise SystemExit("\nslpkg: Error: Choose only one package\n")
|
||||
|
||||
if pkg is None:
|
||||
raise SystemExit(1)
|
||||
|
||||
self.name = "".join(pkg)
|
||||
os.system("clear")
|
||||
|
||||
|
@ -326,8 +354,10 @@ class SBoNetwork(BlackList, Utils):
|
|||
lines = sum(1 for line in page.splitlines())
|
||||
diff = rows - lines
|
||||
fill = "\n" * diff
|
||||
|
||||
if diff > 0:
|
||||
return fill
|
||||
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
@ -337,6 +367,7 @@ class SBoNetwork(BlackList, Utils):
|
|||
"""
|
||||
self.FAULT = ""
|
||||
UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
|
||||
if "".join(self.source_dwn) in UNST:
|
||||
self.FAULT = "".join(self.source_dwn)
|
||||
|
||||
|
@ -345,27 +376,38 @@ class SBoNetwork(BlackList, Utils):
|
|||
"""
|
||||
pkg_security([self.name])
|
||||
self.error_uns()
|
||||
|
||||
if self.FAULT:
|
||||
print()
|
||||
self.msg.template(78)
|
||||
print(f"| Package {self.prgnam} {self.red} {self.FAULT} "
|
||||
f"{self.endc}")
|
||||
self.msg.template(78)
|
||||
|
||||
else:
|
||||
sources = []
|
||||
|
||||
if not os.path.exists(self.meta.build_path):
|
||||
os.makedirs(self.meta.build_path)
|
||||
|
||||
if not os.path.exists(self._SOURCES):
|
||||
os.makedirs(self._SOURCES)
|
||||
|
||||
os.chdir(self.meta.build_path)
|
||||
|
||||
Download(self.meta.build_path, self.sbo_dwn.split(),
|
||||
repo="sbo").start()
|
||||
|
||||
Download(self._SOURCES, self.source_dwn, repo="sbo").start()
|
||||
|
||||
script = self.sbo_dwn.split("/")[-1]
|
||||
|
||||
for src in self.source_dwn:
|
||||
sources.append(src.split("/")[-1])
|
||||
|
||||
BuildPackage(script, sources, self.meta.build_path,
|
||||
auto=False).build()
|
||||
|
||||
slack_package(self.prgnam) # check if build
|
||||
|
||||
def install(self):
|
||||
|
|
|
@ -60,14 +60,18 @@ class QueuePkgs(Utils):
|
|||
"# In this file, you can create a list of\n",
|
||||
"# packages you want to build or install.\n",
|
||||
"#\n"]
|
||||
|
||||
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):
|
||||
with open(self.queue_list, "w") as queue:
|
||||
for line in queue_file:
|
||||
queue.write(line)
|
||||
|
||||
self.queued = self.read_file(self.queue_list)
|
||||
|
||||
def packages(self):
|
||||
|
@ -75,7 +79,9 @@ class QueuePkgs(Utils):
|
|||
file.
|
||||
"""
|
||||
for read in self.queued.splitlines():
|
||||
|
||||
read = read.lstrip()
|
||||
|
||||
if not read.startswith("#"):
|
||||
yield read.replace("\n", "")
|
||||
|
||||
|
@ -83,8 +89,10 @@ class QueuePkgs(Utils):
|
|||
"""Prints packages from queue
|
||||
"""
|
||||
print("Packages in the queue:")
|
||||
|
||||
for pkg in self.packages():
|
||||
print(f"{self.green}{pkg}{self.endc}")
|
||||
|
||||
print()
|
||||
|
||||
def add(self, pkgs):
|
||||
|
@ -92,27 +100,39 @@ class QueuePkgs(Utils):
|
|||
"""
|
||||
queue_list = list(self.packages())
|
||||
pkgs = list(OrderedDict.fromkeys(pkgs))
|
||||
|
||||
print("Add packages in the queue:")
|
||||
|
||||
with open(self.queue_list, "a") as queue:
|
||||
|
||||
for pkg in pkgs:
|
||||
|
||||
find = sbo_search_pkg(pkg)
|
||||
|
||||
if pkg not in queue_list and find is not None:
|
||||
print(f"{self.green}{pkg}{self.endc}")
|
||||
queue.write(pkg + "\n")
|
||||
|
||||
else:
|
||||
print(f"{self.red}{pkg}{self.endc}")
|
||||
|
||||
print()
|
||||
|
||||
def remove(self, pkgs):
|
||||
"""Removes packages from the queue
|
||||
"""
|
||||
print("Remove packages from the queue:")
|
||||
|
||||
with open(self.queue_list, "w") as queue:
|
||||
|
||||
for line in self.queued.splitlines():
|
||||
|
||||
if line not in pkgs:
|
||||
queue.write(line + "\n")
|
||||
|
||||
else:
|
||||
print(f"{self.red}{line}{self.endc}")
|
||||
|
||||
print()
|
||||
|
||||
def build(self):
|
||||
|
@ -120,27 +140,37 @@ class QueuePkgs(Utils):
|
|||
"""
|
||||
sources = []
|
||||
packages = list(self.packages())
|
||||
|
||||
if packages:
|
||||
|
||||
for pkg in packages:
|
||||
|
||||
if pkg not in SBoGrep(pkg).names():
|
||||
raise SystemExit(f"\nPackage '{pkg}' was not found in "
|
||||
f"the SBo repository\n")
|
||||
|
||||
if not os.path.exists(self.meta.build_path):
|
||||
os.mkdir(self.meta.build_path)
|
||||
|
||||
if not os.path.exists(self._SOURCES):
|
||||
os.mkdir(self._SOURCES)
|
||||
|
||||
sbo_url = sbo_search_pkg(pkg)
|
||||
sbo_dwn = SBoLink(sbo_url).tar_gz()
|
||||
source_dwn = SBoGrep(pkg).source().split()
|
||||
os.chdir(self.meta.build_path)
|
||||
script = sbo_dwn.split("/")[-1]
|
||||
|
||||
Download(self.meta.build_path, sbo_dwn.split(),
|
||||
repo="sbo").start()
|
||||
|
||||
for src in source_dwn:
|
||||
Download(self._SOURCES, src.split(), repo="sbo").start()
|
||||
sources.append(src.split("/")[-1])
|
||||
|
||||
BuildPackage(script, sources, self.meta.build_path,
|
||||
auto=False).build()
|
||||
|
||||
else:
|
||||
raise SystemExit("\nPackages not found in the queue for "
|
||||
"building\n")
|
||||
|
@ -149,17 +179,24 @@ class QueuePkgs(Utils):
|
|||
"""Installs packages from the queue
|
||||
"""
|
||||
packages = list(self.packages())
|
||||
|
||||
if packages:
|
||||
|
||||
print() # new line at start
|
||||
|
||||
for pkg in packages:
|
||||
|
||||
ver = SBoGrep(pkg).version()
|
||||
prgnam = f"{pkg}-{ver}"
|
||||
|
||||
if find_package(prgnam, self.meta.output):
|
||||
binary = slack_package(prgnam)
|
||||
PackageManager(binary).upgrade(flag="--install-new")
|
||||
|
||||
else:
|
||||
print(f"\nPackage {prgnam} not found in the "
|
||||
f"{self.meta.output} for installation\n")
|
||||
|
||||
else:
|
||||
raise SystemExit("\nPackages not found in the queue for "
|
||||
"installation\n")
|
||||
|
|
|
@ -40,6 +40,8 @@ class SBoArch:
|
|||
"""
|
||||
if self.arch.startswith("i") and self.arch.endswith("86"):
|
||||
self.arch = self.x86
|
||||
|
||||
elif self.meta.arch.startswith("arm"):
|
||||
self.arch = self.arm
|
||||
|
||||
return self.arch
|
||||
|
|
|
@ -22,25 +22,17 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import sqlite3
|
||||
from slpkg.repositories import Repo
|
||||
from slpkg.__metadata__ import MetaData as _meta_
|
||||
|
||||
from slpkg.slack.slack_version import slack_ver
|
||||
from slpkg.models.models import SBoTable, session
|
||||
|
||||
|
||||
def sbo_search_pkg(name):
|
||||
"""Search for package path in SLACKBUILDS.TXT file and
|
||||
return url
|
||||
"""
|
||||
db = _meta_.db
|
||||
lib_path = _meta_.lib_path
|
||||
con = sqlite3.connect(f"{lib_path}{db}")
|
||||
cur = con.cursor()
|
||||
|
||||
location = cur.execute("""SELECT location
|
||||
FROM sbo
|
||||
WHERE name = '{}'""".format(name)).fetchone()
|
||||
location = session.query(SBoTable.location).filter(
|
||||
SBoTable.name == name).first()
|
||||
|
||||
repo = Repo()
|
||||
sbo = repo.default_repository()["sbo"]
|
||||
|
|
|
@ -38,16 +38,20 @@ def slack_package(prgnam):
|
|||
TAG, binaries, cache, binary = "_SBo", [], "0", ""
|
||||
|
||||
for exp in os.environ.keys():
|
||||
|
||||
if exp == "TAG":
|
||||
TAG = os.environ["TAG"]
|
||||
break
|
||||
|
||||
for pkg in find_package(prgnam, _meta_.output):
|
||||
|
||||
if pkg.startswith(prgnam) and pkg[:-4].endswith(TAG):
|
||||
binaries.append(pkg)
|
||||
|
||||
for bins in binaries:
|
||||
|
||||
binary = bins
|
||||
|
||||
if parse_version(bins) > parse_version(cache):
|
||||
binary = bins
|
||||
cache = binary
|
||||
|
|
|
@ -86,8 +86,10 @@ class SBoInstall(BlackList, Utils):
|
|||
"""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 += "/"
|
||||
|
||||
|
@ -97,14 +99,18 @@ class SBoInstall(BlackList, Utils):
|
|||
tagc = ""
|
||||
self.is_upgrade = is_upgrade
|
||||
self.case_insensitive()
|
||||
|
||||
for _sbo in self.slackbuilds:
|
||||
|
||||
if _sbo in self.data and _sbo not in self.blacklist:
|
||||
sbo_deps = Requires(self.flag).sbo(_sbo)
|
||||
self.deps += sbo_deps
|
||||
self.deps_dict[_sbo] = self.one_for_all(sbo_deps)
|
||||
self.package_found.append(_sbo)
|
||||
|
||||
else:
|
||||
self.package_not_found.append(_sbo)
|
||||
|
||||
self.update_deps()
|
||||
|
||||
if not self.package_found:
|
||||
|
@ -114,22 +120,27 @@ class SBoInstall(BlackList, Utils):
|
|||
self.master_packages, mas_src = self.sbo_version_source(
|
||||
self.package_found)
|
||||
self.msg.done()
|
||||
|
||||
if (self.meta.rsl_deps in ["on", "ON"] and
|
||||
self.flag != "--resolve-off" and not self.match):
|
||||
self.msg.resolving()
|
||||
self.dependencies, dep_src = self.sbo_version_source(
|
||||
self.one_for_all(self.deps))
|
||||
|
||||
if (self.meta.rsl_deps in ["on", "ON"] and
|
||||
self.flag != "--resolve-off" and not self.match):
|
||||
self.msg.done()
|
||||
self.clear_masters()
|
||||
|
||||
if self.package_found:
|
||||
|
||||
if self.match and [""] != self.slackbuilds:
|
||||
self.msg.matching(self.slackbuilds)
|
||||
|
||||
else:
|
||||
print("\nThe following packages will be automatically "
|
||||
"installed or upgraded \nwith new version:\n")
|
||||
|
||||
self.top_view()
|
||||
self.msg.upg_inst(self.is_upgrade)
|
||||
|
||||
|
@ -139,6 +150,7 @@ class SBoInstall(BlackList, Utils):
|
|||
name = "-".join(sbo.split("-")[:-1])
|
||||
self.view_packages(tagc, name, sbo.split("-")[-1],
|
||||
self.select_arch(arch))
|
||||
|
||||
self.view_installing_for_deps()
|
||||
|
||||
# view dependencies
|
||||
|
@ -150,10 +162,12 @@ class SBoInstall(BlackList, Utils):
|
|||
|
||||
count_total = sum([self.count_ins, self.count_upg,
|
||||
self.count_uni])
|
||||
|
||||
if self.match and [""] != self.slackbuilds:
|
||||
print("\nMatching summary")
|
||||
print("=" * 79)
|
||||
raise SystemExit(f"Total {count_total} matching packages\n")
|
||||
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print(f"{self.grey}Total {count_total} "
|
||||
|
@ -164,6 +178,7 @@ class SBoInstall(BlackList, Utils):
|
|||
f"{self.count_upg} {self.msg.pkg(self.count_upg)}")
|
||||
print(f"will be upgraded.{self.endc}\n")
|
||||
self.continue_to_install()
|
||||
|
||||
else:
|
||||
self.msg.not_found(self.is_upgrade)
|
||||
raise SystemExit()
|
||||
|
@ -174,9 +189,12 @@ class SBoInstall(BlackList, Utils):
|
|||
"""
|
||||
if "--case-ins" in self.flag:
|
||||
data_dict = self.case_sensitive(self.data)
|
||||
|
||||
for name in self.slackbuilds:
|
||||
index = self.slackbuilds.index(name)
|
||||
|
||||
for key, value in data_dict.items():
|
||||
|
||||
if key == name.lower():
|
||||
self.slackbuilds[index] = value
|
||||
|
||||
|
@ -186,6 +204,7 @@ class SBoInstall(BlackList, Utils):
|
|||
onelist, dependencies = [], []
|
||||
onelist = self.dimensional_list(self.deps)
|
||||
dependencies = self.remove_dbs(onelist)
|
||||
|
||||
for dep in dependencies:
|
||||
deps = Requires(self.flag).sbo(dep)
|
||||
self.deps_dict[dep] = self.one_for_all(deps)
|
||||
|
@ -195,10 +214,13 @@ class SBoInstall(BlackList, Utils):
|
|||
"""
|
||||
if (self.count_uni > 0 or self.count_upg > 0 or
|
||||
"--download-only" in self.flag or "--rebuild" in self.flag):
|
||||
|
||||
if self.master_packages and self.msg.answer() in ["y", "Y"]:
|
||||
installs, upgraded = self.build_install()
|
||||
|
||||
if "--download-only" in self.flag:
|
||||
raise SystemExit()
|
||||
|
||||
self.msg.reference(installs, upgraded)
|
||||
write_deps(self.deps_dict)
|
||||
delete_folder(self.build_folder)
|
||||
|
@ -215,6 +237,7 @@ class SBoInstall(BlackList, Utils):
|
|||
"""
|
||||
self.master_packages = self.remove_dbs(self.master_packages)
|
||||
for mas in self.master_packages:
|
||||
|
||||
if mas in self.dependencies:
|
||||
self.master_packages.remove(mas)
|
||||
|
||||
|
@ -222,7 +245,9 @@ class SBoInstall(BlackList, Utils):
|
|||
"""Return found matching SBo packages
|
||||
"""
|
||||
for sbo in self.package_not_found:
|
||||
|
||||
for pkg in self.data:
|
||||
|
||||
if sbo in pkg and pkg not in self.blacklist:
|
||||
self.package_found.append(pkg)
|
||||
|
||||
|
@ -230,10 +255,12 @@ class SBoInstall(BlackList, Utils):
|
|||
"""Create sbo name with version
|
||||
"""
|
||||
sbo_versions, sources = [], []
|
||||
|
||||
for sbo in slackbuilds:
|
||||
sbo_ver = f"{sbo}-{SBoGrep(sbo).version()}"
|
||||
sbo_versions.append(sbo_ver)
|
||||
sources.append(SBoGrep(sbo).source())
|
||||
|
||||
return [sbo_versions, sources]
|
||||
|
||||
def one_for_all(self, deps):
|
||||
|
@ -248,18 +275,21 @@ class SBoInstall(BlackList, Utils):
|
|||
# dependencies in order to be installed.
|
||||
requires = self.dimensional_list(deps)
|
||||
dependencies = self.remove_dbs(requires)
|
||||
|
||||
return dependencies
|
||||
|
||||
def top_view(self):
|
||||
"""View top template
|
||||
"""
|
||||
self.msg.template(78)
|
||||
|
||||
print(f"| Packages{' ' * 16}"
|
||||
f"New version{' ' * 8}"
|
||||
f"Arch{' ' * 4}"
|
||||
f"Build{' ' * 2}"
|
||||
f"Repos{' ' * 10}"
|
||||
f"Size")
|
||||
|
||||
self.msg.template(78)
|
||||
|
||||
def view_packages(self, *args):
|
||||
|
@ -270,8 +300,10 @@ class SBoInstall(BlackList, Utils):
|
|||
args[3] arch
|
||||
"""
|
||||
ver = GetFromInstalled(args[1]).version()
|
||||
|
||||
if ver:
|
||||
ver = f"-{ver}"
|
||||
|
||||
print(f" {args[0]}{args[1] + ver} {self.endc}"
|
||||
f"{' ' * (24-len(args[1] + ver))}{args[2]}"
|
||||
f"{' ' * (18-len(args[2]))} {args[3]}"
|
||||
|
@ -286,17 +318,22 @@ class SBoInstall(BlackList, Utils):
|
|||
# split sbo name with version and get name
|
||||
sbo_name = "-".join(sbo.split("-")[:-1])
|
||||
find = GetFromInstalled(sbo_name).name()
|
||||
|
||||
if find_package(sbo, self.meta.pkg_path):
|
||||
paint = self.meta.color["GREEN"]
|
||||
self.count_ins += 1
|
||||
|
||||
if "--rebuild" in self.flag:
|
||||
self.count_upg += 1
|
||||
|
||||
elif sbo_name == find:
|
||||
paint = self.meta.color["YELLOW"]
|
||||
self.count_upg += 1
|
||||
|
||||
else:
|
||||
paint = self.meta.color["RED"]
|
||||
self.count_uni += 1
|
||||
|
||||
return paint
|
||||
|
||||
def select_arch(self, src):
|
||||
|
@ -304,9 +341,11 @@ class SBoInstall(BlackList, Utils):
|
|||
from arch else select arch.
|
||||
"""
|
||||
arch = self.arch
|
||||
|
||||
for item in self.unst:
|
||||
if item in src:
|
||||
arch = item
|
||||
|
||||
return arch
|
||||
|
||||
def filenames(self, sources):
|
||||
|
@ -320,58 +359,76 @@ class SBoInstall(BlackList, Utils):
|
|||
"""
|
||||
slackbuilds = self.dependencies + self.master_packages
|
||||
installs, upgraded, = [], []
|
||||
|
||||
if not os.path.exists(self.build_folder):
|
||||
os.makedirs(self.build_folder)
|
||||
|
||||
if not os.path.exists(self._SOURCES):
|
||||
os.makedirs(self._SOURCES)
|
||||
|
||||
os.chdir(self.build_folder)
|
||||
|
||||
for prgnam in slackbuilds:
|
||||
|
||||
if (self.meta.not_downgrade == "on" and
|
||||
self.not_downgrade(prgnam) is True):
|
||||
continue
|
||||
|
||||
pkg = "-".join(prgnam.split("-")[:-1])
|
||||
installed = "".join(find_package(prgnam, self.meta.pkg_path))
|
||||
src_link = SBoGrep(pkg).source().split()
|
||||
|
||||
if (installed and "--download-only" not in self.flag and
|
||||
"--rebuild" not in self.flag):
|
||||
self.msg.template(78)
|
||||
self.msg.pkg_found(prgnam)
|
||||
self.msg.template(78)
|
||||
|
||||
elif self.unst[0] in src_link or self.unst[1] in src_link:
|
||||
self.msg.template(78)
|
||||
print(f"| Package {prgnam} {self.red}"
|
||||
f"{''.join(src_link)}{self.endc}")
|
||||
self.msg.template(78)
|
||||
|
||||
else:
|
||||
sbo_url = sbo_search_pkg(pkg)
|
||||
sbo_link = SBoLink(sbo_url).tar_gz()
|
||||
script = sbo_link.split("/")[-1]
|
||||
|
||||
if self.meta.sbosrcarch in ["on", "ON"]:
|
||||
src_link = list(self.sbosrcarsh(prgnam, sbo_link,
|
||||
src_link))
|
||||
Download(self.build_folder, sbo_link.split(),
|
||||
repo="sbo").start()
|
||||
Download(self._SOURCES, src_link, repo="sbo").start()
|
||||
|
||||
if "--download-only" in self.flag:
|
||||
continue
|
||||
|
||||
sources = list(self.filenames(src_link))
|
||||
BuildPackage(script, sources, self.build_folder,
|
||||
auto=False).build()
|
||||
binary = slack_package(prgnam)
|
||||
|
||||
if os.path.isfile("".join(binary)):
|
||||
|
||||
if GetFromInstalled(pkg).name() == pkg:
|
||||
print(f"[ {self.yellow}Upgrading{self.endc} ] --> "
|
||||
f"{prgnam}")
|
||||
upgraded.append(prgnam)
|
||||
|
||||
else:
|
||||
print(f"[ {self.green}Installing{self.endc} ] --> "
|
||||
f"{prgnam}")
|
||||
installs.append(prgnam)
|
||||
|
||||
if ("--rebuild" in self.flag and
|
||||
GetFromInstalled(pkg).name() == pkg):
|
||||
PackageManager(binary).upgrade(flag="--reinstall")
|
||||
|
||||
else:
|
||||
PackageManager(binary).upgrade(flag="--install-new")
|
||||
|
||||
return installs, upgraded
|
||||
|
||||
def not_downgrade(self, prgnam):
|
||||
|
@ -380,19 +437,23 @@ class SBoInstall(BlackList, Utils):
|
|||
name = "-".join(prgnam.split("-")[:-1])
|
||||
sbo_ver = prgnam.split("-")[-1]
|
||||
ins_ver = GetFromInstalled(name).version()
|
||||
|
||||
if not ins_ver:
|
||||
ins_ver = "0"
|
||||
|
||||
if parse_version(sbo_ver) < parse_version(ins_ver):
|
||||
self.msg.template(78)
|
||||
print(f"| Package {name} does not downgrade, "
|
||||
f"setting by user")
|
||||
self.msg.template(78)
|
||||
|
||||
return True
|
||||
|
||||
def sbosrcarsh(self, prgnam, sbo_link, src_link):
|
||||
"""Alternative repository for sbo sources"""
|
||||
name = "-".join(prgnam.split("-")[:-1])
|
||||
category = f"{sbo_link.split('/')[-2]}/{name}/"
|
||||
|
||||
for link in src_link:
|
||||
source = link.split("/")[-1]
|
||||
yield f"{self.meta.sbosrcarch_link}{category}{source}"
|
||||
|
|
|
@ -31,13 +31,19 @@ def pkg_security(pkgs):
|
|||
reasons. Configuration file in the /etc/slpkg/pkg_security"""
|
||||
packages, msg, utils = [], Msg(), Utils()
|
||||
security_packages = utils.read_file("/etc/slpkg/pkg_security")
|
||||
|
||||
for read in security_packages.splitlines():
|
||||
read = read.lstrip()
|
||||
|
||||
if not read.startswith("#"):
|
||||
packages.append(read.replace("\n", ""))
|
||||
|
||||
for p in pkgs:
|
||||
|
||||
for pkg in packages:
|
||||
|
||||
if p == pkg:
|
||||
msg.security_pkg(p)
|
||||
|
||||
if not msg.answer() in ["y", "Y"]:
|
||||
raise SystemExit()
|
||||
|
|
|
@ -28,16 +28,21 @@ def units(comp_sum, uncomp_sum):
|
|||
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
|
||||
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
|
||||
comp_unit = uncomp_unit = "Mb"
|
||||
|
||||
if compressed > 1024:
|
||||
compressed = round((compressed / 1024), 2)
|
||||
comp_unit = "Gb"
|
||||
|
||||
if uncompressed > 1024:
|
||||
uncompressed = round((uncompressed / 1024), 2)
|
||||
uncomp_unit = "Gb"
|
||||
|
||||
if compressed < 1:
|
||||
compressed = sum(map(int, comp_sum))
|
||||
comp_unit = "Kb"
|
||||
|
||||
if uncompressed < 1:
|
||||
uncompressed = sum(map(int, uncomp_sum))
|
||||
uncomp_unit = "Kb"
|
||||
|
||||
return [comp_unit, uncomp_unit], [compressed, uncompressed]
|
||||
|
|
|
@ -36,19 +36,29 @@ def mirrors(name, location):
|
|||
ver = slack_ver()
|
||||
repo = Repo()
|
||||
slack = repo.slack()
|
||||
|
||||
if _meta_.arch == "x86_64":
|
||||
|
||||
if rel == "stable":
|
||||
http = f"{slack}slackware64-{ver}/{location}{name}"
|
||||
|
||||
else:
|
||||
http = f"{slack}slackware64-{rel}/{location}{name}"
|
||||
|
||||
elif _meta_.arch.startswith("arm"):
|
||||
|
||||
if rel == "stable":
|
||||
http = f"{slack}slackwarearm-{ver}/{location}{name}"
|
||||
|
||||
else:
|
||||
http = f"{slack}slackwarearm-{rel}/{location}{name}"
|
||||
|
||||
else:
|
||||
|
||||
if rel == "stable":
|
||||
http = f"{slack}slackware-{ver}/{location}{name}"
|
||||
|
||||
else:
|
||||
http = f"{slack}slackware-{rel}/{location}{name}"
|
||||
|
||||
return http
|
||||
|
|
|
@ -78,9 +78,11 @@ class Patches(BlackList, Utils):
|
|||
self.comp_sum = []
|
||||
self.uncomp_sum = []
|
||||
self.msg.checking()
|
||||
|
||||
if self.version == "stable":
|
||||
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT",
|
||||
"patches/")).get_request()
|
||||
|
||||
else:
|
||||
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "")).get_request()
|
||||
|
||||
|
@ -89,17 +91,25 @@ class Patches(BlackList, Utils):
|
|||
"""
|
||||
self.store()
|
||||
self.msg.done()
|
||||
|
||||
if self.upgrade_all:
|
||||
|
||||
if "--checklist" in self.flag:
|
||||
self.dialog_checklist()
|
||||
|
||||
print("\nThese packages need upgrading:\n")
|
||||
self.msg.template(78)
|
||||
print(f"| Package{' ' * 17}New Version{' ' * 8}Arch"
|
||||
f"{' ' * 4}Build{' ' * 2}Repo{' ' * 11}Size")
|
||||
|
||||
self.msg.template(78)
|
||||
|
||||
print("Upgrading:")
|
||||
|
||||
self.views()
|
||||
|
||||
unit, size = units(self.comp_sum, self.uncomp_sum)
|
||||
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print(f"{self.grey}Total {self.count_upg} "
|
||||
|
@ -109,6 +119,7 @@ class Patches(BlackList, Utils):
|
|||
print(f"After this process, {size[1]} {unit[1]} of additional disk"
|
||||
f" space will be used.{self.endc}")
|
||||
print()
|
||||
|
||||
if self.msg.answer() in ["y", "Y"]:
|
||||
Download(self.patch_path, self.dwn_links,
|
||||
repo="slack").start()
|
||||
|
@ -116,18 +127,25 @@ class Patches(BlackList, Utils):
|
|||
self.patch_path, self.upgrade_all))
|
||||
self.upgrade()
|
||||
self.kernel()
|
||||
|
||||
if self.meta.slackpkg_log in ["on", "ON"]:
|
||||
# update the slackpkg ChanheLog.txt file
|
||||
self.slackpkg_update()
|
||||
|
||||
self.msg.reference(self.installed, self.upgraded)
|
||||
|
||||
# delete the downloaded packages
|
||||
delete_package(self.patch_path, self.upgrade_all)
|
||||
|
||||
# update the packages lists
|
||||
self.update_lists()
|
||||
|
||||
else:
|
||||
slack_arch = ""
|
||||
|
||||
if self.meta.arch == "x86_64":
|
||||
slack_arch = "64"
|
||||
|
||||
print(f"\nSlackware{slack_arch} '{self.version}' v{slack_ver()}"
|
||||
f" distribution is up to date!\n")
|
||||
|
||||
|
@ -138,9 +156,11 @@ class Patches(BlackList, Utils):
|
|||
black = list(self.get_black())
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
|
||||
repo_pkg_name = split_package(name)[0]
|
||||
|
||||
if self.meta.only_installed in ["on", "ON"]:
|
||||
pkg_name = split_package(name)[0]
|
||||
pkg_ver = split_package(name)[1]
|
||||
|
||||
if (GetFromInstalled(pkg_name).name() and
|
||||
repo_pkg_name not in black and
|
||||
repo_pkg_name not in self.skip and
|
||||
|
@ -151,10 +171,12 @@ class Patches(BlackList, Utils):
|
|||
self.uncomp_sum.append(uncomp)
|
||||
self.upgrade_all.append(name)
|
||||
self.count_upg += 1
|
||||
|
||||
if not find_package(f"{repo_pkg_name}-",
|
||||
self.meta.pkg_path):
|
||||
self.count_added += 1
|
||||
self.count_upg -= 1
|
||||
|
||||
elif (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):
|
||||
|
@ -163,9 +185,11 @@ class Patches(BlackList, Utils):
|
|||
self.uncomp_sum.append(uncomp)
|
||||
self.upgrade_all.append(name)
|
||||
self.count_upg += 1
|
||||
|
||||
if not find_package(f"{repo_pkg_name}-", self.meta.pkg_path):
|
||||
self.count_added += 1
|
||||
self.count_upg -= 1
|
||||
|
||||
return self.count_upg
|
||||
|
||||
def dialog_checklist(self):
|
||||
|
@ -174,15 +198,20 @@ class Patches(BlackList, Utils):
|
|||
data = []
|
||||
for upg in self.upgrade_all:
|
||||
data.append(upg[:-4])
|
||||
|
||||
text = "Press 'spacebar' to unchoose packages from upgrade"
|
||||
title = " Upgrade "
|
||||
status = True
|
||||
|
||||
backtitle = f"{self.meta.__all__} {self.meta.__version__}"
|
||||
|
||||
pkgs = DialogUtil(data, text, title, backtitle,
|
||||
status).checklist()
|
||||
|
||||
index = 0
|
||||
for pkg, comp, uncomp in zip(self.upgrade_all, self.comp_sum,
|
||||
self.uncomp_sum):
|
||||
|
||||
if pkg[:-4] not in pkgs:
|
||||
self.dwn_links.pop(index)
|
||||
self.upgrade_all.pop(index)
|
||||
|
@ -191,7 +220,9 @@ class Patches(BlackList, Utils):
|
|||
self.count_upg -= 1
|
||||
del comp, uncomp
|
||||
index -= 1
|
||||
|
||||
index += 1
|
||||
|
||||
if not self.upgrade_all:
|
||||
raise SystemExit()
|
||||
|
||||
|
@ -202,11 +233,15 @@ class Patches(BlackList, Utils):
|
|||
pkg_repo = split_package(upg[:-4])
|
||||
color = self.red
|
||||
pkg_inst = GetFromInstalled(pkg_repo[0]).name()
|
||||
|
||||
if pkg_repo[0] == pkg_inst:
|
||||
color = self.yellow
|
||||
|
||||
ver = GetFromInstalled(pkg_repo[0]).version()
|
||||
|
||||
if ver:
|
||||
ver = f"-{ver}"
|
||||
|
||||
print(f" {color}{pkg_repo[0] + ver}{self.endc}"
|
||||
f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}"
|
||||
f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}"
|
||||
|
@ -219,13 +254,16 @@ class Patches(BlackList, Utils):
|
|||
for pkg in self.upgrade_all:
|
||||
check_md5(pkg_checksum(pkg, "slack_patches"),
|
||||
self.patch_path + pkg)
|
||||
|
||||
pkg_ver = f"{split_package(pkg)[0]}-{split_package(pkg)[1]}"
|
||||
|
||||
if find_package(f"{split_package(pkg)[0]}-",
|
||||
self.meta.pkg_path):
|
||||
print(f"[ {self.yellow}upgrading{self.endc} ] --> {pkg[:-4]}")
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade(
|
||||
"--install-new")
|
||||
self.upgraded.append(pkg_ver)
|
||||
|
||||
else:
|
||||
print(f"[ {self.green}installing{self.endc} ] --> {pkg[:-4]}")
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade(
|
||||
|
@ -237,9 +275,12 @@ class Patches(BlackList, Utils):
|
|||
then reinstall boot loader
|
||||
"""
|
||||
for core in self.upgrade_all:
|
||||
|
||||
if "kernel" in core:
|
||||
|
||||
if self.meta.default_answer in ["y", "Y"]:
|
||||
answer = self.meta.default_answer
|
||||
|
||||
else:
|
||||
print()
|
||||
self.msg.template(78)
|
||||
|
@ -247,17 +288,21 @@ class Patches(BlackList, Utils):
|
|||
f"boot loader ***{self.endc}")
|
||||
print("| L=lilo / E=elilo / G=grub")
|
||||
self.msg.template(78)
|
||||
|
||||
try:
|
||||
answer = input("\nThe kernel has been upgraded, "
|
||||
"reinstall boot loader [L/E/G]? ")
|
||||
except EOFError:
|
||||
raise SystemExit("\n")
|
||||
|
||||
if answer in ["L"]:
|
||||
subprocess.call("lilo", shell=True)
|
||||
break
|
||||
|
||||
elif answer in ["E"]:
|
||||
subprocess.call("eliloconfig", shell=True)
|
||||
break
|
||||
|
||||
elif answer in ["G"]:
|
||||
subprocess.call("grub-mkconfig -o /boot/grub/grub.cfg",
|
||||
shell=True)
|
||||
|
@ -268,12 +313,15 @@ class Patches(BlackList, Utils):
|
|||
from Slackware official mirrors after update distribution.
|
||||
"""
|
||||
NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).get_request()
|
||||
|
||||
if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old"):
|
||||
os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
|
||||
|
||||
if os.path.isfile(f"{self.meta.slackpkg_lib_path}ChangeLog.txt"):
|
||||
shutil.copy2(f"{self.meta.slackpkg_lib_path}ChangeLog.txt",
|
||||
f"{self.meta.slackpkg_lib_path}ChangeLog.txt.old")
|
||||
os.remove(f"{self.meta.slackpkg_lib_path}ChangeLog.txt")
|
||||
|
||||
with open(f"{self.meta.slackpkg_lib_path}ChangeLog.txt", "w") as log:
|
||||
log.write(NEW_ChangeLog_txt)
|
||||
|
||||
|
@ -283,5 +331,6 @@ class Patches(BlackList, Utils):
|
|||
"""
|
||||
print(f"{self.green}Update the package lists ?{self.endc}")
|
||||
print("=" * 79)
|
||||
|
||||
if self.msg.answer() in ["y", "Y"]:
|
||||
Update().run(["slack"])
|
||||
|
|
|
@ -32,11 +32,15 @@ def slack_ver():
|
|||
"""Opens the file and read Slackware version
|
||||
"""
|
||||
utils = Utils()
|
||||
|
||||
if _meta_.slackware_version in ["off", "OFF"]:
|
||||
sv = utils.read_file("/etc/slackware-version")
|
||||
version = re.findall(r"\d+", sv)
|
||||
|
||||
if len(sv) > 2:
|
||||
return (".".join(version[:2]))
|
||||
|
||||
else:
|
||||
return (".".join(version))
|
||||
|
||||
return _meta_.slackware_version
|
||||
|
|
|
@ -33,10 +33,13 @@ def slackware_repository():
|
|||
"""
|
||||
utils = Utils()
|
||||
slack_repo, packages, names = [], [], []
|
||||
|
||||
slack_repo = repo_data(
|
||||
utils.read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"),
|
||||
"slack", "")
|
||||
|
||||
for pkg in slack_repo[0]:
|
||||
names.append(split_package(pkg)[0])
|
||||
packages.append(pkg[:-4])
|
||||
|
||||
return packages, names
|
||||
|
|
|
@ -46,19 +46,24 @@ def it_self_update():
|
|||
_meta_.__all__,
|
||||
branch,
|
||||
_meta_.__all__))
|
||||
|
||||
version_data = URL(ver_link).get_request()
|
||||
|
||||
for line in version_data.splitlines():
|
||||
line = line.strip()
|
||||
|
||||
if line.startswith("__version_info__"):
|
||||
__new_version__ = ".".join(re.findall(r"\d+", line))
|
||||
|
||||
if __new_version__ > _meta_.__version__:
|
||||
|
||||
if _meta_.default_answer in ["y", "Y"]:
|
||||
answer = _meta_.default_answer
|
||||
|
||||
else:
|
||||
print("\nNew version '{0}-{1}' is available !\n".format(
|
||||
_meta_.__all__, __new_version__))
|
||||
|
||||
try:
|
||||
answer = input("Would you like to upgrade [y/N]? ")
|
||||
except EOFError:
|
||||
|
@ -66,6 +71,7 @@ def it_self_update():
|
|||
|
||||
if answer in ["y", "Y"]:
|
||||
print() # new line after answer
|
||||
|
||||
else:
|
||||
raise SystemExit()
|
||||
|
||||
|
@ -81,19 +87,26 @@ def it_self_update():
|
|||
os.makedirs(_meta_.build_path)
|
||||
|
||||
Download(_meta_.build_path, dwn_link, repo="").start()
|
||||
|
||||
os.chdir(_meta_.build_path)
|
||||
|
||||
slpkg_tar_file = f"slpkg-{__new_version__}.tar.gz"
|
||||
tar = tarfile.open(slpkg_tar_file)
|
||||
tar.extractall()
|
||||
tar.close()
|
||||
|
||||
file_name = f"{_meta_.__all__}-{__new_version__}"
|
||||
|
||||
os.chdir(file_name)
|
||||
|
||||
check_md5(pkg_checksum(slpkg_tar_file, _meta_.__all__),
|
||||
_meta_.build_path + slpkg_tar_file)
|
||||
|
||||
subprocess.call("chmod +x {0}".format("install.sh"), shell=True)
|
||||
subprocess.call("sh install.sh", shell=True)
|
||||
|
||||
else:
|
||||
print(f"\n{_meta_.__all__}: There is no new version, "
|
||||
"already you use the last!\n")
|
||||
|
||||
raise SystemExit()
|
||||
|
|
|
@ -48,8 +48,10 @@ class DependenciesStatus(Utils):
|
|||
self.count_dep = 0
|
||||
self.dep_path = self.meta.log_path + "dep/"
|
||||
self.logs = find_package("", self.dep_path)
|
||||
|
||||
if not self.logs:
|
||||
self.no_logs()
|
||||
|
||||
self.installed = find_package("", self.meta.pkg_path)
|
||||
|
||||
def data(self):
|
||||
|
@ -57,16 +59,23 @@ class DependenciesStatus(Utils):
|
|||
dictionary database
|
||||
"""
|
||||
for pkg in self.installed:
|
||||
|
||||
if os.path.isfile(f"{self.meta.pkg_path}{pkg}"):
|
||||
name = split_package(pkg)[0]
|
||||
|
||||
for log in self.logs:
|
||||
deps = self.read_file(f"{self.dep_path}{log}")
|
||||
|
||||
for dep in deps.splitlines():
|
||||
|
||||
if name == dep:
|
||||
|
||||
if name not in self.dmap.keys():
|
||||
self.dmap[name] = [log]
|
||||
|
||||
if not self.count_pkg:
|
||||
self.count_pkg = 1
|
||||
|
||||
else:
|
||||
self.dmap[name] += [log]
|
||||
self.count_packages()
|
||||
|
@ -75,24 +84,29 @@ class DependenciesStatus(Utils):
|
|||
"""Counts dependencies and packages
|
||||
"""
|
||||
packages = []
|
||||
|
||||
for pkg in self.dmap.values():
|
||||
packages += pkg
|
||||
self.count_dep += 1
|
||||
|
||||
self.count_pkg = len(set(packages))
|
||||
|
||||
def show(self):
|
||||
"""Show dependencies status
|
||||
"""
|
||||
self.data()
|
||||
|
||||
print()
|
||||
self.msg.template(78)
|
||||
print(f"| Dependencies{' ' * 20}Packages")
|
||||
self.msg.template(78)
|
||||
|
||||
for key, value in self.dmap.items():
|
||||
print(" {0}{1}{2}{3}{4}".format(
|
||||
self.green, key, self.endc, " " * (32-len(key)),
|
||||
", ".join(value)))
|
||||
self.summary()
|
||||
|
||||
if self.image:
|
||||
Graph(self.image).dependencies(self.dmap)
|
||||
|
||||
|
@ -103,15 +117,21 @@ class DependenciesStatus(Utils):
|
|||
print("| Dependencies\n"
|
||||
"| -- Packages")
|
||||
self.msg.template(78)
|
||||
|
||||
self.data()
|
||||
|
||||
for pkg, dep in self.dmap.items():
|
||||
print(f"+ {self.green}{pkg}{self.endc}")
|
||||
print("|")
|
||||
|
||||
for d in dep:
|
||||
print(f"+-- {d}")
|
||||
print("|")
|
||||
|
||||
print("\x1b[1A \n", end="", flush=True)
|
||||
|
||||
self.summary()
|
||||
|
||||
if self.image:
|
||||
Graph(self.image).dependencies(self.dmap)
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class TrackingDeps(BlackList, Utils):
|
|||
"""Flags initialization
|
||||
"""
|
||||
for i in range(0, len(self.flag)):
|
||||
|
||||
if self.flag[i].startswith("--graph="):
|
||||
self.image = self.flag[i].split("=")[1]
|
||||
self.flag[i] = "--graph="
|
||||
|
@ -75,50 +76,70 @@ class TrackingDeps(BlackList, Utils):
|
|||
"""
|
||||
self.msg.resolving()
|
||||
self.repositories()
|
||||
|
||||
if self.find_pkg:
|
||||
self.dependencies_list.reverse()
|
||||
self.requires = self.dimensional_list(self.dependencies_list)
|
||||
self.dependencies = self.remove_dbs(self.requires)
|
||||
|
||||
if self.dependencies == []:
|
||||
self.dependencies = ["No dependencies"]
|
||||
|
||||
if "--graph=" in self.flag:
|
||||
self.deps_tree()
|
||||
|
||||
self.msg.done()
|
||||
|
||||
pkg_len = len(self.name) + 24
|
||||
|
||||
print() # new line at start
|
||||
self.msg.template(pkg_len)
|
||||
print(f"| Package {self.cyan}{self.name}{self.endc} "
|
||||
f"dependencies :")
|
||||
self.msg.template(pkg_len)
|
||||
|
||||
print("\\")
|
||||
print(f" +---{self.yellow}[ Tree of dependencies ]{self.endc}")
|
||||
|
||||
index = 0
|
||||
|
||||
for pkg in self.dependencies:
|
||||
|
||||
if "--check-deps" in self.flag:
|
||||
used = self.check_used(pkg)
|
||||
self.deps_used(pkg, used)
|
||||
used = (f"is dependence on --> "
|
||||
f"{self.cyan}{', '.join(used)}{self.endc}")
|
||||
|
||||
else:
|
||||
used = ""
|
||||
|
||||
index += 1
|
||||
installed = ""
|
||||
|
||||
if find_package(f"{pkg}-", self.meta.pkg_path):
|
||||
|
||||
if self.meta.use_colors in ["off", "OFF"]:
|
||||
installed = "* "
|
||||
|
||||
print(" |")
|
||||
print(f" +--{index}: {self.green}{pkg}{self.endc} "
|
||||
f"{installed}{used}")
|
||||
|
||||
else:
|
||||
print(" |")
|
||||
print(f" +--{index}: {self.red}{pkg}{self.endc} "
|
||||
f"{installed}")
|
||||
|
||||
if self.meta.use_colors in ["off", "OFF"]:
|
||||
print("\n * = Installed\n")
|
||||
|
||||
else:
|
||||
print() # new line at end
|
||||
|
||||
if "--graph=" in self.flag:
|
||||
self.graph()
|
||||
|
||||
else:
|
||||
self.msg.done()
|
||||
raise SystemExit("\nNo package was found to match\n")
|
||||
|
@ -129,14 +150,17 @@ class TrackingDeps(BlackList, Utils):
|
|||
if self.repo == "sbo":
|
||||
self.sbo_case_insensitive()
|
||||
self.find_pkg = sbo_search_pkg(self.name)
|
||||
|
||||
if self.find_pkg:
|
||||
self.dependencies_list = Requires(self.flag).sbo(self.name)
|
||||
|
||||
else:
|
||||
PACKAGES_TXT = self.read_file(
|
||||
f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT")
|
||||
self.names = list(self.package_name(PACKAGES_TXT))
|
||||
self.bin_case_insensitive()
|
||||
self.find_pkg = search_pkg(self.name, self.repo)
|
||||
|
||||
if self.find_pkg:
|
||||
self.black = list(self.get_black())
|
||||
self.dependencies_list = Dependencies(
|
||||
|
@ -149,7 +173,9 @@ class TrackingDeps(BlackList, Utils):
|
|||
if "--case-ins" in self.flag:
|
||||
data = SBoGrep(name="").names()
|
||||
data_dict = self.case_sensitive(data)
|
||||
|
||||
for key, value in data_dict.items():
|
||||
|
||||
if key == self.name.lower():
|
||||
self.name = value
|
||||
|
||||
|
@ -159,7 +185,9 @@ class TrackingDeps(BlackList, Utils):
|
|||
"""
|
||||
if "--case-ins" in self.flag:
|
||||
data_dict = self.case_sensitive(self.names)
|
||||
|
||||
for key, value in data_dict.items():
|
||||
|
||||
if key == self.name.lower():
|
||||
self.name = value
|
||||
|
||||
|
@ -174,9 +202,12 @@ class TrackingDeps(BlackList, Utils):
|
|||
used = []
|
||||
dep_path = f"{self.meta.log_path}dep/"
|
||||
logs = find_package("", dep_path)
|
||||
|
||||
for log in logs:
|
||||
deps = self.read_file(f"{dep_path}{log}")
|
||||
|
||||
for dep in deps.splitlines():
|
||||
|
||||
if pkg == dep:
|
||||
used.append(log)
|
||||
return used
|
||||
|
@ -186,13 +217,18 @@ class TrackingDeps(BlackList, Utils):
|
|||
"""
|
||||
dependencies = self.dependencies + [self.name]
|
||||
if self.repo == "sbo":
|
||||
|
||||
for dep in dependencies:
|
||||
deps = Requires(flag="").sbo(dep)
|
||||
|
||||
if dep not in self.deps_dict.values():
|
||||
self.deps_dict[dep] = self.dimensional_list(deps)
|
||||
|
||||
else:
|
||||
|
||||
for dep in dependencies:
|
||||
deps = Dependencies(self.repo, self.black).binary(dep, flag="")
|
||||
|
||||
if dep not in self.deps_dict.values():
|
||||
self.deps_dict[dep] = self.dimensional_list(deps)
|
||||
|
||||
|
@ -200,7 +236,9 @@ class TrackingDeps(BlackList, Utils):
|
|||
"""Creates dependencies dictionary
|
||||
"""
|
||||
if find_package(f"{pkg}-", self.meta.pkg_path):
|
||||
|
||||
if pkg not in self.deps_dict.values():
|
||||
self.deps_dict[pkg] = used
|
||||
|
||||
else:
|
||||
self.deps_dict[pkg] += used
|
||||
|
|
|
@ -34,25 +34,37 @@ def choose_upg(packages):
|
|||
"""Creating checklist to choose packages for upgrade
|
||||
"""
|
||||
selected_packages, data = [], []
|
||||
|
||||
if packages:
|
||||
|
||||
for pkg in packages:
|
||||
name = GetFromInstalled(pkg).name()
|
||||
ver = GetFromInstalled(pkg).version()
|
||||
binary = f"{name}-{ver}"
|
||||
installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
|
||||
data.append(installed)
|
||||
|
||||
text = "Press 'spacebar' to unchoose packages from upgrade"
|
||||
title = " Upgrade "
|
||||
|
||||
backtitle = f"{_meta_.__all__} {_meta_.__version__}"
|
||||
|
||||
status = True
|
||||
|
||||
pkgs = DialogUtil(data, text, title, backtitle,
|
||||
status).checklist()
|
||||
|
||||
pkgs = [] if pkgs is None else pkgs
|
||||
|
||||
for pkg in pkgs:
|
||||
name = split_package(pkg)[0]
|
||||
|
||||
if name in packages:
|
||||
selected_packages.append(name)
|
||||
|
||||
if not selected_packages:
|
||||
raise SystemExit(1)
|
||||
|
||||
print()
|
||||
|
||||
return selected_packages
|
||||
|
|
|
@ -35,8 +35,10 @@ class URL:
|
|||
self.meta = _meta_
|
||||
self.red = _meta_.color["RED"]
|
||||
self.endc = _meta_.color["ENDC"]
|
||||
|
||||
if self.meta.http_proxy:
|
||||
self.http = urllib3.ProxyManager(self.meta.http_proxy)
|
||||
|
||||
else:
|
||||
self.http = urllib3.PoolManager()
|
||||
|
||||
|
@ -49,4 +51,5 @@ class URL:
|
|||
except urllib3.exceptions.NewConnectionError:
|
||||
print(f"\n{self.red}Can't read the file "
|
||||
f"'{self.link.split('/')[-1]}'{self.endc}")
|
||||
|
||||
return " "
|
||||
|
|
|
@ -44,8 +44,10 @@ class Utils:
|
|||
"""Creates one dimensional list
|
||||
"""
|
||||
one_list = []
|
||||
|
||||
for lst in lists:
|
||||
one_list += lst
|
||||
|
||||
return one_list
|
||||
|
||||
def remove_dbs(self, double):
|
||||
|
@ -57,8 +59,10 @@ class Utils:
|
|||
"""Returns reading file
|
||||
"""
|
||||
code = self.check_encoding('', registry)
|
||||
|
||||
if not code:
|
||||
code = "utf-8"
|
||||
|
||||
with open(registry, "r", encoding=code) as file_txt:
|
||||
read_file = file_txt.read()
|
||||
return read_file
|
||||
|
@ -67,6 +71,7 @@ class Utils:
|
|||
"""Returns list with all the names of packages repository
|
||||
"""
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
yield split_package(line[14:].strip())[0]
|
||||
|
||||
|
@ -75,6 +80,7 @@ class Utils:
|
|||
packages
|
||||
"""
|
||||
for pkg in downloaded:
|
||||
|
||||
if os.path.isfile(f"{path}{pkg}"):
|
||||
yield pkg
|
||||
|
||||
|
@ -84,6 +90,7 @@ class Utils:
|
|||
"""
|
||||
for line in config.splitlines():
|
||||
line = line.lstrip()
|
||||
|
||||
if line and not line.startswith("#"):
|
||||
return line
|
||||
|
||||
|
@ -92,8 +99,10 @@ class Utils:
|
|||
"""
|
||||
if "%2b" in file_name:
|
||||
return file_name.replace("%2b", "+", 5)
|
||||
|
||||
elif "%2B" in file_name:
|
||||
return file_name.replace("%2B", "+", 5)
|
||||
|
||||
else:
|
||||
return file_name
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue