Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2022-10-29 20:01:36 +03:00
commit 452e809fd3
11 changed files with 71 additions and 22 deletions

View file

@ -1,3 +1,11 @@
4.2.3 - 28/10/2022
Updated:
- Creating all necessary paths from the config file
- Logs cleaning view dependencies
Added:
- Check if database file exists
- Check if the package exists in the database before upgrade
4.2.2 - 20/10/2022 4.2.2 - 20/10/2022
Updated: Updated:
- Removed version for skip installed option - Removed version for skip installed option

View file

@ -30,8 +30,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
.. code-block:: bash .. code-block:: bash
$ tar xvf slpkg-4.2.2.tar.gz $ tar xvf slpkg-4.2.3.tar.gz
$ cd slpkg-4.2.2 $ cd slpkg-4.2.3
$ ./install.sh $ ./install.sh
@ -96,6 +96,6 @@ If you feel satisfied with this project and want to thanks me make a donation.
Copyright Copyright
--------- ---------
- Copyright 2014-2022 © Dimitris Zlatanidis. - Copyright 2014.2.32 © Dimitris Zlatanidis.
- Slackware® is a Registered Trademark of Patrick Volkerding. - Slackware® is a Registered Trademark of Patrick Volkerding.
- Linux is a Registered Trademark of Linus Torvalds. - Linux is a Registered Trademark of Linus Torvalds.

View file

@ -39,8 +39,8 @@ configs:
# Slackware command fro remove packages. # Slackware command fro remove packages.
removepkg: removepkg removepkg: removepkg
# Cli menu colors configs. Default is on. [on/off] # Cli menu colors configs. Default is off. [on/off]
colors: on colors: off
# Wget downloader options. # Wget downloader options.
# -c, --continue: resume getting a partially-downloaded file. # -c, --continue: resume getting a partially-downloaded file.

View file

@ -1,6 +1,6 @@
[metadata] [metadata]
name = slpkg name = slpkg
version = 4.2.2 version = 4.2.3
license_file = LICENSE license_file = LICENSE
author = Dimitris Zlatanidis author = Dimitris Zlatanidis
author_email = d.zlatanidis@gmail.com author_email = d.zlatanidis@gmail.com

View file

@ -97,7 +97,7 @@ find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | gr
| 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 and creating lib directory # Install configuration files and creating lib directory
mkdir -p $PKG/etc/$PRGNAM $PKG/var/lib/$PRGNAM/database $PKG/var/lib/$PRGNAM/repository mkdir -p $PKG/etc/$PRGNAM
install -D -m0644 configs/slpkg.yml $PKG/etc/slpkg/slpkg.yml.new install -D -m0644 configs/slpkg.yml $PKG/etc/slpkg/slpkg.yml.new
install -D -m0645 configs/blacklist.yml $PKG/etc/slpkg/blacklist.yml.new install -D -m0645 configs/blacklist.yml $PKG/etc/slpkg/blacklist.yml.new

View file

@ -14,10 +14,11 @@ class Check:
''' Some checks before proceed. ''' ''' Some checks before proceed. '''
log_packages: str = Configs.log_packages log_packages: str = Configs.log_packages
sbo_repo_tag: str = Configs.sbo_repo_tag sbo_repo_tag: str = Configs.sbo_repo_tag
db_path: str = Configs.db_path
database_name: str = Configs.database
def exists(self, slackbuilds: list): def exists(self, slackbuilds: list):
''' Checking if the slackbuild exists in the repository. ''' ''' Checking if the slackbuild exists in the repository. '''
self.database()
packages = [] packages = []
for sbo in slackbuilds: for sbo in slackbuilds:
@ -59,6 +60,7 @@ class Check:
def database(self): def database(self):
''' Checking for empty table ''' ''' Checking for empty table '''
if not SBoQueries('').names(): db = f'{self.db_path}/{self.database_name}'
if not SBoQueries('').names() or not os.path.isfile(db):
raise SystemExit('\nYou need to update the package lists first.\n' raise SystemExit('\nYou need to update the package lists first.\n'
'Please run slpkg update.\n') 'Please run slpkg update.\n')

View file

@ -44,15 +44,11 @@ class Configs:
removepkg: str = 'removepkg' removepkg: str = 'removepkg'
# Cli menu colors configs # Cli menu colors configs
colors: str = 'on' colors: str = 'off'
# Wget options # Wget options
wget_options = '-c -N' wget_options = '-c -N'
# Creating the build path
if not os.path.isdir(build_path):
os.makedirs(build_path)
''' Overwrite with user configuration. ''' ''' Overwrite with user configuration. '''
config_file: str = f'{etc_path}/{prog_name}.yml' config_file: str = f'{etc_path}/{prog_name}.yml'
if os.path.isfile(config_file): if os.path.isfile(config_file):
@ -95,6 +91,19 @@ class Configs:
except KeyError: except KeyError:
pass pass
# Creating the paths if they doesn't exists
paths = [tmp_slpkg,
build_path,
download_only,
sbo_repo_path,
lib_path,
etc_path,
db_path]
for path in paths:
if not os.path.isdir(path):
os.makedirs(path)
@classmethod @classmethod
def colour(cls): def colour(cls):
color = { color = {

View file

@ -67,6 +67,8 @@ class Argparse:
def upgrade(self): def upgrade(self):
if len(self.args) == 1: if len(self.args) == 1:
self.check.database()
upgrade = Upgrade() upgrade = Upgrade()
packages = list(upgrade.packages()) packages = list(upgrade.packages())
@ -83,6 +85,7 @@ class Argparse:
if len(self.args) >= 2 and '--reinstall' not in self.flags: if len(self.args) >= 2 and '--reinstall' not in self.flags:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
self.check.database()
self.check.exists(packages) self.check.exists(packages)
self.check.unsupported(packages) self.check.unsupported(packages)
@ -95,6 +98,7 @@ class Argparse:
if len(self.args) >= 2: if len(self.args) >= 2:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
self.check.database()
self.check.exists(packages) self.check.exists(packages)
self.check.unsupported(packages) self.check.unsupported(packages)
@ -110,6 +114,7 @@ class Argparse:
if len(self.args) >= 2: if len(self.args) >= 2:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
self.check.database()
self.check.exists(packages) self.check.exists(packages)
download = Download(self.flags) download = Download(self.flags)
download.packages(packages) download.packages(packages)
@ -123,6 +128,9 @@ class Argparse:
if len(self.args) >= 2: if len(self.args) >= 2:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
self.check.database()
packages = self.check.blacklist(packages) packages = self.check.blacklist(packages)
self.check.installed(packages) self.check.installed(packages)
@ -135,6 +143,9 @@ class Argparse:
def view(self): def view(self):
if len(self.args) >= 2 and not self.flags: if len(self.args) >= 2 and not self.flags:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
self.check.database()
packages = self.check.blacklist(packages) packages = self.check.blacklist(packages)
self.check.exists(packages) self.check.exists(packages)
@ -147,6 +158,9 @@ class Argparse:
def search(self): def search(self):
if len(self.args) >= 2 and not self.flags: if len(self.args) >= 2 and not self.flags:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
self.check.database()
packages = self.check.blacklist(packages) packages = self.check.blacklist(packages)
search = SearchPackage() search = SearchPackage()
@ -157,6 +171,9 @@ class Argparse:
def find(self): def find(self):
if len(self.args) >= 2 and not self.flags: if len(self.args) >= 2 and not self.flags:
packages = list(set(self.args[1:])) packages = list(set(self.args[1:]))
self.check.database()
packages = self.check.blacklist(packages) packages = self.check.blacklist(packages)
find = FindInstalled() find = FindInstalled()
@ -169,6 +186,8 @@ class Argparse:
usage(1) usage(1)
if len(self.args) == 1: if len(self.args) == 1:
self.check.database()
logs = CleanLogsDependencies(self.flags) logs = CleanLogsDependencies(self.flags)
logs.clean() logs.clean()
raise SystemExit() raise SystemExit()

View file

@ -16,11 +16,18 @@ class Upgrade:
def packages(self): def packages(self):
''' Compares version of packages and returns the maximum. ''' ''' Compares version of packages and returns the maximum. '''
print("Do not forget to run 'slpkg update' before.")
repo_packages = SBoQueries('').names()
for pkg in os.listdir(self.log_packages): for pkg in os.listdir(self.log_packages):
if pkg.endswith(self.sbo_repo_tag): if pkg.endswith(self.sbo_repo_tag):
name = '-'.join(pkg.split('-')[:-3]) inst_pkg_name = '-'.join(pkg.split('-')[:-3])
installed_ver = pkg.replace(name + '-', '').split('-')[0]
repo_ver = SBoQueries(name).version()
if LooseVersion(repo_ver) > LooseVersion(installed_ver): if inst_pkg_name in repo_packages:
yield name installed_ver = pkg.replace(
inst_pkg_name + '-', '').split('-')[0]
repo_ver = SBoQueries(inst_pkg_name).version()
if LooseVersion(repo_ver) > LooseVersion(installed_ver):
yield inst_pkg_name

View file

@ -10,7 +10,7 @@ from slpkg.configs import Configs
@dataclass @dataclass
class Version: class Version:
prog_name: str = Configs.prog_name prog_name: str = Configs.prog_name
version_info: tuple = (4, 2, 2) version_info: tuple = (4, 2, 3)
version: str = '{0}.{1}.{2}'.format(*version_info) version: str = '{0}.{1}.{2}'.format(*version_info)
license: str = 'MIT License' license: str = 'MIT License'
author: str = 'dslackw' author: str = 'dslackw'

View file

@ -116,6 +116,10 @@ class ViewMessage:
self.arch = 'noarch' self.arch = 'noarch'
if installed: if installed:
if '--reinstall' not in self.flags:
install = 'installed'
print(f'[{set_color} {install} {color["ENDC"]}] -> ' print(f'[{set_color} {install} {color["ENDC"]}] -> '
f'{sbo}-{version} {set_color}' f'{sbo}-{version} {set_color}'
f'({installed.split(self.arch)[0][:-1].split("-")[-1]})' f'({installed.split(self.arch)[0][:-1].split("-")[-1]})'
@ -166,8 +170,8 @@ class ViewMessage:
for dep in dependencies: for dep in dependencies:
print(f'{color["CYAN"]}{dep[0]}{color["ENDC"]}') print(f'{color["CYAN"]}{dep[0]}{color["ENDC"]}')
print('Dependencies:') print(' |')
print(f'{color["CYAN"]} {dep[1]}{color["ENDC"]}\n') print(f' +->{color["CYAN"]} {dep[1]}{color["ENDC"]}\n')
print('Note: After cleaning you should remove them one by one.') print('Note: After cleaning you should remove them one by one.')
def question(self): def question(self):