diff --git a/ChangeLog.txt b/ChangeLog.txt index e2ee40ac..f1d78603 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,8 @@ +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: - New option --download-only diff --git a/README.rst b/README.rst index 5db2f536..2cfbc7c7 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository 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/setup.cfg b/setup.cfg index 8021551c..db0a16f4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = slpkg -version = 4.1.9 +version = 4.2.0 license_file = LICENSE author = Dimitris Zlatanidis author_email = d.zlatanidis@gmail.com 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..f8b2bb95 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: @@ -66,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()) @@ -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 c1c542bf..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) @@ -111,16 +108,11 @@ class Slackbuilds: 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: @@ -199,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/version.py b/slpkg/version.py index b4fe7a3e..00c56f81 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, 9) + version_info: tuple = (4, 2, 0) version: str = '{0}.{1}.{2}'.format(*version_info) license: str = 'MIT License' author: str = 'dslackw' diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index dfc76668..2d11ddfc 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,10 +34,10 @@ 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', + 'Edit the configuration file in the /etc/slpkg/slpkg.yml.', 'If you need more information try to use slpkg manpage.'] for opt in args: 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 = []