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/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 .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 --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/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/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..6bf64405 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' @@ -58,40 +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'] - 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): 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/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' 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..59d4f475 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 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 = [] @@ -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()