Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2022-10-14 20:54:24 +03:00
commit 31f6b4ef44
12 changed files with 95 additions and 44 deletions

View file

@ -1,8 +1,12 @@
4.1.9 - 14/10/2022
Added:
- New option --download-only
4.1.8 - 06/10/2022 4.1.8 - 06/10/2022
Updated: Updated:
- Manpage for .yaml files - Manpage for .yaml files
Added: Added:
- New flag --skip-installed - New option --skip-installed
4.1.7 - 28/9/2022 4.1.7 - 28/9/2022
Bugfixed: Bugfixed:

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.1.8.tar.gz $ tar xvf slpkg-4.1.9.tar.gz
$ cd slpkg-4.1.8 $ cd slpkg-4.1.9
$ ./install.sh $ ./install.sh

View file

@ -3,6 +3,7 @@ configs:
tmp_path: /tmp tmp_path: /tmp
tmp_slpkg: /tmp/slpkg tmp_slpkg: /tmp/slpkg
build_path: /tmp/slpkg/build build_path: /tmp/slpkg/build
download_only: /tmp/slpkg
lib_path: /var/lib/slpkg lib_path: /var/lib/slpkg
etc_path: /etc/slpkg etc_path: /etc/slpkg
db_path: /var/lib/slpkg/database db_path: /var/lib/slpkg/database

View file

@ -1,10 +1,10 @@
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.1.0" dslackw .TH slpkg 1 "Orestiada, Greece" "slpkg 4.1.9" dslackw
.SH NAME .SH NAME
.P .P
slpkg - [OPTIONS] [COMMAND] <packages> slpkg - [OPTIONS] [COMMAND] <packages>
.SH SYNAPSES .SH SYNAPSES
.P .P
slpkg [-h|-v] [update] [upgrade] [build] [install] [remove] [find] [search] [clean-logs] [clean-tmp] --yes --resolve-off --reinstall --skip-installed slpkg [-h|-v] [update] [upgrade] [build] [install] [remove] [find] [search] [clean-logs] [clean-tmp] --yes --jobs --resolve-off --reinstall --skip-installed --download-only
.SH DESCRIPTION .SH DESCRIPTION
.P .P
Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update. Slpkg is a software package manager that installs, updates, and removes packages on Slackware based systems. It automatically computes dependencies and figures out what things should occur to install packages. Slpkg makes it easier to maintain groups of machines without having to manually update.
@ -85,6 +85,11 @@ This a helpful option if you want to avoid building and reinstalling packages.
Note: This option affects only the dependencies. Note: This option affects only the dependencies.
.RE .RE
.P .P
--download-only
.RS
Download only the package without building or installing it. Works both with build or install command.
.RE
.P
-h | --help -h | --help
.RS .RS
Show help informatio and exit. Show help informatio and exit.

View file

@ -1,6 +1,6 @@
[metadata] [metadata]
name = slpkg name = slpkg
version = 4.1.8 version = 4.1.9
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

@ -5,7 +5,6 @@
import hashlib import hashlib
from dataclasses import dataclass from dataclasses import dataclass
from slpkg.configs import Configs
from slpkg.views.views import ViewMessage from slpkg.views.views import ViewMessage
@ -13,10 +12,8 @@ from slpkg.views.views import ViewMessage
class Md5sum: class Md5sum:
''' Checksum the sources. ''' ''' Checksum the sources. '''
flags: str flags: str
build_path: str = Configs.build_path
def check(self, source: str, checksum: str, name: str): def check(self, path: str, source: str, checksum: str, name: str):
path = f'{self.build_path}/{name}'
filename = f'{path}/{source.split("/")[-1]}' filename = f'{path}/{source.split("/")[-1]}'
md5 = self.read_file(filename) md5 = self.read_file(filename)

View file

@ -22,6 +22,7 @@ class Configs:
tmp_path: str = '/tmp' tmp_path: str = '/tmp'
tmp_slpkg: str = f'{tmp_path}/{prog_name}' tmp_slpkg: str = f'{tmp_path}/{prog_name}'
build_path: str = f'/tmp/{prog_name}/build' build_path: str = f'/tmp/{prog_name}/build'
download_only: str = f'{tmp_slpkg}/'
lib_path: str = f'/var/lib/{prog_name}' lib_path: str = f'/var/lib/{prog_name}'
etc_path: str = f'/etc/{prog_name}' etc_path: str = f'/etc/{prog_name}'
db_path: str = f'/var/lib/{prog_name}/database' db_path: str = f'/var/lib/{prog_name}/database'
@ -58,40 +59,44 @@ class Configs:
with open(config_file, 'r') as conf: with open(config_file, 'r') as conf:
configs = yaml.safe_load(conf) configs = yaml.safe_load(conf)
config = configs['configs'] try:
config = configs['configs']
# OS architecture by default # OS architecture by default
os_arch: str = config['os_arch'] os_arch: str = config['os_arch']
# All necessary paths # All necessary paths
tmp_path: str = config['tmp_path'] tmp_path: str = config['tmp_path']
tmp_slpkg: str = config['tmp_slpkg'] tmp_slpkg: str = config['tmp_slpkg']
build_path: str = config['build_path'] build_path: str = config['build_path']
lib_path: str = config['lib_path'] download_only: str = config['download_only']
etc_path: str = config['etc_path'] lib_path: str = config['lib_path']
db_path: str = config['db_path'] etc_path: str = config['etc_path']
sbo_repo_path: str = config['sbo_repo_path'] db_path: str = config['db_path']
log_packages: str = config['log_packages'] sbo_repo_path: str = config['sbo_repo_path']
log_packages: str = config['log_packages']
# Database name # Database name
database: str = config['database'] database: str = config['database']
# Repository details # Repository details
repo_version: str = config['repo_version'] repo_version: str = config['repo_version']
sbo_url: str = config['sbo_url'] sbo_url: str = config['sbo_url']
sbo_txt: str = config['sbo_txt'] sbo_txt: str = config['sbo_txt']
tar_suffix: str = config['tar_suffix'] tar_suffix: str = config['tar_suffix']
pkg_suffix: str = config['pkg_suffix'] pkg_suffix: str = config['pkg_suffix']
repo_tag: str = config['repo_tag'] repo_tag: str = config['repo_tag']
# Slackware commands # Slackware commands
installpkg: str = config['installpkg'] installpkg: str = config['installpkg']
reinstall: str = config['reinstall'] reinstall: str = config['reinstall']
removepkg: str = config['removepkg'] removepkg: str = config['removepkg']
# Other configs # Other configs
colors: str = config['colors'] colors: str = config['colors']
wget_options: str = config['wget_options'] wget_options: str = config['wget_options']
except KeyError:
pass
@classmethod @classmethod
def colour(cls): def colour(cls):

View file

@ -37,7 +37,8 @@ class Argparse:
'--jobs', '--jobs',
'--resolve-off', '--resolve-off',
'--reinstall', '--reinstall',
'--skip-installed' '--skip-installed',
'--download-only'
] ]
for option in self.options: for option in self.options:

View file

@ -30,6 +30,7 @@ class Slackbuilds:
build_path: str = Configs.build_path build_path: str = Configs.build_path
sbo_url: str = Configs.sbo_url sbo_url: str = Configs.sbo_url
build_path: str = Configs.build_path build_path: str = Configs.build_path
download_only: str = Configs.download_only
tmp_slpkg: str = Configs.tmp_slpkg tmp_slpkg: str = Configs.tmp_slpkg
tmp_path: str = Configs.tmp_path tmp_path: str = Configs.tmp_path
tar_suffix: str = Configs.tar_suffix tar_suffix: str = Configs.tar_suffix
@ -56,7 +57,9 @@ class Slackbuilds:
''' View slackbuilds before proceed. ''' ''' View slackbuilds before proceed. '''
view = ViewMessage(self.flags) view = ViewMessage(self.flags)
if self.install: if '--download-only' in self.flags:
view.download_packages(self.slackbuilds, self.dependencies)
elif self.install:
view.install_packages(self.slackbuilds, self.dependencies) view.install_packages(self.slackbuilds, self.dependencies)
else: else:
view.build_packages(self.slackbuilds, self.dependencies) view.build_packages(self.slackbuilds, self.dependencies)
@ -108,11 +111,16 @@ class Slackbuilds:
wget.download(self.tmp_slpkg, url) wget.download(self.tmp_slpkg, url)
self.utils.untar_archive(self.tmp_slpkg, file, self.build_path) if '--download-only' not in self.flags:
self.utils.untar_archive(self.tmp_slpkg, file, self.build_path)
sources = SBoQueries(sbo).sources() sources = SBoQueries(sbo).sources()
self.download_sources(sbo, sources) self.download_sources(sbo, sources)
# Skip building or installing the package
if '--download-only' in self.flags:
continue
self.build_the_script(self.build_path, sbo) self.build_the_script(self.build_path, sbo)
if self.install: if self.install:
@ -148,6 +156,7 @@ class Slackbuilds:
if ('--reinstall' in self.flags and if ('--reinstall' in self.flags and
self.utils.is_installed(package[:-4])): self.utils.is_installed(package[:-4])):
execute = self.reinstall execute = self.reinstall
command = f'{execute} {self.tmp_path}/{package}' command = f'{execute} {self.tmp_path}/{package}'
subprocess.call(command, shell=True) subprocess.call(command, shell=True)
@ -176,6 +185,7 @@ class Slackbuilds:
self.set_makeflags() self.set_makeflags()
stdout = subprocess.call(execute) stdout = subprocess.call(execute)
if stdout > 0: if stdout > 0:
raise SystemExit(stdout) raise SystemExit(stdout)
@ -187,10 +197,14 @@ class Slackbuilds:
def download_sources(self, name: str, sources: str): def download_sources(self, name: str, sources: str):
''' Download the sources. ''' ''' Download the sources. '''
wget = Wget() wget = Wget()
path = f'{self.build_path}/{name}' path = f'{self.build_path}/{name}'
if '--download-only' in self.flags:
path = self.download_only
checksums = SBoQueries(name).checksum() checksums = SBoQueries(name).checksum()
for source, checksum in zip(sources.split(), checksums[0].split()): for source, checksum in zip(sources.split(), checksums[0].split()):
wget.download(path, source) wget.download(path, source)
md5sum = Md5sum(self.flags) md5sum = Md5sum(self.flags)
md5sum.check(source, checksum, name) md5sum.check(path, source, checksum, 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, 1, 8) version_info: tuple = (4, 1, 9)
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

@ -33,7 +33,8 @@ def usage(status: int):
f' {YELLOW}--jobs{ENDC} Set it for multicore systems.', f' {YELLOW}--jobs{ENDC} Set it for multicore systems.',
f' {YELLOW}--resolve-off{ENDC} Turns off dependency resolving.', f' {YELLOW}--resolve-off{ENDC} Turns off dependency resolving.',
f' {YELLOW}--reinstall{ENDC} Use this option if you want to upgrade.', f' {YELLOW}--reinstall{ENDC} Use this option if you want to upgrade.',
f' {YELLOW}--skip-installed{ENDC} Skip installed packages.\n', f' {YELLOW}--skip-installed{ENDC} Skip installed packages.',
f' {YELLOW}--download-only{ENDC} Download only the packages.\n',
' -h, --help Show this message and exit.', ' -h, --help Show this message and exit.',
' -v, --version Print version and exit.\n', ' -v, --version Print version and exit.\n',
'If you need more information try to use slpkg manpage.'] 'If you need more information try to use slpkg manpage.']

View file

@ -53,6 +53,19 @@ class ViewMessage:
self._view_total(slackbuilds, dependencies, option='install') self._view_total(slackbuilds, dependencies, option='install')
def download_packages(self, slackbuilds: list, dependencies: list):
print('The following packages will be downloaded:\n')
for sbo in slackbuilds:
version = SBoQueries(sbo).version()
self._view_download(sbo, version)
if dependencies:
print('\nDependencies:')
for sbo in dependencies:
version = SBoQueries(sbo).version()
self._view_download(sbo, version)
def remove_packages(self, packages: list): def remove_packages(self, packages: list):
print('The following packages will be removed:\n') print('The following packages will be removed:\n')
self.installed_packages = [] self.installed_packages = []
@ -76,6 +89,16 @@ class ViewMessage:
return self.installed_packages, self.dependencies return self.installed_packages, self.dependencies
def _view_download(self, sbo: str, version: str):
color = self.colors()
if self.utils.is_installed(f'{sbo}-'):
print(f'[{color["YELLOW"]} download {color["ENDC"]}] -> '
f'{sbo}-{version}')
else:
print(f'[{color["CYAN"]} download {color["ENDC"]}] -> '
f'{sbo}-{version}')
def _view_build(self, sbo: str, version: str): def _view_build(self, sbo: str, version: str):
color = self.colors() color = self.colors()