From 6cbed7c3c5bb3e1e96110f762a3975576cca5eec Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 14 Oct 2022 21:49:53 +0300 Subject: [PATCH 1/6] Bugfixed: download only path Signed-off-by: Dimitris Zlatanidis --- slpkg/slackbuild.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index c1c542bf..b6edf34e 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -109,7 +109,10 @@ class Slackbuilds: location = SBoQueries(sbo).location() url = f'{self.sbo_url}/{location}/{file}' - wget.download(self.tmp_slpkg, url) + if '--download-only' in self.flags: + wget.download(self.download_only, url) + else: + wget.download(self.tmp_slpkg, url) if '--download-only' not in self.flags: self.utils.untar_archive(self.tmp_slpkg, file, self.build_path) From 828fc7c416c4314316777116ed82577270126c95 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 14 Oct 2022 21:52:03 +0300 Subject: [PATCH 2/6] Updated for version 4.2.0 Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 ++++ README.rst | 4 ++-- setup.cfg | 2 +- slpkg/version.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e2ee40ac..1527e30a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +4.2.0 - 14/10/2022 +Bugfixed: +- Download only option sources path + 4.1.9 - 14/10/2022 Added: - New option --download-only diff --git a/README.rst b/README.rst index 5db2f536..d073b765 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository Date: Sat, 15 Oct 2022 20:05:38 +0300 Subject: [PATCH 3/6] Moved option --download-only to commands Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 ++-- README.rst | 2 +- man/slpkg.1 | 14 +++++++------- slpkg/download_only.py | 38 ++++++++++++++++++++++++++++++++++++++ slpkg/main.py | 20 +++++++++++++++++--- slpkg/slackbuild.py | 19 +++---------------- slpkg/views/cli_menu.py | 4 ++-- slpkg/views/views.py | 8 +------- 8 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 slpkg/download_only.py diff --git a/ChangeLog.txt b/ChangeLog.txt index 1527e30a..f89d9788 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,6 @@ 4.2.0 - 14/10/2022 -Bugfixed: -- Download only option sources path +Updated: +- Moved option --download-only to commands 4.1.9 - 14/10/2022 Added: diff --git a/README.rst b/README.rst index d073b765..2cfbc7c7 100644 --- a/README.rst +++ b/README.rst @@ -52,6 +52,7 @@ Usage upgrade Upgrade all the packages. build Build only the packages. install Build and install the packages. + download Download only the packages. remove Remove installed packages. find Find installed packages. search Search packages on repository. @@ -64,7 +65,6 @@ Usage --resolve-off Turns off dependency resolving. --reinstall Use this option if you want to upgrade. --skip-installed Skip installed packages. - --download-only Download only the packages. -h, --help Show this message and exit. -v, --version Print version and exit. diff --git a/man/slpkg.1 b/man/slpkg.1 index 29d3ba9d..f9b0cc8d 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -1,10 +1,10 @@ -.TH slpkg 1 "Orestiada, Greece" "slpkg 4.1.9" dslackw +.TH slpkg 1 "Orestiada, Greece" "slpkg 4.2.0" dslackw .SH NAME .P 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 --download-only +slpkg [-h|-v] [update] [upgrade] [build] [install] [download] [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. @@ -32,6 +32,11 @@ install Builds and installs the packages in the correct order and also logs the packages with dependencies to use for removal. .RE .P +download +.RS +Download only the packages without building or installing it. +.RE +.P remove .RS Removes packages with dependencies if the packages was installed with slpkg install method. @@ -85,11 +90,6 @@ 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/download_only.py b/slpkg/download_only.py new file mode 100644 index 00000000..38f7492b --- /dev/null +++ b/slpkg/download_only.py @@ -0,0 +1,38 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +from dataclasses import dataclass + +from slpkg.downloader import Wget +from slpkg.configs import Configs +from slpkg.queries import SBoQueries +from slpkg.views.views import ViewMessage +from slpkg.models.models import session as Session + + +@dataclass +class Download: + flags: list + session: str = Session + download_only = Configs.download_only + sbo_url: str = Configs.sbo_url + tar_suffix: str = Configs.tar_suffix + + def packages(self, slackbuilds: list): + + view = ViewMessage(self.flags) + view.download_packages(slackbuilds) + view.question() + wget = Wget() + + for sbo in slackbuilds: + file = f'{sbo}{self.tar_suffix}' + location = SBoQueries(sbo).location() + url = f'{self.sbo_url}/{location}/{file}' + + wget.download(self.download_only, url) + + sources = SBoQueries(sbo).sources() + for source in sources.split(): + wget.download(self.download_only, source) diff --git a/slpkg/main.py b/slpkg/main.py index c7b6e0d2..4ca1ef15 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -12,6 +12,7 @@ from slpkg.version import Version from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.views.cli_menu import usage +from slpkg.download_only import Download from slpkg.slackbuild import Slackbuilds from slpkg.find_installed import FindInstalled from slpkg.remove_packages import RemovePackages @@ -37,9 +38,7 @@ class Argparse: '--jobs', '--resolve-off', '--reinstall', - '--skip-installed', - '--download-only' - ] + '--skip-installed'] for option in self.options: if option in self.args: @@ -103,6 +102,20 @@ class Argparse: raise SystemExit() usage(1) + def download(self): + if [f for f in self.flags if f in self.options[1:]]: + usage(1) + + if len(self.args) >= 2: + packages = list(set(self.args[1:])) + + self.check.exists(packages) + download = Download(self.flags) + download.packages(packages) + + raise SystemExit() + usage(1) + def remove(self): if [f for f in self.flags if f in self.options[1:]]: usage(1) @@ -178,6 +191,7 @@ def main(): 'upgrade': argparse.upgrade, 'build': argparse.build, 'install': argparse.install, + 'download': argparse.download, 'remove': argparse.remove, 'search': argparse.search, 'find': argparse.find, diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index b6edf34e..00c04553 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -30,7 +30,6 @@ 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 @@ -57,9 +56,7 @@ class Slackbuilds: ''' View slackbuilds before proceed. ''' view = ViewMessage(self.flags) - if '--download-only' in self.flags: - view.download_packages(self.slackbuilds, self.dependencies) - elif self.install: + if self.install: view.install_packages(self.slackbuilds, self.dependencies) else: view.build_packages(self.slackbuilds, self.dependencies) @@ -109,21 +106,13 @@ class Slackbuilds: location = SBoQueries(sbo).location() url = f'{self.sbo_url}/{location}/{file}' - if '--download-only' in self.flags: - wget.download(self.download_only, url) - else: - wget.download(self.tmp_slpkg, url) + wget.download(self.tmp_slpkg, url) - if '--download-only' not in self.flags: - self.utils.untar_archive(self.tmp_slpkg, file, self.build_path) + 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: @@ -202,8 +191,6 @@ class Slackbuilds: wget = Wget() path = f'{self.build_path}/{name}' - if '--download-only' in self.flags: - path = self.download_only checksums = SBoQueries(name).checksum() diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index dfc76668..92a0ecfe 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -23,6 +23,7 @@ def usage(status: int): f' {CYAN}upgrade{ENDC} Upgrade all the packages.', f' {CYAN}build{ENDC} Build only the packages.', f' {CYAN}install{ENDC} Build and install the packages.', + f' {CYAN}download{ENDC} Download only the packages.', f' {CYAN}remove{ENDC} Remove installed packages.', f' {CYAN}find{ENDC} Find installed packages.', f' {CYAN}search{ENDC} Search packages on repository.', @@ -33,8 +34,7 @@ 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.', - f' {YELLOW}--download-only{ENDC} Download only the packages.\n', + f' {YELLOW}--skip-installed{ENDC} Skip installed 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 59d4f475..90e3741a 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -53,19 +53,13 @@ class ViewMessage: self._view_total(slackbuilds, dependencies, option='install') - def download_packages(self, slackbuilds: list, dependencies: list): + def download_packages(self, slackbuilds: 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): print('The following packages will be removed:\n') self.installed_packages = [] From b441fbd3b67f09a948470bf7a0ba12d0ad4f852b Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 15 Oct 2022 21:00:21 +0300 Subject: [PATCH 4/6] Updated cli menu Signed-off-by: Dimitris Zlatanidis --- slpkg/views/cli_menu.py | 1 + 1 file changed, 1 insertion(+) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 92a0ecfe..4f7e2242 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -37,6 +37,7 @@ def usage(status: int): f' {YELLOW}--skip-installed{ENDC} Skip installed packages.\n', ' -h, --help Show this message and exit.', ' -v, --version Print version and exit.\n', + 'Configuration file in the /etc/slpkg/slpkg.yml.', 'If you need more information try to use slpkg manpage.'] for opt in args: From bd8c6c6fac2669d49c87ddcf67ae22f48e1518e6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 15 Oct 2022 21:04:17 +0300 Subject: [PATCH 5/6] Updated upgrade to work with options Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 1 + slpkg/main.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index f89d9788..f1d78603 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ 4.2.0 - 14/10/2022 Updated: - Moved option --download-only to commands +- Upgrade commands works with all options 4.1.9 - 14/10/2022 Added: diff --git a/slpkg/main.py b/slpkg/main.py index 4ca1ef15..f8b2bb95 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -65,7 +65,7 @@ class Argparse: usage(1) def upgrade(self): - if len(self.args) == 1 and not self.flags: + if len(self.args) == 1: upgrade = Upgrade() packages = list(upgrade.packages()) From 86c8d393781b56aa89d0f7b3c21c0acdc384130e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 16 Oct 2022 19:22:44 +0300 Subject: [PATCH 6/6] Updated cli menu Signed-off-by: Dimitris Zlatanidis --- slpkg/views/cli_menu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 4f7e2242..2d11ddfc 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -37,7 +37,7 @@ def usage(status: int): f' {YELLOW}--skip-installed{ENDC} Skip installed packages.\n', ' -h, --help Show this message and exit.', ' -v, --version Print version and exit.\n', - 'Configuration file in the /etc/slpkg/slpkg.yml.', + 'Edit the configuration file in the /etc/slpkg/slpkg.yml.', 'If you need more information try to use slpkg manpage.'] for opt in args: