Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2022-10-20 12:57:16 +03:00
commit 32ab26b7ed
18 changed files with 90 additions and 74 deletions

View file

@ -1,3 +1,9 @@
4.2.1 - 18/10/2022
Added:
- Print the README file in the search option
Updated:
- Configs for sbo repository
4.2.0 - 14/10/2022
Updated:
- Moved option --download-only to commands

View file

@ -30,8 +30,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
.. code-block:: bash
$ tar xvf slpkg-4.2.0.tar.gz
$ cd slpkg-4.2.0
$ tar xvf slpkg-4.2.1.tar.gz
$ cd slpkg-4.2.1
$ ./install.sh

View file

@ -1,2 +1,4 @@
blacklist:
packages: []
# Add packages and separate them with commas.
packages: []

View file

@ -1,5 +1,8 @@
configs:
# OS architecture by default.
os_arch: x86_64
# All necessary paths.
tmp_path: /tmp
tmp_slpkg: /tmp/slpkg
build_path: /tmp/slpkg/build
@ -9,15 +12,23 @@ configs:
db_path: /var/lib/slpkg/database
sbo_repo_path: /var/lib/slpkg/repository
log_packages: /var/log/packages
# Database name.
database: database.slpkg
repo_version: 15.0
sbo_url: http://slackbuilds.org/slackbuilds/15.0
# SBo repository configs.
sbo_repo_url: http://slackbuilds.org/slackbuilds/15.0
sbo_txt: SLACKBUILDS.TXT
tar_suffix: .tar.gz
pkg_suffix: .tgz
repo_tag: _SBo
sbo_tar_suffix: .tar.gz
sbo_repo_tag: _SBo
# Slackware commands.
installpkg: upgradepkg --install-new
reinstall: upgradepkg --reinstall
removepkg: removepkg
# Cli menu colors configs.
colors: on
# Wget options.
wget_options: -c -N

View file

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

View file

@ -13,7 +13,7 @@ from slpkg.blacklist import Blacklist
class Check:
''' Some checks before proceed. '''
log_packages: str = Configs.log_packages
repo_tag: str = Configs.repo_tag
sbo_repo_tag: str = Configs.sbo_repo_tag
def exists(self, slackbuilds: list):
''' Checking if the slackbuild exists in the repository. '''
@ -42,7 +42,7 @@ class Check:
for package in os.listdir(self.log_packages):
for sbo in slackbuilds:
if sbo + '-' in package and self.repo_tag in package:
if sbo + '-' in package and self.sbo_repo_tag in package:
return
raise SystemExit('\nNot found installed packages.\n')

View file

@ -32,21 +32,21 @@ class Configs:
# Database name
database: str = f'database.{prog_name}'
# Repository details
repo_version: str = '15.0'
sbo_url: str = f'http://slackbuilds.org/slackbuilds/{repo_version}'
# SBo repository configs
sbo_repo_url: str = 'http://slackbuilds.org/slackbuilds/15.0'
sbo_txt: str = 'SLACKBUILDS.TXT'
tar_suffix: str = '.tar.gz'
pkg_suffix: str = '.tgz'
repo_tag: str = '_SBo'
sbo_tar_suffix: str = '.tar.gz'
sbo_repo_tag: str = '_SBo'
# Slackware commands
installpkg: str = 'upgradepkg --install-new'
reinstall: str = 'upgradepkg --reinstall'
removepkg: str = 'removepkg'
# Other configs
# Cli menu colors configs
colors: str = 'on'
# Wget options
wget_options = '-c -N'
# Creating the build path
@ -60,6 +60,7 @@ class Configs:
configs = yaml.safe_load(conf)
try:
config = configs['configs']
# OS architecture by default
@ -79,22 +80,23 @@ class Configs:
# Database name
database: str = config['database']
# Repository details
repo_version: str = config['repo_version']
sbo_url: str = config['sbo_url']
# SBo repository details
sbo_repo_url: str = config['sbo_repo_url']
sbo_txt: str = config['sbo_txt']
tar_suffix: str = config['tar_suffix']
pkg_suffix: str = config['pkg_suffix']
repo_tag: str = config['repo_tag']
sbo_tar_suffix: str = config['sbo_tar_suffix']
sbo_repo_tag: str = config['sbo_repo_tag']
# Slackware commands
installpkg: str = config['installpkg']
reinstall: str = config['reinstall']
removepkg: str = config['removepkg']
# Other configs
# Cli menu colors configs
colors: str = config['colors']
# Wget options
wget_options: str = config['wget_options']
except KeyError:
pass

View file

@ -20,19 +20,19 @@ class CreateData:
def insert_sbo_table(self):
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:"
'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.read_file(f"{self.sbo_repo_path}/SLACKBUILDS.TXT")
sbo_file = self.read_file(f'{self.sbo_repo_path}/SLACKBUILDS.TXT')
cache = [] # init cache
@ -42,7 +42,7 @@ class CreateData:
for tag in sbo_tags:
if line.startswith(tag):
line = line.replace(tag, "").strip()
line = line.replace(tag, '').strip()
cache.append(line)
if (i % 11) == 0:
@ -60,5 +60,5 @@ class CreateData:
self.session.commit()
def read_file(self, file: str):
with open(file, "r", encoding="utf-8") as f:
with open(file, 'r', encoding='utf-8') as f:
return f.readlines()

View file

@ -17,7 +17,7 @@ class Requires:
requires = SBoQueries(self.name).requires()
for req in requires:
if req and req != "%README%":
if req and req != '%README%':
sub = SBoQueries(req).requires()
for s in sub:
requires.append(s)

View file

@ -16,8 +16,8 @@ class Download:
flags: list
session: str = Session
download_only = Configs.download_only
sbo_url: str = Configs.sbo_url
tar_suffix: str = Configs.tar_suffix
sbo_repo_url: str = Configs.sbo_repo_url
sbo_tar_suffix: str = Configs.sbo_tar_suffix
def packages(self, slackbuilds: list):
@ -27,9 +27,9 @@ class Download:
wget = Wget()
for sbo in slackbuilds:
file = f'{sbo}{self.tar_suffix}'
file = f'{sbo}{self.sbo_tar_suffix}'
location = SBoQueries(sbo).location()
url = f'{self.sbo_url}/{location}/{file}'
url = f'{self.sbo_repo_url}/{location}/{file}'
wget.download(self.download_only, url)

View file

@ -11,13 +11,13 @@ from slpkg.configs import Configs
class FindInstalled:
log_packages: str = Configs.log_packages
colors: dict = Configs.colour
repo_tag: str = Configs.repo_tag
sbo_repo_tag: str = Configs.sbo_repo_tag
def find(self, packages: list):
matching = []
for pkg in packages:
for package in os.listdir(self.log_packages):
if pkg in package and self.repo_tag in package:
if pkg in package and self.sbo_repo_tag in package:
matching.append(package)
self.matched(matching)

View file

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import urllib3
from dataclasses import dataclass
from slpkg.configs import Configs
@ -13,9 +14,10 @@ from slpkg.models.models import session as Session
class Search:
session: str = Session
colors: dict = Configs.colour
sbo_url: str = Configs.sbo_url
sbo_repo_url: str = Configs.sbo_repo_url
def package(self, packages):
http = urllib3.PoolManager()
color = self.colors()
GREEN = color['GREEN']
BLUE = color['BLUE']
@ -36,6 +38,9 @@ class Search:
SBoTable.location
).filter(SBoTable.name == package).first()
readme = http.request(
'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README')
print(f'Name: {GREEN}{info[0]}{ENDC}\n'
f'Version: {GREEN}{info[1]}{ENDC}\n'
f'Requires: {GREEN}{info[2]}{ENDC}\n'
@ -45,5 +50,5 @@ class Search:
f'Md5sum_x86_64: {YELLOW}{info[6]}{ENDC}\n'
f'Files: {GREEN}{info[7]}{ENDC}\n'
f'Description: {GREEN}{info[8]}{ENDC}\n'
f'SBo url: {BLUE}{self.sbo_url}/{info[9]}/'
f'{info[0]}{ENDC}\n')
f'SBo url: {BLUE}{self.sbo_repo_url}/{info[9]}/{info[0]}{ENDC}\n'
f'README: {readme.data.decode()}')

View file

@ -28,13 +28,11 @@ class Slackbuilds:
session: str = Session
utils: str = Utilities()
build_path: str = Configs.build_path
sbo_url: str = Configs.sbo_url
sbo_repo_url: str = Configs.sbo_repo_url
build_path: str = Configs.build_path
tmp_slpkg: str = Configs.tmp_slpkg
tmp_path: str = Configs.tmp_path
tar_suffix: str = Configs.tar_suffix
repo_tag: str = Configs.repo_tag
pkg_suffix: str = Configs.pkg_suffix
sbo_tar_suffix: str = Configs.sbo_tar_suffix
installpkg: str = Configs.installpkg
reinstall: str = Configs.reinstall
@ -98,13 +96,13 @@ class Slackbuilds:
wget = Wget()
for sbo in self.install_order:
file = f'{sbo}{self.tar_suffix}'
file = f'{sbo}{self.sbo_tar_suffix}'
self.utils.remove_file_if_exists(self.tmp_slpkg, file)
self.utils.remove_folder_if_exists(self.build_path, sbo)
location = SBoQueries(sbo).location()
url = f'{self.sbo_url}/{location}/{file}'
url = f'{self.sbo_repo_url}/{location}/{file}'
wget.download(self.tmp_slpkg, url)

View file

@ -18,7 +18,7 @@ from slpkg.models.models import session as Session
class UpdateRepository:
''' Deletes and install the data. '''
sbo_repo_path: str = Configs.sbo_repo_path
url: str = Configs.sbo_url
url: str = Configs.sbo_repo_url
sbo_txt: str = Configs.sbo_txt
db_path: str = Configs.db_path
database: str = Configs.database
@ -29,10 +29,10 @@ class UpdateRepository:
self.delete_file(self.sbo_repo_path, self.sbo_txt)
self.delete_sbo_data()
sbo_url = f'{self.url}/{self.sbo_txt}'
sbo_repo_url = f'{self.url}/{self.sbo_txt}'
wget = Wget()
wget.download(self.sbo_repo_path, sbo_url)
wget.download(self.sbo_repo_path, sbo_repo_url)
data = CreateData()
data.insert_sbo_table()

View file

@ -12,12 +12,12 @@ from slpkg.queries import SBoQueries
@dataclass
class Upgrade:
log_packages: str = Configs.log_packages
repo_tag: str = Configs.repo_tag
sbo_repo_tag: str = Configs.sbo_repo_tag
def packages(self):
''' Compares version of packages and returns the maximum. '''
for pkg in os.listdir(self.log_packages):
if pkg.endswith(self.repo_tag):
if pkg.endswith(self.sbo_repo_tag):
name = '-'.join(pkg.split('-')[:-3])
installed_ver = pkg.replace(name + '-', '').split('-')[0]
repo_ver = SBoQueries(name).version()

View file

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

View file

@ -17,7 +17,7 @@ class ViewMessage:
flags: list
colors: dict = Configs.colour
log_packages: str = Configs.log_packages
repo_tag: str = Configs.repo_tag
sbo_repo_tag: str = Configs.sbo_repo_tag
arch: str = Configs.os_arch
session: str = Session
utils: str = Utilities()
@ -131,7 +131,7 @@ class ViewMessage:
for package in installed:
black = package.split('-')[0]
if (package.startswith(name) and self.repo_tag in package and
if (package.startswith(name) and self.sbo_repo_tag in package and
black not in self.black.get()):
self.installed_packages.append(package)
print(f'[{color["RED"]} delete {color["ENDC"]}] -> {package}')

View file

@ -5,27 +5,19 @@ from slpkg.configs import Configs
class TestConfigs(unittest.TestCase):
def setUp(self):
self.repo_version = Configs.repo_version
self.sbo_txt = Configs.sbo_txt
self.tar_suffix = Configs.tar_suffix
self.pkg_suffix = Configs.pkg_suffix
self.repo_tag = Configs.repo_tag
self.sbo_tar_suffix = Configs.sbo_tar_suffix
self.sbo_repo_tag = Configs.sbo_repo_tag
self.os_arch = Configs.os_arch
def test_repo_version(self):
self.assertEqual(15.0, self.repo_version)
def test_sbo_txt(self):
self.assertEqual('SLACKBUILDS.TXT', self.sbo_txt)
def test_tar_suffix(self):
self.assertEqual('.tar.gz', self.tar_suffix)
def test_pkg_suffix(self):
self.assertEqual('.tgz', self.pkg_suffix)
self.assertEqual('.tar.gz', self.sbo_tar_suffix)
def test_repo_tag(self):
self.assertEqual('_SBo', self.repo_tag)
self.assertEqual('_SBo', self.sbo_repo_tag)
def test_os_arch(self):
self.assertEqual('x86_64', self.os_arch)