From 0c98c2aee098b091a8200f1146936c5298e679ac Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 12 Oct 2022 21:14:27 +0300 Subject: [PATCH 1/6] Updated man page Signed-off-by: Dimitris Zlatanidis --- man/slpkg.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index 229a6080..d9003aa2 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -4,7 +4,7 @@ slpkg - [OPTIONS] [COMMAND] .SH SYNAPSES .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 .SH DESCRIPTION .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. From 8ef906b3558252e99f0e977af3ee5a47237107eb Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 12 Oct 2022 21:15:35 +0300 Subject: [PATCH 2/6] Updated version Signed-off-by: Dimitris Zlatanidis --- man/slpkg.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/slpkg.1 b/man/slpkg.1 index d9003aa2..63aa61a7 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -1,4 +1,4 @@ -.TH slpkg 1 "Orestiada, Greece" "slpkg 4.1.0" dslackw +.TH slpkg 1 "Orestiada, Greece" "slpkg 4.1.8" dslackw .SH NAME .P slpkg - [OPTIONS] [COMMAND] From 14060643747dabfb6c7e83dbed671373e29e0edb Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 14 Oct 2022 20:22:33 +0300 Subject: [PATCH 3/6] Added option --download-only Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 6 +++++- configs/slpkg.yml | 1 + man/slpkg.1 | 7 ++++++- slpkg/checksum.py | 5 +---- slpkg/configs.py | 2 ++ slpkg/main.py | 3 ++- slpkg/slackbuild.py | 20 +++++++++++++++++--- slpkg/views/cli_menu.py | 3 ++- slpkg/views/views.py | 23 +++++++++++++++++++++++ 9 files changed, 59 insertions(+), 11 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 56acdfc0..e2ee40ac 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,12 @@ +4.1.9 - 14/10/2022 +Added: +- New option --download-only + 4.1.8 - 06/10/2022 Updated: - Manpage for .yaml files Added: -- New flag --skip-installed +- New option --skip-installed 4.1.7 - 28/9/2022 Bugfixed: diff --git a/configs/slpkg.yml b/configs/slpkg.yml index 7adcb108..de2c1d61 100644 --- a/configs/slpkg.yml +++ b/configs/slpkg.yml @@ -3,6 +3,7 @@ configs: tmp_path: /tmp tmp_slpkg: /tmp/slpkg build_path: /tmp/slpkg/build + download_only: /tmp/slpkg lib_path: /var/lib/slpkg etc_path: /etc/slpkg db_path: /var/lib/slpkg/database diff --git a/man/slpkg.1 b/man/slpkg.1 index 63aa61a7..d1b8385c 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -4,7 +4,7 @@ slpkg - [OPTIONS] [COMMAND] .SH SYNAPSES .P -slpkg [-h|-v] [update] [upgrade] [build] [install] [remove] [find] [search] [clean-logs] [clean-tmp] --yes --jobs --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 .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. @@ -85,6 +85,11 @@ This a helpful option if you want to avoid building and reinstalling packages. Note: This option affects only the dependencies. .RE .P +--download-only +.RS +Download only the package without building or installing it. Works both with build or install command. +.RE +.P -h | --help .RS Show help informatio and exit. diff --git a/slpkg/checksum.py b/slpkg/checksum.py index 72f5bf1f..834efc31 100644 --- a/slpkg/checksum.py +++ b/slpkg/checksum.py @@ -5,7 +5,6 @@ import hashlib from dataclasses import dataclass -from slpkg.configs import Configs from slpkg.views.views import ViewMessage @@ -13,10 +12,8 @@ from slpkg.views.views import ViewMessage class Md5sum: ''' Checksum the sources. ''' flags: str - build_path: str = Configs.build_path - def check(self, source: str, checksum: str, name: str): - path = f'{self.build_path}/{name}' + def check(self, path: str, source: str, checksum: str, name: str): filename = f'{path}/{source.split("/")[-1]}' md5 = self.read_file(filename) diff --git a/slpkg/configs.py b/slpkg/configs.py index f483c4ba..0ac21ae4 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -22,6 +22,7 @@ class Configs: tmp_path: str = '/tmp' tmp_slpkg: str = f'{tmp_path}/{prog_name}' build_path: str = f'/tmp/{prog_name}/build' + download_only: str = f'{tmp_slpkg}/' lib_path: str = f'/var/lib/{prog_name}' etc_path: str = f'/etc/{prog_name}' db_path: str = f'/var/lib/{prog_name}/database' @@ -67,6 +68,7 @@ class Configs: tmp_path: str = config['tmp_path'] tmp_slpkg: str = config['tmp_slpkg'] build_path: str = config['build_path'] + download_only: str = config['download_only'] lib_path: str = config['lib_path'] etc_path: str = config['etc_path'] db_path: str = config['db_path'] diff --git a/slpkg/main.py b/slpkg/main.py index a9a0e40d..c7b6e0d2 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -37,7 +37,8 @@ class Argparse: '--jobs', '--resolve-off', '--reinstall', - '--skip-installed' + '--skip-installed', + '--download-only' ] for option in self.options: diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index 0e9f7c9c..c1c542bf 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -30,6 +30,7 @@ class Slackbuilds: build_path: str = Configs.build_path sbo_url: str = Configs.sbo_url build_path: str = Configs.build_path + download_only: str = Configs.download_only tmp_slpkg: str = Configs.tmp_slpkg tmp_path: str = Configs.tmp_path tar_suffix: str = Configs.tar_suffix @@ -56,7 +57,9 @@ class Slackbuilds: ''' View slackbuilds before proceed. ''' 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) else: view.build_packages(self.slackbuilds, self.dependencies) @@ -108,11 +111,16 @@ class Slackbuilds: 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() 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) if self.install: @@ -148,6 +156,7 @@ class Slackbuilds: if ('--reinstall' in self.flags and self.utils.is_installed(package[:-4])): execute = self.reinstall + command = f'{execute} {self.tmp_path}/{package}' subprocess.call(command, shell=True) @@ -176,6 +185,7 @@ class Slackbuilds: self.set_makeflags() stdout = subprocess.call(execute) + if stdout > 0: raise SystemExit(stdout) @@ -187,10 +197,14 @@ class Slackbuilds: def download_sources(self, name: str, sources: str): ''' Download the sources. ''' wget = Wget() + path = f'{self.build_path}/{name}' + if '--download-only' in self.flags: + path = self.download_only + checksums = SBoQueries(name).checksum() for source, checksum in zip(sources.split(), checksums[0].split()): wget.download(path, source) md5sum = Md5sum(self.flags) - md5sum.check(source, checksum, name) + md5sum.check(path, source, checksum, name) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index ad677822..dfc76668 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -33,7 +33,8 @@ def usage(status: int): f' {YELLOW}--jobs{ENDC} Set it for multicore systems.', f' {YELLOW}--resolve-off{ENDC} Turns off dependency resolving.', 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.', ' -v, --version Print version and exit.\n', 'If you need more information try to use slpkg manpage.'] diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 33c3d943..67cf196f 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -53,6 +53,19 @@ class ViewMessage: self._view_total(slackbuilds, dependencies, option='install') + def download_packages(self, slackbuilds: list, dependencies: list): + print('The following packages will be download:\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): print('The following packages will be removed:\n') self.installed_packages = [] @@ -76,6 +89,16 @@ class ViewMessage: 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): color = self.colors() From 143670754de6a59aef3f24054beb5cc4585ac3c6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 14 Oct 2022 20:27:37 +0300 Subject: [PATCH 4/6] Fixed KeyError in configs Signed-off-by: Dimitris Zlatanidis --- slpkg/configs.py | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/slpkg/configs.py b/slpkg/configs.py index 0ac21ae4..6bf64405 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -59,41 +59,44 @@ class Configs: with open(config_file, 'r') as conf: configs = yaml.safe_load(conf) - config = configs['configs'] + try: + config = configs['configs'] - # OS architecture by default - os_arch: str = config['os_arch'] + # OS architecture by default + os_arch: str = config['os_arch'] - # All necessary paths - tmp_path: str = config['tmp_path'] - tmp_slpkg: str = config['tmp_slpkg'] - build_path: str = config['build_path'] - download_only: str = config['download_only'] - lib_path: str = config['lib_path'] - etc_path: str = config['etc_path'] - db_path: str = config['db_path'] - sbo_repo_path: str = config['sbo_repo_path'] - log_packages: str = config['log_packages'] + # All necessary paths + tmp_path: str = config['tmp_path'] + tmp_slpkg: str = config['tmp_slpkg'] + build_path: str = config['build_path'] + download_only: str = config['download_only'] + lib_path: str = config['lib_path'] + etc_path: str = config['etc_path'] + db_path: str = config['db_path'] + sbo_repo_path: str = config['sbo_repo_path'] + log_packages: str = config['log_packages'] - # Database name - database: str = config['database'] + # Database name + database: str = config['database'] - # Repository details - repo_version: str = config['repo_version'] - sbo_url: str = config['sbo_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'] + # Repository details + repo_version: str = config['repo_version'] + sbo_url: str = config['sbo_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'] - # Slackware commands - installpkg: str = config['installpkg'] - reinstall: str = config['reinstall'] - removepkg: str = config['removepkg'] + # Slackware commands + installpkg: str = config['installpkg'] + reinstall: str = config['reinstall'] + removepkg: str = config['removepkg'] - # Other configs - colors: str = config['colors'] - wget_options: str = config['wget_options'] + # Other configs + colors: str = config['colors'] + wget_options: str = config['wget_options'] + except KeyError: + pass @classmethod def colour(cls): From 6bebe5c2c78e2d79e919ce65cdef074af602d481 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 14 Oct 2022 20:31:12 +0300 Subject: [PATCH 5/6] Updated for version 4.1.9 Signed-off-by: Dimitris Zlatanidis --- README.rst | 4 ++-- man/slpkg.1 | 2 +- setup.cfg | 2 +- slpkg/version.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 49d629a9..7e03869c 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository diff --git a/setup.cfg b/setup.cfg index 26381ddf..8021551c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = slpkg -version = 4.1.8 +version = 4.1.9 license_file = LICENSE author = Dimitris Zlatanidis author_email = d.zlatanidis@gmail.com diff --git a/slpkg/version.py b/slpkg/version.py index 2f3320b5..b4fe7a3e 100644 --- a/slpkg/version.py +++ b/slpkg/version.py @@ -10,7 +10,7 @@ from slpkg.configs import Configs @dataclass class Version: 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) license: str = 'MIT License' author: str = 'dslackw' From a38f414329d3accd89299c8d78ef2d5ff147fbd8 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 14 Oct 2022 20:41:37 +0300 Subject: [PATCH 6/6] Fixed typo Signed-off-by: Dimitris Zlatanidis --- slpkg/views/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 67cf196f..59d4f475 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -54,7 +54,7 @@ class ViewMessage: self._view_total(slackbuilds, dependencies, option='install') def download_packages(self, slackbuilds: list, dependencies: list): - print('The following packages will be download:\n') + print('The following packages will be downloaded:\n') for sbo in slackbuilds: version = SBoQueries(sbo).version()