Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2020-02-14 22:18:50 +01:00
commit 4f6f26f67e
40 changed files with 171 additions and 356 deletions

View file

@ -1,3 +1,12 @@
3.8.1 - 13/02/2020
Fixed:
- Bugfix double install packages from slack regular repo
and patches directory #122
Updated:
- Removed status progress bar
- Setup and installing
- Managed blacklist in the simple way
3.8.0 - 05/02/2020 3.8.0 - 05/02/2020
Added: Added:
- Many changes happen in this version, a big part of code has been rewritten - Many changes happen in this version, a big part of code has been rewritten

View file

@ -1202,14 +1202,7 @@ Packages in blacklist:
live555 live555
faac faac
Note: you can use asterisk "*" to match more packages like:
*lib* \\ Add all packages inlcude string "lib"
*lib \\ Add all packages ends with string "lib"
lib* \\ Add all packages starts with string "lib"
multi:*multilib* \\ Add all packages include string "multilib" from "multi"
\\ repository.
``` ```
Print a package description: Print a package description:

View file

@ -11,7 +11,7 @@ distribution like SalixOS, Slackel etc.
##### Install slpkg ##### Install slpkg
There are mainly 3 ways: There are mainly 2 ways:
1. Suggested method, download latest slpkg version from: 1. Suggested method, download latest slpkg version from:
'`https://gitlab.com/dslackw/slpkg/releases`' '`https://gitlab.com/dslackw/slpkg/releases`'
@ -21,6 +21,3 @@ There are mainly 3 ways:
2. Download binary package from '`https://sourceforge.net/projects/slpkg/files/binary/`' 2. Download binary package from '`https://sourceforge.net/projects/slpkg/files/binary/`'
and use Slackware command '`upgradepkg --install-new <slpkg binary>`' and use Slackware command '`upgradepkg --install-new <slpkg binary>`'
3. Using pip: '`pip3 install https://gitlab.com/dslackw/slpkg/-/archive/3.8.0/slpkg-3.8.0.tar.gz`'
or instead '`'python3 -m pip install`''.

View file

@ -1,4 +1,4 @@
# slpkg 3.8.0 # slpkg 3.8.1
Slpkg is a powerful software package manager that installs, updates, and removes packages on Slpkg is a powerful software package manager that installs, updates, and removes packages on
[Slackware](http://www.slackware.com/) based systems. It automatically computes dependencies and [Slackware](http://www.slackware.com/) based systems. It automatically computes dependencies and

View file

@ -2,26 +2,6 @@
# #
# blacklist file is part of slpkg. # blacklist file is part of slpkg.
# #
# Copyright 2014-2019 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/>.
#
# END OF LEGAL NOTICE
#
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# This is the blacklist file. Each package listed here may not be # This is the blacklist file. Each package listed here may not be
# installed be upgraded be find or deleted. # installed be upgraded be find or deleted.
@ -30,15 +10,6 @@
# To blacklist the package 'wicd-1.7.2.4-x86_64-4.txz' the line will be: # To blacklist the package 'wicd-1.7.2.4-x86_64-4.txz' the line will be:
# wicd # wicd
# #
# This one will blacklist all packages include string "lib" in package name:
# *lib*
#
# Add packages in blacklist by repository:
# slacky:* `add all packages from the slacky repository`
# sbo:py* `add all packages from the sbo starts with 'py'`
# sbo:jdk `add jdk package from the sbo repository`
# slack:*multi* `add packages include string 'multi' from the slack`
# msb:*.txz `add packages ends with '.txz' from the msb repository`
# #
# Sometimes the automatic kernel update creates problems because you # Sometimes the automatic kernel update creates problems because you
# may need to file intervention 'lilo'. The slpkg automatically detects # may need to file intervention 'lilo'. The slpkg automatically detects

View file

@ -2,7 +2,7 @@
# #
# slpkg.conf file is part of slpkg. # slpkg.conf file is part of slpkg.
# #
# Copyright 2014-2019 Dimitris Zlatanidis <d.zlatanidis@gmail.com> # Copyright 2014-2020 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved. # All rights reserved.
# #
# Slpkg is a user-friendly package manager for Slackware installations. # Slpkg is a user-friendly package manager for Slackware installations.
@ -115,10 +115,6 @@ SLACKPKG_LOG=on
# packages required for distribution. # packages required for distribution.
ONLY_INSTALLED=off ONLY_INSTALLED=off
# Enable or disable the progress bar. Status bar progress delays the search
# process in package lists. Default is "off".
PRG_BAR=off
# Register a text editor that uses the slpkg in a few options. # Register a text editor that uses the slpkg in a few options.
# Default is "nano". # Default is "nano".
EDITOR=nano EDITOR=nano

View file

@ -23,10 +23,7 @@
import os import os
import sys
import time import time
import shutil
from slpkg.md5sum import md5
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
try: try:
@ -52,12 +49,11 @@ optional_requires = [
def print_logo(): def print_logo():
"""print slpkg logo""" """print slpkg logo"""
if "install" not in sys.argv:
logo_fname = os.path.join(os.path.dirname(__file__), 'logo.txt') logo_fname = os.path.join(os.path.dirname(__file__), 'logo.txt')
with open(logo_fname, 'rb') as f: with open(logo_fname, 'rb') as f:
logo = f.read().decode('utf-8') logo = f.read().decode('utf-8')
print(logo) print(logo)
time.sleep(1) time.sleep(0.5)
print_logo() print_logo()
@ -104,29 +100,3 @@ setup(
"Topic :: Utilities"], "Topic :: Utilities"],
python_requires=">=3.7" python_requires=">=3.7"
) )
# Install configuration files with pip.
if "install" in sys.argv:
conf_file = [
"conf/slpkg.conf",
"conf/repositories.conf",
"conf/blacklist",
"conf/slackware-mirrors",
"conf/default-repositories",
"conf/custom-repositories",
"conf/rlworkman.deps",
"conf/pkg_security"
]
if not os.path.exists(_meta_.conf_path):
os.makedirs(_meta_.conf_path)
for conf in conf_file:
filename = conf.split("/")[-1]
if os.path.isfile(_meta_.conf_path + filename):
old = md5(_meta_.conf_path + filename)
new = md5(conf)
if old != new:
shutil.copy2(conf, _meta_.conf_path + filename + ".new")
else:
shutil.copy2(conf, _meta_.conf_path)
shutil.copy2(conf_file[0],
_meta_.conf_path + conf_file[0].split("/")[-1] + ".orig")

View file

@ -77,18 +77,15 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
# skip pip installs
sed -i 's/if "install"/if ""/' setup.py
python3 setup.py install --root=$PKG python3 setup.py install --root=$PKG
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
# install configuration files
mkdir -p $PKG/etc/slpkg mkdir -p $PKG/etc/slpkg
# install configurations files CONFIGS="slpkg.conf repositories.conf blacklist slackware-mirrors \
CONFIGS="slpkg.conf repositories.conf blacklist slackware-mirrors default-repositories \ default-repositories custom-repositories rlworkman.deps pkg_security"
custom-repositories rlworkman.deps pkg_security"
for file in $CONFIGS; do for file in $CONFIGS; do
install -D -m0644 conf/$file $PKG/etc/slpkg/${file}.new install -D -m0644 conf/$file $PKG/etc/slpkg/${file}.new
done done

View file

@ -76,7 +76,7 @@ class MetaData:
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (3, 8, 0) __version_info__ = (3, 8, 1)
__version__ = "{0}.{1}.{2}".format(*__version_info__) __version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)" __license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com" __email__ = "d.zlatanidis@gmail.com"

View file

@ -30,7 +30,7 @@ from slpkg.slack.slack_version import slack_ver
def header(): def header():
"""help header message""" """help header message"""
print(f"\nslpkg - version {_meta_.__version__} | Slackware release: {_meta_.slack_rel} - {slack_ver()}\n") print(f"slpkg - version {_meta_.__version__} | Slackware release: {_meta_.slack_rel} - {slack_ver()}\n")
def options(): def options():

View file

@ -25,7 +25,6 @@
from pkg_resources import parse_version from pkg_resources import parse_version
from slpkg.messages import Msg from slpkg.messages import Msg
from slpkg.toolbar import status
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.upgrade_checklist import choose_upg from slpkg.upgrade_checklist import choose_upg
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -48,7 +47,6 @@ def pkg_upgrade(repo, skip, flag):
# unsize = data[3] # unsize = data[3]
data = repo_data(PACKAGES_TXT, repo, flag="") data = repo_data(PACKAGES_TXT, repo, flag="")
for pkg in installed(): for pkg in installed():
status(0.0005)
inst_pkg = split_package(pkg) inst_pkg = split_package(pkg)
for name in data[0]: for name in data[0]:
if name: # this tips because some pkg_name is empty if name: # this tips because some pkg_name is empty

View file

@ -24,7 +24,6 @@
import sys import sys
from slpkg.toolbar import status
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.binary.greps import Requires from slpkg.binary.greps import Requires
@ -48,13 +47,16 @@ class Dependencies:
requires = Requires(name, self.repo).get_deps() requires = Requires(name, self.repo).get_deps()
if requires: if requires:
for req in requires: for req in requires:
status(0)
if req and req not in self.black: if req and req not in self.black:
dependencies.append(req) dependencies.append(req)
if dependencies: self.deep_check(dependencies, flag)
self.dep_results.append(dependencies)
for dep in dependencies:
self.binary(dep, flag)
return self.dep_results return self.dep_results
else: else:
return [] return []
def deep_check(self, dependencies, flag):
"""Checking if dependencies are finnished
"""
if dependencies:
self.dep_results.append(dependencies)
[self.binary(dep, flag) for dep in dependencies]

View file

@ -23,7 +23,6 @@
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.toolbar import status
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -36,8 +35,6 @@ def repo_data(PACKAGES_TXT, repo, flag):
(name, location, size, unsize, (name, location, size, unsize,
rname, rlocation, rsize, runsize) = ([] for i in range(8)) rname, rlocation, rsize, runsize) = ([] for i in range(8))
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
if _meta_.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
status(0.000005)
if line.startswith("PACKAGE NAME:"): if line.startswith("PACKAGE NAME:"):
name.append(line[15:].strip()) name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION:"): if line.startswith("PACKAGE LOCATION:"):
@ -46,7 +43,14 @@ def repo_data(PACKAGES_TXT, repo, flag):
size.append(line[28:-2].strip()) size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed):"): if line.startswith("PACKAGE SIZE (uncompressed):"):
unsize.append(line[30:-2].strip()) unsize.append(line[30:-2].strip())
if repo == "rlw":
if repo == "slack":
(rname,
rlocation,
rsize,
runsize
) = slack_filter(name, location, size, unsize, flag)
elif repo == "rlw":
(rname, (rname,
rlocation, rlocation,
rsize, rsize,
@ -75,6 +79,30 @@ def repo_data(PACKAGES_TXT, repo, flag):
return [rname, rlocation, rsize, runsize] return [rname, rlocation, rsize, runsize]
def slack_filter(name, location, size, unsize, flag):
"""Slackware filter seperate packages from patches/ directory
"""
(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)
fsize.append(s)
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)
fsize.append(s)
funsize.append(u)
return [fname, flocation, fsize, funsize]
def rlw_filter(name, location, size, unsize): def rlw_filter(name, location, size, unsize):
"""Filter rlw repository data """Filter rlw repository data
""" """

View file

@ -28,7 +28,6 @@ from pkg_resources import parse_version
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.sizes import units from slpkg.sizes import units
from slpkg.messages import Msg from slpkg.messages import Msg
from slpkg.toolbar import status
from slpkg.checksum import check_md5 from slpkg.checksum import check_md5
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.downloader import Download from slpkg.downloader import Download
@ -47,8 +46,6 @@ from slpkg.binary.greps import repo_data
from slpkg.binary.repo_init import RepoInit from slpkg.binary.repo_init import RepoInit
from slpkg.binary.dependency import Dependencies from slpkg.binary.dependency import Dependencies
from slpkg.slack.slack_version import slack_ver
class BinaryInstall: class BinaryInstall:
"""Install binaries packages with all dependencies from """Install binaries packages with all dependencies from
@ -82,7 +79,7 @@ class BinaryInstall:
self.repo_pkg_names = [] self.repo_pkg_names = []
for name in self.data[0]: for name in self.data[0]:
self.repo_pkg_names.append(split_package(name)[0]) self.repo_pkg_names.append(split_package(name)[0])
self.blacklist = BlackList().packages(self.data[0], self.repo) self.blacklist = BlackList().get_black()
self.matching = False self.matching = False
def init_flags(self): def init_flags(self):
@ -266,7 +263,6 @@ class BinaryInstall:
self.flag != "--resolve-off"): self.flag != "--resolve-off"):
self.msg.resolving() self.msg.resolving()
for dep in self.packages: for dep in self.packages:
status(0.05)
dependencies = [] dependencies = []
dependencies = Utils().dimensional_list(Dependencies( dependencies = Utils().dimensional_list(Dependencies(
self.repo, self.blacklist).binary(dep, self.flag)) self.repo, self.blacklist).binary(dep, self.flag))
@ -290,6 +286,7 @@ class BinaryInstall:
for pkg, comp in zip(install, comp_sum): for pkg, comp in zip(install, comp_sum):
pkg_repo = split_package(pkg[:-4]) pkg_repo = split_package(pkg[:-4])
if find_package(pkg[:-4], self.meta.pkg_path): if find_package(pkg[:-4], self.meta.pkg_path):
if "--reinstall" in self.flag:
pkg_sum += 1 pkg_sum += 1
COLOR = self.meta.color["GREEN"] COLOR = self.meta.color["GREEN"]
elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name(): elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name():
@ -331,6 +328,7 @@ class BinaryInstall:
install.append(pk) install.append(pk)
comp_sum.append(comp) comp_sum.append(comp)
uncomp_sum.append(uncomp) uncomp_sum.append(uncomp)
if not install: if not install:
for pkg in packages: for pkg in packages:
for pk, loc, comp, uncomp in zip(self.data[0], self.data[1], for pk, loc, comp, uncomp in zip(self.data[0], self.data[1],
@ -346,26 +344,5 @@ class BinaryInstall:
install.reverse() install.reverse()
comp_sum.reverse() comp_sum.reverse()
uncomp_sum.reverse() uncomp_sum.reverse()
if self.repo == "slack":
dwn, install, comp_sum, uncomp_sum = self.patches(dwn, install,
comp_sum,
uncomp_sum)
return [dwn, install, comp_sum, uncomp_sum]
def patches(self, dwn, install, comp_sum, uncomp_sum): return [dwn, install, comp_sum, uncomp_sum]
"""Seperates packages from patches/ directory
"""
dwnp, installp, comp_sump, uncomp_sump = ([] for i in range(4))
for d, i, c, u in zip(dwn, install, comp_sum, uncomp_sum):
if "_slack" + slack_ver() in i:
dwnp.append(d)
dwn.remove(d)
installp.append(i)
install.remove(i)
comp_sump.append(c)
comp_sum.remove(c)
uncomp_sump.append(u)
uncomp_sum.remove(u)
if "--patches" in self.flag:
return dwnp, installp, comp_sump, uncomp_sump
return dwn, install, comp_sum, uncomp_sum

View file

@ -41,9 +41,9 @@ class RepoInit:
def fetch(self): def fetch(self):
if self.repo in self.meta.default_repositories: if self.repo in self.meta.default_repositories:
exec(f"self._init_{self.repo}()") getattr(self, f"_init_{self.repo}")()
else: else:
exec("self._init_custom()") self._init_custom()
self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT" self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT"
PACKAGES_TXT = Utils().read_file(self.lib) PACKAGES_TXT = Utils().read_file(self.lib)
return PACKAGES_TXT, self.mirror return PACKAGES_TXT, self.mirror

View file

@ -33,6 +33,6 @@ def search_pkg(name, repo):
""" """
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT") PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
names = list(Utils().package_name(PACKAGES_TXT)) names = list(Utils().package_name(PACKAGES_TXT))
blacklist = BlackList().packages(pkgs=names, repo=repo) blacklist = BlackList().get_black()
if name in names and name not in blacklist: if name in names and name not in blacklist:
return name return name

View file

@ -25,7 +25,6 @@
import os import os
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -33,7 +32,6 @@ class BlackList:
"""Blacklist class to add, remove or listed packages """Blacklist class to add, remove or listed packages
in blacklist file.""" in blacklist file."""
def __init__(self): def __init__(self):
self.quit = False
self.green = _meta_.color["GREEN"] self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"] self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
@ -55,89 +53,30 @@ class BlackList:
def listed(self): def listed(self):
"""Print blacklist packages """Print blacklist packages
""" """
print("\nPackages in the blacklist:\n") print("Packages in the blacklist:\n")
for black in self.get_black(): for black in self.get_black():
if black: if black:
print(f"{self.green}{black}{self.endc}") print(f"{self.green}{black}{self.endc}")
self.quit = True
if self.quit:
print() # new line at exit
def add(self, pkgs): def add(self, pkgs):
"""Add blacklist packages if not exist """Add blacklist packages if not exist
""" """
blacklist = self.get_black() blacklist = self.get_black()
pkgs = set(pkgs) pkgs = set(pkgs)
print("\nAdd packages in the blacklist:\n") print("Add packages in the blacklist:\n")
with open(self.blackfile, "a") as black_conf: with open(self.blackfile, "a") as black_conf:
for pkg in pkgs: for pkg in pkgs:
if pkg not in blacklist: if pkg not in blacklist:
print(f"{self.green}{pkg}{self.endc}") print(f"{self.green}{pkg}{self.endc}")
black_conf.write(pkg + "\n") black_conf.write(pkg + "\n")
self.quit = True
if self.quit:
print() # new line at exit
def remove(self, pkgs): def remove(self, pkgs):
"""Remove packages from blacklist """Remove packages from blacklist
""" """
print("\nRemove packages from the blacklist:\n") print("Remove packages from the blacklist:\n")
with open(self.blackfile, "w") as remove: with open(self.blackfile, "w") as remove:
for line in self.black_conf.splitlines(): for line in self.black_conf.splitlines():
if line not in pkgs: if line not in pkgs:
remove.write(line + "\n") remove.write(line + "\n")
else: else:
print(f"{self.red}{line}{self.endc}") print(f"{self.red}{line}{self.endc}")
self.quit = True
if self.quit:
print() # new line at exit
def packages(self, pkgs, repo):
"""Return packages in blacklist or by repository
"""
self.black = []
for bl in self.get_black():
pr = bl.split(":")
for pkg in pkgs:
self.__priority(pr, repo, pkg)
self.__blackpkg(bl, repo, pkg)
return self.black
def __add(self, repo, pkg):
"""Split packages by repository
"""
if repo == "sbo":
return pkg
else:
return split_package(pkg)[0]
def __priority(self, pr, repo, pkg):
"""Add packages in blacklist by priority
"""
if (pr[0] == repo and pr[1].startswith("*") and
pr[1].endswith("*")):
if pr[1][1:-1] in pkg:
self.black.append(self.__add(repo, pkg))
elif pr[0] == repo and pr[1].endswith("*"):
if pkg.startswith(pr[1][:-1]):
self.black.append(self.__add(repo, pkg))
elif pr[0] == repo and pr[1].startswith("*"):
if pkg.endswith(pr[1][1:]):
self.black.append(self.__add(repo, pkg))
elif pr[0] == repo and "*" not in pr[1]:
self.black.append(self.__add(repo, pkg))
def __blackpkg(self, bl, repo, pkg):
"""Add packages in blacklist
"""
if bl.startswith("*") and bl.endswith("*"):
if bl[1:-1] in pkg:
self.black.append(self.__add(repo, pkg))
elif bl.endswith("*"):
if pkg.startswith(bl[:-1]):
self.black.append(self.__add(repo, pkg))
elif bl.startswith("*"):
if pkg.endswith(bl[1:]):
self.black.append(self.__add(repo, pkg))
if bl not in self.black and "*" not in bl:
self.black.append(bl)

View file

@ -66,7 +66,6 @@ class Updates:
def status_bar(self): def status_bar(self):
"""Top view bar status """Top view bar status
""" """
print()
self.msg.template(78) self.msg.template(78)
print("| Repository Status") print("| Repository Status")
self.msg.template(78) self.msg.template(78)

View file

@ -44,7 +44,6 @@ class Config:
def view(self): def view(self):
"""View slpkg config file """View slpkg config file
""" """
print() # new line at start
conf_args = [ conf_args = [
"RELEASE", "RELEASE",
"SLACKWARE_VERSION", "SLACKWARE_VERSION",

View file

@ -53,7 +53,6 @@ class PkgDesc:
def view(self): def view(self):
"""Print package description by repository """Print package description by repository
""" """
print() # new line at start
description, count = "", 0 description, count = "", 0
if self.repo == "sbo": if self.repo == "sbo":
description = SBoGrep(self.name).description() description = SBoGrep(self.name).description()
@ -68,7 +67,4 @@ class PkgDesc:
if description: if description:
print(f"{self.color}{description}{self.meta.color['ENDC']}") print(f"{self.color}{description}{self.meta.color['ENDC']}")
else: else:
self.msg.pkg_not_found("", self.name, "No matching", "\n") self.msg.pkg_not_found("", self.name, "No matching", "")
raise SystemExit(1)
if description and self.repo == "sbo":
print()

View file

@ -114,7 +114,7 @@ class Initialization:
os.mkdir(log) os.mkdir(log)
if not os.path.exists(lib): if not os.path.exists(lib):
os.mkdir(lib) os.mkdir(lib)
dirs = ["core/", "extra/", "pasture/", "patches/"] dirs = ["core/", "extra/", "patches/"]
for d in dirs: for d in dirs:
if not os.path.exists(lib + d): if not os.path.exists(lib + d):
os.mkdir(lib + d) os.mkdir(lib + d)
@ -123,10 +123,8 @@ class Initialization:
CHECKSUMS_MD5 = mirrors(md5_file, "") CHECKSUMS_MD5 = mirrors(md5_file, "")
self.EXTRA = mirrors(lib_file, dirs[1]) self.EXTRA = mirrors(lib_file, dirs[1])
self.EXT_CHECKSUMS = mirrors(md5_file, dirs[1]) self.EXT_CHECKSUMS = mirrors(md5_file, dirs[1])
self.PASTURE = mirrors(lib_file, dirs[2]) self.PATCHES = mirrors(lib_file, dirs[2])
self.PAS_CHECKSUMS = mirrors(md5_file, dirs[2]) self.PAT_CHECKSUMS = mirrors(md5_file, dirs[2])
self.PATCHES = mirrors(lib_file, dirs[3])
self.PAT_CHECKSUMS = mirrors(md5_file, dirs[3])
ChangeLog_txt = mirrors(log_file, "") ChangeLog_txt = mirrors(log_file, "")
if self.check: if self.check:
return self.checks_logs(log, ChangeLog_txt) return self.checks_logs(log, ChangeLog_txt)
@ -134,21 +132,16 @@ class Initialization:
self.down(lib + dirs[0], CHECKSUMS_MD5, repo_name) self.down(lib + dirs[0], CHECKSUMS_MD5, repo_name)
self.down(lib + dirs[1], self.EXTRA, repo_name) self.down(lib + dirs[1], self.EXTRA, repo_name)
self.down(lib + dirs[1], self.EXT_CHECKSUMS, repo_name) self.down(lib + dirs[1], self.EXT_CHECKSUMS, repo_name)
if slack_ver() != "14.0": # no pasture/ folder for 14.0 version self.down(lib + dirs[2], self.PATCHES, repo_name)
self.down(lib + dirs[2], self.PASTURE, repo_name) self.down(lib + dirs[2], self.PAT_CHECKSUMS, repo_name)
self.down(lib + dirs[2], self.PAS_CHECKSUMS, repo_name)
self.down(lib + dirs[3], self.PATCHES, repo_name)
self.down(lib + dirs[3], self.PAT_CHECKSUMS, repo_name)
self.down(log, ChangeLog_txt, repo_name) self.down(log, ChangeLog_txt, repo_name)
self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5, self.remote(log, ChangeLog_txt, lib, PACKAGES_TXT, CHECKSUMS_MD5,
FILELIST_TXT, repo_name) FILELIST_TXT, repo_name)
self.merge(lib, "PACKAGES.TXT", ["core/PACKAGES.TXT", self.merge(lib, "PACKAGES.TXT", ["core/PACKAGES.TXT",
"extra/PACKAGES.TXT", "extra/PACKAGES.TXT",
"pasture/PACKAGES.TXT",
"patches/PACKAGES.TXT"]) "patches/PACKAGES.TXT"])
self.merge(lib, "CHECKSUMS.md5", ["core/CHECKSUMS.md5", self.merge(lib, "CHECKSUMS.md5", ["core/CHECKSUMS.md5",
"extra/CHECKSUMS.md5", "extra/CHECKSUMS.md5",
"pasture/CHECKSUMS.md5",
"patches/CHECKSUMS_md5"]) "patches/CHECKSUMS_md5"])
def sbo(self): def sbo(self):
@ -669,7 +662,7 @@ class Initialization:
self.file_remove(lib_path, CHECKSUMS_MD5.split("/")[-1]) self.file_remove(lib_path, CHECKSUMS_MD5.split("/")[-1])
self.file_remove(lib_path, FILELIST_TXT.split("/")[-1]) self.file_remove(lib_path, FILELIST_TXT.split("/")[-1])
if repo == "slack": if repo == "slack":
dirs = ["core/", "extra/", "pasture/"] dirs = ["core/", "extra/"]
for d in dirs: for d in dirs:
self.file_remove(lib_path + d, "PACKAGES.TXT") self.file_remove(lib_path + d, "PACKAGES.TXT")
self.file_remove(lib_path + d, "CHECKSUMS.md5") self.file_remove(lib_path + d, "CHECKSUMS.md5")
@ -677,9 +670,6 @@ class Initialization:
self.down(lib_path + "core/", CHECKSUMS_MD5, repo) self.down(lib_path + "core/", CHECKSUMS_MD5, repo)
self.down(lib_path + "extra/", self.EXTRA, repo) self.down(lib_path + "extra/", self.EXTRA, repo)
self.down(lib_path + "extra/", self.EXT_CHECKSUMS, repo) self.down(lib_path + "extra/", self.EXT_CHECKSUMS, repo)
if slack_ver() != "14.0": # no pasture/ folder for 14.0 version
self.down(lib_path + "pasture/", self.PASTURE, repo)
self.down(lib_path + "pasture/", self.PAS_CHECKSUMS, repo)
# download new files # download new files
if repo != "slack": if repo != "slack":
self.down(lib_path, PACKAGES_TXT, repo) self.down(lib_path, PACKAGES_TXT, repo)

View file

@ -62,7 +62,7 @@ class NewConfig:
"""Find all '.new' files from /etc/ folder """Find all '.new' files from /etc/ folder
and subfolders and subfolders
""" """
print("\nSearch for .new configuration files:\n") print("Search for .new configuration files:\n")
for path, dirs, files in os.walk(self.etc): for path, dirs, files in os.walk(self.etc):
del dirs # delete unsed del dirs # delete unsed
for f in files: for f in files:

View file

@ -32,7 +32,7 @@ def searching(find_pkg, directory):
""" """
if os.path.isdir(directory): if os.path.isdir(directory):
installed = os.listdir(directory) installed = os.listdir(directory)
blacklist = BlackList().packages(pkgs=installed, repo="local") blacklist = BlackList().get_black()
if os.path.exists(directory): if os.path.exists(directory):
for pkg in installed: for pkg in installed:
if (not pkg.startswith(".") and pkg.startswith(find_pkg) and if (not pkg.startswith(".") and pkg.startswith(find_pkg) and

View file

@ -199,7 +199,7 @@ class PackageManager:
def _view_removed(self): def _view_removed(self):
"""View packages before removed """View packages before removed
""" """
print("\nPackages with name matching [ {0}{1}{2} ]\n".format( print("Packages with name matching [ {0}{1}{2} ]\n".format(
self.cyan, ", ".join(self.binary), self.endc)) self.cyan, ", ".join(self.binary), self.endc))
removed, packages = self._get_removed() removed, packages = self._get_removed()
if packages and "--checklist" in self.extra: if packages and "--checklist" in self.extra:
@ -220,10 +220,9 @@ class PackageManager:
self._calc_sizes() self._calc_sizes()
self._remove_summary() self._remove_summary()
if "--third-party" in self.extra: if "--third-party" in self.extra:
print("\n") print()
self.msg.template(78) self.msg.template(78)
print(("| {0}{1}*** WARNING ***{2}").format( print(f"| {' ' * 27}{self.red}*** WARNING ***{self.endc}")
" " * 27, self.red, self.endc))
print("| Before you use third-party option, be sure you have" print("| Before you use third-party option, be sure you have"
" updated the packages \n| lists. Run the command" " updated the packages \n| lists. Run the command"
" 'slpkg update' and 'slpkg -c slack --upgrade'") " 'slpkg update' and 'slpkg -c slack --upgrade'")
@ -395,7 +394,7 @@ class PackageManager:
matching, packages = 0, [] matching, packages = 0, []
pkg_cache, match_cache = "", "" pkg_cache, match_cache = "", ""
slack_packages, slack_names = slackware_repository() slack_packages, slack_names = slackware_repository()
print("\nPackages with matching name [ {0}{1}{2} ]\n".format( print("Packages with matching name [ {0}{1}{2} ]\n".format(
self.cyan, ", ".join(self.binary), self.endc)) self.cyan, ", ".join(self.binary), self.endc))
for pkg in self.binary: for pkg in self.binary:
for match in find_package("", self.meta.pkg_path): for match in find_package("", self.meta.pkg_path):
@ -454,7 +453,8 @@ class PackageManager:
for pkg in self.binary: for pkg in self.binary:
name = GetFromInstalled(pkg).name() name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version() ver = GetFromInstalled(pkg).version()
find = find_package(f"{name}{ver}{self.meta.sp}", self.meta.pkg_path) find = find_package(f"{name}{ver}{self.meta.sp}",
self.meta.pkg_path)
if find: if find:
package = Utils().read_file( package = Utils().read_file(
self.meta.pkg_path + "".join(find)) self.meta.pkg_path + "".join(find))
@ -536,8 +536,8 @@ class PackageManager:
packages = "" packages = ""
if repo == "sbo": if repo == "sbo":
if (os.path.isfile( if (os.path.isfile(
self.meta.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")): self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT")):
packages = Utils().read_file(self.meta.lib_path + f"{repo}_repo/SLACKBUILDS.TXT") packages = Utils().read_file(self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT")
else: else:
if (os.path.isfile( if (os.path.isfile(
self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")): self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):

View file

@ -38,6 +38,7 @@ class FindFromRepos:
self.count_pkg = 0 self.count_pkg = 0
self.count_repo = 0 self.count_repo = 0
self.meta = _meta_ self.meta = _meta_
self.msg = Msg()
self.cyan = self.meta.color["CYAN"] self.cyan = self.meta.color["CYAN"]
self.grey = self.meta.color["GREY"] self.grey = self.meta.color["GREY"]
self.endc = self.meta.color["ENDC"] self.endc = self.meta.color["ENDC"]
@ -45,10 +46,10 @@ class FindFromRepos:
def find(self, pkg, flag): def find(self, pkg, flag):
"""Start to find packages and print """Start to find packages and print
""" """
print(f"\nPackages with name matching [ {self.cyan}{', '.join(pkg)}{self.endc} ]\n") print(f"Packages with name matching [ {self.cyan}{', '.join(pkg)}{self.endc} ]\n")
Msg().template(78) self.msg.template(78)
print(f"| Repository Package {' ' * 54}Size") print(f"| Repository Package {' ' * 54}Size")
Msg().template(78) self.msg.template(78)
for repo in _meta_.repositories: for repo in _meta_.repositories:
PACKAGES_TXT = PackageManager(pkg).list_lib(repo) PACKAGES_TXT = PackageManager(pkg).list_lib(repo)
packages, sizes = PackageManager(pkg).list_greps(repo, packages, sizes = PackageManager(pkg).list_greps(repo,

View file

@ -61,11 +61,14 @@ class RepoInfo:
status = f"{self.red}disabled{self.endc}" status = f"{self.red}disabled{self.endc}"
self.form["Status:"] = status self.form["Status:"] = status
self.form["Default:"] = "no" self.form["Default:"] = "no"
if repo in self.meta.default_repositories: if repo in self.meta.default_repositories:
self.form["Default:"] = "yes" self.form["Default:"] = "yes"
if (repo in self.meta.repositories and if (repo in self.meta.repositories and
os.path.isfile(self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")): os.path.isfile(self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):
status = f"{self.green}enabled{self.endc}" status = f"{self.green}enabled{self.endc}"
if repo != "sbo": if repo != "sbo":
data = self.repository_data(repo) data = self.repository_data(repo)
size = units(data[1], data[2]) size = units(data[1], data[2])
@ -79,18 +82,20 @@ class RepoInfo:
self.form["Status:"] = status self.form["Status:"] = status
self.form["Last updated:"] = data[3] self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile( elif (repo == "sbo" and os.path.isfile(
self.meta.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(repo))): self.meta.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")):
status = "{0}enabled{1}".format(self.meta.color["GREEN"], status = f"{self.green}enabled{self.endc}"
self.meta.color["ENDC"])
sum_sbo_pkgs = 0 sum_sbo_pkgs = 0
for line in (Utils().read_file( for line in (Utils().read_file(
self.meta.lib_path + "sbo_repo/SLACKBUILDS." self.meta.lib_path + "sbo_repo/SLACKBUILDS."
"TXT").splitlines()): "TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "): if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1 sum_sbo_pkgs += 1
changelog_txt = Utils().read_file( changelog_txt = Utils().read_file(
self.meta.log_path + "sbo/ChangeLog.txt") self.meta.log_path + "sbo/ChangeLog.txt")
last_upd = changelog_txt.split("\n", 1)[0] last_upd = changelog_txt.split("\n", 1)[0]
self.form["Repo id:"] = repo self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo] self.form["Repo url:"] = self.all_repos[repo]
self.form["Total compressed packages:"] = "" self.form["Total compressed packages:"] = ""
@ -98,19 +103,17 @@ class RepoInfo:
self.form["Number of packages:"] = sum_sbo_pkgs self.form["Number of packages:"] = sum_sbo_pkgs
self.form["Status:"] = status self.form["Status:"] = status
self.form["Last updated:"] = last_upd self.form["Last updated:"] = last_upd
print()
for key, value in sorted(self.form.items()): for key, value in sorted(self.form.items()):
print(self.meta.color["GREY"] + key + self.meta.color["ENDC"], print(f"{self.green}{key}{self.endc} {value}")
value)
print()
raise SystemExit()
def repository_data(self, repo): def repository_data(self, repo):
""" """
Grap data packages Grap data packages
""" """
sum_pkgs, size, unsize, last_upd = 0, [], [], "" sum_pkgs, size, unsize, last_upd = 0, [], [], ""
f = self.meta.lib_path + repo + "_repo/PACKAGES.TXT" f = f"{self.meta.lib_path}{repo}_repo/PACKAGES.TXT"
for line in Utils().read_file(f).splitlines(): for line in Utils().read_file(f).splitlines():
if line.startswith("PACKAGES.TXT;"): if line.startswith("PACKAGES.TXT;"):
last_upd = line[14:].strip() last_upd = line[14:].strip()
@ -120,8 +123,10 @@ class RepoInfo:
size.append(line[28:-2].strip()) size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed): "): if line.startswith("PACKAGE SIZE (uncompressed): "):
unsize.append(line[30:-2].strip()) unsize.append(line[30:-2].strip())
if repo in ["salix", "slackl"]: if repo in ["salix", "slackl"]:
log = Utils().read_file( log = Utils().read_file(
self.meta.log_path + "{0}/ChangeLog.txt".format(repo)) self.meta.log_path + f"{repo}/ChangeLog.txt")
last_upd = log.split("\n", 1)[0] last_upd = log.split("\n", 1)[0]
return [sum_pkgs, size, unsize, last_upd] return [sum_pkgs, size, unsize, last_upd]

View file

@ -32,6 +32,10 @@ class RepoList:
""" """
def __init__(self): def __init__(self):
self.meta = _meta_ self.meta = _meta_
self.green = self.meta.color["GREEN"]
self.red = self.meta.color["RED"]
self.grey = self.meta.color["GREY"]
self.endc = self.meta.color["ENDC"]
self.msg = Msg() self.msg = Msg()
self.all_repos = Repo().default_repository() self.all_repos = Repo().default_repository()
self.all_repos["slack"] = Repo().slack() self.all_repos["slack"] = Repo().slack()
@ -41,7 +45,6 @@ class RepoList:
"""View or enabled or disabled repositories """View or enabled or disabled repositories
""" """
def_cnt, cus_cnt = 0, 0 def_cnt, cus_cnt = 0, 0
print()
self.msg.template(78) self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}".format( print("{0}{1}{2}{3}{4}{5}{6}".format(
"| Repo id", " " * 2, "| Repo id", " " * 2,
@ -50,13 +53,13 @@ class RepoList:
"Status")) "Status"))
self.msg.template(78) self.msg.template(78)
for repo_id, repo_URL in sorted(self.all_repos.items()): for repo_id, repo_URL in sorted(self.all_repos.items()):
status, COLOR = "disabled", self.meta.color["RED"] status, COLOR = "disabled", self.red
default = "yes" default = "yes"
if len(repo_URL) > 49: if len(repo_URL) > 49:
repo_URL = repo_URL[:48] + "~" repo_URL = repo_URL[:48] + "~"
if repo_id in self.meta.repositories: if repo_id in self.meta.repositories:
def_cnt += 1 def_cnt += 1
status, COLOR = "enabled", self.meta.color["GREEN"] status, COLOR = "enabled", self.green
if repo_id not in self.meta.default_repositories: if repo_id not in self.meta.default_repositories:
cus_cnt += 1 cus_cnt += 1
default = "no" default = "no"
@ -64,13 +67,12 @@ class RepoList:
repo_id, " " * (9 - len(repo_id)), repo_id, " " * (9 - len(repo_id)),
repo_URL, " " * (52 - len(repo_URL)), repo_URL, " " * (52 - len(repo_URL)),
default, " " * (8 - len(default)), default, " " * (8 - len(default)),
COLOR, status, self.meta.color["ENDC"])) COLOR, status, self.endc))
print("\nRepositories summary") print("\nRepositories summary")
print("=" * 79) print("=" * 79)
print("{0}{1}/{2} enabled default repositories and {3} custom.".format( print(f"{self.grey}{def_cnt}/{len(self.all_repos)} enabled default "
self.meta.color["GREY"], def_cnt, len(self.all_repos), cus_cnt)) f"repositories and {cus_cnt} custom.")
print("Edit the file '/etc/slpkg/repositories.conf' for enable " print("Edit the file '/etc/slpkg/repositories.conf' for enable "
"and disable default\nrepositories or run 'slpkg " "and disable default\nrepositories or run 'slpkg "
"repo-enable' command.\n{0}".format(self.meta.color["ENDC"])) f"repo-enable' command.{self.endc}")
raise SystemExit()

View file

@ -26,7 +26,6 @@ import os
from pkg_resources import parse_version from pkg_resources import parse_version
from slpkg.messages import Msg from slpkg.messages import Msg
from slpkg.toolbar import status
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.upgrade_checklist import choose_upg from slpkg.upgrade_checklist import choose_upg
@ -38,12 +37,12 @@ from slpkg.sbo.greps import SBoGrep
def sbo_upgrade(skip, flag): def sbo_upgrade(skip, flag):
"""Return packages for upgrade """Return packages for upgrade
""" """
Msg().checking() msg = Msg()
msg.checking()
upgrade_names = [] upgrade_names = []
data = SBoGrep(name="").names() data = SBoGrep(name="").names()
blacklist = BlackList().packages(pkgs=data, repo="sbo") blacklist = BlackList().get_black()
for pkg in sbo_list(): for pkg in sbo_list():
status(0.02)
name = split_package(pkg)[0] name = split_package(pkg)[0]
ver = split_package(pkg)[1] ver = split_package(pkg)[1]
if (name in data and name not in skip and name not in blacklist): if (name in data and name not in skip and name not in blacklist):
@ -51,7 +50,7 @@ def sbo_upgrade(skip, flag):
package = f"{name}-{ver}" package = f"{name}-{ver}"
if parse_version(sbo_package) > parse_version(package): if parse_version(sbo_package) > parse_version(package):
upgrade_names.append(name) upgrade_names.append(name)
Msg().done() msg.done()
if "--checklist" in flag: if "--checklist" in flag:
upgrade_names = choose_upg(upgrade_names) upgrade_names = choose_upg(upgrade_names)
return upgrade_names return upgrade_names
@ -60,8 +59,6 @@ def sbo_upgrade(skip, flag):
def sbo_list(): def sbo_list():
"""Return all SBo packages """Return all SBo packages
""" """
sbo_packages = []
for pkg in os.listdir(_meta_.pkg_path): for pkg in os.listdir(_meta_.pkg_path):
if pkg.endswith("_SBo"): if pkg.endswith("_SBo"):
sbo_packages.append(pkg) yield pkg
return sbo_packages

View file

@ -24,7 +24,6 @@
import sys import sys
from slpkg.toolbar import status
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.__metadata__ import MetaData as _meta_ from slpkg.__metadata__ import MetaData as _meta_
@ -38,8 +37,7 @@ class Requires:
self.flag = flag self.flag = flag
self.meta = _meta_ self.meta = _meta_
self.SLACKBUILDS_TXT = SBoGrep(name="").names() self.SLACKBUILDS_TXT = SBoGrep(name="").names()
self.blacklist = BlackList().packages(pkgs=self.SLACKBUILDS_TXT, self.blacklist = BlackList().get_black()
repo="sbo")
self.dep_results = [] self.dep_results = []
def sbo(self, name): def sbo(self, name):
@ -52,8 +50,6 @@ class Requires:
requires = SBoGrep(name).requires() requires = SBoGrep(name).requires()
if requires: if requires:
for req in requires: for req in requires:
status(0.03)
# toolbar_width = status(index, toolbar_width, 1)
# avoid to add %README% as dependency and # avoid to add %README% as dependency and
# if require in blacklist # if require in blacklist
if "%README%" not in req and req not in self.blacklist: if "%README%" not in req and req not in self.blacklist:

View file

@ -76,7 +76,7 @@ class SBoNetwork:
self.with_checklist() self.with_checklist()
grep = SBoGrep(self.name) grep = SBoGrep(self.name)
self.sbo_files = grep.files() self.sbo_files = grep.files()
self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo") self.blacklist = BlackList().get_black()
self.sbo_url = sbo_search_pkg(self.name) self.sbo_url = sbo_search_pkg(self.name)
if self.sbo_url: if self.sbo_url:
self.sbo_desc = grep.description()[len(self.name) + 2:-1] self.sbo_desc = grep.description()[len(self.name) + 2:-1]

View file

@ -44,19 +44,22 @@ class QueuePkgs:
installation installation
""" """
def __init__(self): def __init__(self):
queue_file = [
"# In this file you can create a list of\n",
"# packages you want to build or install.\n",
"#\n"
]
self.meta = _meta_ self.meta = _meta_
self.green = _meta_.color["GREEN"] self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"] self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"] self.endc = _meta_.color["ENDC"]
self.quit = False
self.queue = self.meta.lib_path + "queue/" self.queue = self.meta.lib_path + "queue/"
self.queue_list = self.queue + "queue_list" self.queue_list = self.queue + "queue_list"
self._SOURCES = self.meta.SBo_SOURCES self._SOURCES = self.meta.SBo_SOURCES
self.touch()
def touch(self):
"""Creating the directories and the queue file
"""
queue_file = [
"# 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): if not os.path.exists(self.meta.lib_path):
os.mkdir(self.meta.lib_path) os.mkdir(self.meta.lib_path)
if not os.path.exists(self.queue): if not os.path.exists(self.queue):
@ -71,61 +74,48 @@ class QueuePkgs:
"""Return queue list from /var/lib/queue/queue_list """Return queue list from /var/lib/queue/queue_list
file. file.
""" """
queue_list = []
for read in self.queued.splitlines(): for read in self.queued.splitlines():
read = read.lstrip() read = read.lstrip()
if not read.startswith("#"): if not read.startswith("#"):
queue_list.append(read.replace("\n", "")) yield read.replace("\n", "")
return queue_list
def listed(self): def listed(self):
"""Print packages from queue """Print packages from queue
""" """
print("\nPackages in the queue:\n") print("Packages in the queue:\n")
for pkg in self.packages(): for pkg in self.packages():
if pkg:
print(f"{self.green}{pkg}{self.endc}") print(f"{self.green}{pkg}{self.endc}")
self.quit = True
if self.quit:
print() # new line at exit
def add(self, pkgs): def add(self, pkgs):
"""Add packages in queue if not exist """Add packages in queue if not exist
""" """
queue_list = self.packages() queue_list = list(self.packages())
pkgs = list(OrderedDict.fromkeys(pkgs)) pkgs = list(OrderedDict.fromkeys(pkgs))
print("\nAdd packages in the queue:\n") print("Add packages in the queue:\n")
with open(self.queue_list, "a") as queue: with open(self.queue_list, "a") as queue:
for pkg in pkgs: for pkg in pkgs:
find = sbo_search_pkg(pkg) find = sbo_search_pkg(pkg)
if pkg not in queue_list and find is not None: if pkg not in queue_list and find is not None:
print(f"{self.green}{pkg}{self.endc}") print(f"{self.green}{pkg}{self.endc}")
queue.write(pkg + "\n") queue.write(pkg + "\n")
self.quit = True
else: else:
print(f"{self.red}{pkg}{self.endc}") print(f"{self.red}{pkg}{self.endc}")
self.quit = True
if self.quit:
print() # new line at exit
def remove(self, pkgs): def remove(self, pkgs):
"""Remove packages from queue """Remove packages from queue
""" """
print("\nRemove packages from the queue:\n") print("Remove packages from the queue:\n")
with open(self.queue_list, "w") as queue: with open(self.queue_list, "w") as queue:
for line in self.queued.splitlines(): for line in self.queued.splitlines():
if line not in pkgs: if line not in pkgs:
queue.write(line + "\n") queue.write(line + "\n")
else: else:
print(f"{self.red}{line}{self.endc}") print(f"{self.red}{line}{self.endc}")
self.quit = True
if self.quit:
print() # new line at exit
def build(self): def build(self):
"""Build packages from queue """Build packages from queue
""" """
packages = self.packages() packages = list(self.packages())
if packages: if packages:
for pkg in packages: for pkg in packages:
if not os.path.exists(self.meta.build_path): if not os.path.exists(self.meta.build_path):
@ -152,7 +142,7 @@ class QueuePkgs:
def install(self): def install(self):
"""Install packages from queue """Install packages from queue
""" """
packages = self.packages() packages = list(self.packages())
if packages: if packages:
print() # new line at start print() # new line at start
for pkg in packages: for pkg in packages:

View file

@ -28,7 +28,6 @@ from pkg_resources import parse_version
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.messages import Msg from slpkg.messages import Msg
from slpkg.toolbar import status
from slpkg.log_deps import write_deps from slpkg.log_deps import write_deps
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.downloader import Download from slpkg.downloader import Download
@ -81,7 +80,7 @@ class SBoInstall:
self.count_uni = 0 self.count_uni = 0
self.msg.reading() self.msg.reading()
self.data = SBoGrep(name="").names() self.data = SBoGrep(name="").names()
self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo") self.blacklist = BlackList().get_black()
def init_flags(self): def init_flags(self):
"""Flags initialization """Flags initialization
@ -99,7 +98,6 @@ class SBoInstall:
self.is_upgrade = is_upgrade self.is_upgrade = is_upgrade
self.case_insensitive() self.case_insensitive()
for _sbo in self.slackbuilds: for _sbo in self.slackbuilds:
status(0.03)
if _sbo in self.data and _sbo not in self.blacklist: if _sbo in self.data and _sbo not in self.blacklist:
sbo_deps = Requires(self.flag).sbo(_sbo) sbo_deps = Requires(self.flag).sbo(_sbo)
self.deps += sbo_deps self.deps += sbo_deps
@ -233,7 +231,6 @@ class SBoInstall:
""" """
sbo_versions, sources = [], [] sbo_versions, sources = [], []
for sbo in slackbuilds: for sbo in slackbuilds:
status(0.02)
sbo_ver = f"{sbo}-{SBoGrep(sbo).version()}" sbo_ver = f"{sbo}-{SBoGrep(sbo).version()}"
sbo_versions.append(sbo_ver) sbo_versions.append(sbo_ver)
sources.append(SBoGrep(sbo).source()) sources.append(SBoGrep(sbo).source())

View file

@ -31,7 +31,6 @@ from slpkg.utils import Utils
from slpkg.sizes import units from slpkg.sizes import units
from slpkg.messages import Msg from slpkg.messages import Msg
from slpkg.url_read import URL from slpkg.url_read import URL
from slpkg.toolbar import status
from slpkg.checksum import check_md5 from slpkg.checksum import check_md5
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.downloader import Download from slpkg.downloader import Download
@ -136,9 +135,8 @@ class Patches:
Store and return packages for upgrading Store and return packages for upgrading
""" """
data = repo_data(self.PACKAGES_TXT, "slack", self.flag) data = repo_data(self.PACKAGES_TXT, "slack", self.flag)
black = BlackList().packages(pkgs=data[0], repo="slack") black = BlackList().get_black()
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]): for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
status(0.0003)
repo_pkg_name = split_package(name)[0] repo_pkg_name = split_package(name)[0]
if (not os.path.isfile(self.meta.pkg_path + name[:-4]) and if (not os.path.isfile(self.meta.pkg_path + name[:-4]) and
repo_pkg_name not in black and repo_pkg_name not in black and
@ -163,9 +161,8 @@ class Patches:
text = "Press 'spacebar' to unchoose packages from upgrade" text = "Press 'spacebar' to unchoose packages from upgrade"
title = " Upgrade " title = " Upgrade "
backtitle = f"{self.meta.__all__} {self.meta.__version__}" backtitle = f"{self.meta.__all__} {self.meta.__version__}"
status = True
pkgs = DialogUtil(data, text, title, backtitle, pkgs = DialogUtil(data, text, title, backtitle,
status).checklist() status=True).checklist()
index = 0 index = 0
for pkg, comp, uncomp in zip(self.upgrade_all, self.comp_sum, for pkg, comp, uncomp in zip(self.upgrade_all, self.comp_sum,
self.uncomp_sum): self.uncomp_sum):
@ -187,10 +184,10 @@ class Patches:
""" """
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)): for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
pkg_repo = split_package(upg[:-4]) pkg_repo = split_package(upg[:-4])
color = self.meta.color["RED"] color = self.red
pkg_inst = GetFromInstalled(pkg_repo[0]).name() pkg_inst = GetFromInstalled(pkg_repo[0]).name()
if pkg_repo[0] == pkg_inst: if pkg_repo[0] == pkg_inst:
color = self.meta.color["YELLOW"] color = self.yellow
ver = GetFromInstalled(pkg_repo[0]).version() ver = GetFromInstalled(pkg_repo[0]).version()
print(f" {color}{pkg_repo[0] + ver}{self.endc}" print(f" {color}{pkg_repo[0] + ver}{self.endc}"
f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}" f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}"

View file

@ -32,7 +32,6 @@ def slack_ver():
""" """
Open file and read Slackware version Open file and read Slackware version
""" """
if _meta_.slackware_version in ["off", "OFF"]: if _meta_.slackware_version in ["off", "OFF"]:
sv = Utils().read_file("/etc/slackware-version") sv = Utils().read_file("/etc/slackware-version")
version = re.findall(r"\d+", sv) version = re.findall(r"\d+", sv)

View file

@ -33,7 +33,7 @@ def slackware_repository():
""" """
slack_repo, packages, names, name = [], [], [], "" slack_repo, packages, names, name = [], [], [], ""
slack_repo = repo_data( slack_repo = repo_data(
Utils().read_file(_meta_.lib_path + "slack_repo/PACKAGES.TXT"), Utils().read_file(f"{_meta_.lib_path}slack_repo/PACKAGES.TXT"),
"slack", "") "slack", "")
for pkg in slack_repo[0]: for pkg in slack_repo[0]:
name = split_package(pkg)[0] name = split_package(pkg)[0]

View file

@ -23,7 +23,6 @@
import os import os
import sys
from slpkg.utils import Utils from slpkg.utils import Utils
from slpkg.messages import Msg from slpkg.messages import Msg

View file

@ -1,39 +0,0 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# toolbar.py file is part of slpkg.
# Copyright 2014-2020 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/>.
import sys
import time
from slpkg.__metadata__ import MetaData as _meta_
def status(sec):
"""Toolbar progressive status
"""
if _meta_.prg_bar in ["on", "ON"]:
syms = ["|", "/", "-", "\\"]
for sym in syms:
print(f"\b{_meta_.color['GREY']}{sym}{_meta_.color['ENDC']}", end="")
print(end="", flush=True)
time.sleep(float(sec))

View file

@ -129,7 +129,7 @@ class TrackingDeps:
self.bin_case_insensitive() self.bin_case_insensitive()
self.find_pkg = search_pkg(self.name, self.repo) self.find_pkg = search_pkg(self.name, self.repo)
if self.find_pkg: if self.find_pkg:
self.black = BlackList().packages(self.names, self.repo) self.black = BlackList().get_black()
self.dependencies_list = Dependencies( self.dependencies_list = Dependencies(
self.repo, self.black).binary(self.name, self.flag) self.repo, self.black).binary(self.name, self.flag)

10
tests/test_file_size.py Normal file
View file

@ -0,0 +1,10 @@
from slpkg.file_size import FileSize
def test_FileSize():
url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt"
lc = "tests/test_units.py"
fs1 = FileSize(url)
fs2 = FileSize(lc)
assert fs1.server() is not None
assert fs2.local() is not None