Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2022-10-16 19:30:38 +03:00
commit d885a6c628
10 changed files with 79 additions and 37 deletions

View file

@ -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

View file

@ -30,8 +30,8 @@ Install from the official third-party `SBo repository <https://slackbuilds.org/r
.. code-block:: bash
$ tar xvf slpkg-4.1.9.tar.gz
$ cd slpkg-4.1.9
$ tar xvf slpkg-4.2.0.tar.gz
$ cd slpkg-4.2.0
$ ./install.sh
@ -52,6 +52,7 @@ Usage
upgrade Upgrade all the packages.
build <packages> Build only the packages.
install <packages> Build and install the packages.
download <packages> Download only the packages.
remove <packages> Remove installed packages.
find <packages> Find installed packages.
search <packages> 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.

View file

@ -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] <packages>
.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.

View file

@ -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

38
slpkg/download_only.py Normal file
View file

@ -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)

View file

@ -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,

View file

@ -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()

View file

@ -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'

View file

@ -23,6 +23,7 @@ def usage(status: int):
f' {CYAN}upgrade{ENDC} Upgrade all the packages.',
f' {CYAN}build{ENDC} <packages> Build only the packages.',
f' {CYAN}install{ENDC} <packages> Build and install the packages.',
f' {CYAN}download{ENDC} <packages> Download only the packages.',
f' {CYAN}remove{ENDC} <packages> Remove installed packages.',
f' {CYAN}find{ENDC} <packages> Find installed packages.',
f' {CYAN}search{ENDC} <packages> 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:

View file

@ -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 = []