From 19f77bd114bf12f35e40b75b4369ca55d702a40c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 28 Jun 2022 17:56:05 +0300 Subject: [PATCH 1/6] Added setup.cfg file --- LICENSE.txt => LICENSE | 0 setup.cfg | 46 +++++++++++++++++++++++++++++++++++++ setup.py | 46 ++----------------------------------- slackbuild/slpkg.SlackBuild | 2 +- 4 files changed, 49 insertions(+), 45 deletions(-) rename LICENSE.txt => LICENSE (100%) create mode 100644 setup.cfg diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..abbd2370 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,46 @@ +[metadata] +name = slpkg +version = 4.1.3 +license_file = LICENSE +author = Dimitris Zlatanidis +author_email = d.zlatanidis@gmail.com +description = Packaging tool that interacts with the SBo repository +long_description = file:README.rst +url = https://dslackw.gitlab.io/slpkg/ +project_urls = + Source = https://dslackw.gitlab.io/slpkg/ + Documentation = https://dslackw.gitlab.io/slpkg/ +classifiers = + License :: OSI Approved :: MIT License + Natural Language :: English + Operating System :: POSIX + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Unix Shell + Topic :: Utilities + Topic :: Software Development :: Build Tools + Topic :: System :: Archiving :: Packaging + Topic :: System :: Software Distribution + Topic :: System :: Installation/Setup + Topic :: System :: Systems Administration + Topic :: System :: Software Distribution + +[options] +packages = + slpkg + slpkg.models + slpkg.views +python_requires = >=3.7 +install_requires = + SQLAlchemy >= 1.4.36 + PyYAML >= 6.0 +include_package_data = True + +[options.packages.find] +where = . diff --git a/setup.py b/setup.py index 65af2c10..0ae45559 100755 --- a/setup.py +++ b/setup.py @@ -1,47 +1,5 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - - from setuptools import setup -from slpkg.version import Version -install_requires = ['SQLAlchemy>=1.4.36', - 'PyYAML>=6.0'] - - -setup( - name='slpkg', - packages=['slpkg', 'slpkg/models', 'slpkg/views'], - scripts=['bin/slpkg'], - version=Version.version, - description='Packaging tool that interacts with the SBo repository', - long_description=open('README.rst').read(), - keywords=['slackware', 'slpkg', 'update', 'build', 'install', 'remove', - 'slackpkg', 'tool'], - author='dslackw', - url='https://dslackw.gitlab.io/slpkg/', - package_data={'': ['LICENSE.txt', 'README.rst', 'ChangeLog.txt']}, - data_files=[('/etc/slpkg', ['configs/slpkg.yaml']), - ('/etc/slpkg', ['configs/blacklist.yaml']), - ('/var/lib/slpkg/database', []), - ('/var/lib/slpkg/repository', [])], - install_requires=install_requires, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'License :: OSI Approved :: MIT License', - 'Operating System :: POSIX :: Linux', - 'Operating System :: Unix', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Unix Shell', - 'Topic :: Software Development :: Build Tools', - 'Topic :: System :: Archiving :: Packaging', - 'Topic :: System :: Software Distribution', - 'Topic :: System :: Installation/Setup', - 'Topic :: System :: Systems Administration', - 'Topic :: System :: Software Distribution', - 'Topic :: Utilities'], - python_requires='>=3.9' -) +if __name__ == '__main__': + setup() diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index 2a5e3dbb..50714a1b 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -108,7 +108,7 @@ find $PKG/usr/man -type f -exec gzip -9 {} \; for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz; rm $i ; done mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION -cp -a README.rst ChangeLog.txt LICENSE.txt requirements.txt $PKG/usr/doc/$PRGNAM-$VERSION +cp -a README.rst ChangeLog.txt LICENSE requirements.txt $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild mkdir -p $PKG/install From 6bb5010846295ea5dc6992b0a22b079d872bae6c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 29 Jun 2022 10:39:54 +0300 Subject: [PATCH 2/6] Updated for version 4.1.4 --- 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 53ee34ce..b295ef5b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +4.1.4 - 29/06/2022 +-Added +- setup.cfg file + 4.1.3 - 26/06/2022 Bugfixed: - /tmp permissions after installation diff --git a/README.rst b/README.rst index cace843e..d1373bf0 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository Date: Sun, 17 Jul 2022 18:39:19 +0300 Subject: [PATCH 3/6] Added upgrade packages option Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 3 ++- man/slpkg.1 | 7 ++++++- slpkg/main.py | 17 +++++++++++++++-- slpkg/upgrade.py | 25 +++++++++++++++++++++++++ slpkg/views/cli_menu.py | 1 + 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 slpkg/upgrade.py diff --git a/ChangeLog.txt b/ChangeLog.txt index b295ef5b..ec1d553e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ -4.1.4 - 29/06/2022 +4.1.4 - 17/07/2022 -Added - setup.cfg file +- Upgrade installed packages option 4.1.3 - 26/06/2022 Bugfixed: diff --git a/man/slpkg.1 b/man/slpkg.1 index ee5b10de..01b91762 100644 --- a/man/slpkg.1 +++ b/man/slpkg.1 @@ -4,7 +4,7 @@ slpkg - [OPTIONS] [COMMAND] .SH SYNAPSES .P -slpkg [-h|-v] [update] [build] [install] [remove] [find] [search] [clean-logs] [clean-tmp] --yes --resolve-off --reinstall +slpkg [-h|-v] [update] [upgrade] [build] [install] [remove] [find] [search] [clean-logs] [clean-tmp] --yes --resolve-off --reinstall .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. @@ -17,6 +17,11 @@ update Updates the package list and the database. .RE .P +upgrade +.RS +Upgrade all the installed packages. +.RE +.P build .RS Builds the scripts and puts them in the /tmp directory. diff --git a/slpkg/main.py b/slpkg/main.py index 5704aa7e..e6af051c 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -7,6 +7,7 @@ from dataclasses import dataclass from slpkg.checks import Check from slpkg.search import Search +from slpkg.upgrade import Upgrade from slpkg.version import Version from slpkg.configs import Configs from slpkg.utilities import Utilities @@ -62,6 +63,16 @@ class Argparse: raise SystemExit() usage(1) + def upgrade(self): + if len(self.args) == 1: + upgrade = Upgrade() + packages = list(upgrade.packages()) + + install = Slackbuilds(packages, self.flags, install=True) + install.execute() + raise SystemExit() + usage(1) + def build(self): if len(self.args) >= 2 and '--reinstall' not in self.flags: packages = list(set(self.args[1:])) @@ -69,7 +80,7 @@ class Argparse: self.check.exists(packages) self.check.unsupported(packages) - build = Slackbuilds(packages, self.flags, False) + build = Slackbuilds(packages, self.flags, install=False) build.execute() raise SystemExit() usage(1) @@ -81,7 +92,7 @@ class Argparse: self.check.exists(packages) self.check.unsupported(packages) - install = Slackbuilds(packages, self.flags, True) + install = Slackbuilds(packages, self.flags, install=True) install.execute() raise SystemExit() usage(1) @@ -141,6 +152,7 @@ class Argparse: path = Configs.tmp_path tmp_slpkg = Configs.tmp_slpkg folder = Configs.prog_name + utils = Utilities() utils.remove_folder_if_exists(path, folder) utils.create_folder(tmp_slpkg, 'build') @@ -160,6 +172,7 @@ def main(): '-v': argparse.version, '--version': argparse.version, 'update': argparse.update, + 'upgrade': argparse.upgrade, 'build': argparse.build, 'install': argparse.install, 'remove': argparse.remove, diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py new file mode 100644 index 00000000..7fe3065d --- /dev/null +++ b/slpkg/upgrade.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import os +from dataclasses import dataclass +from distutils.version import LooseVersion + +from slpkg.configs import Configs +from slpkg.queries import SBoQueries + + +@dataclass +class Upgrade: + log_packages: str = Configs.log_packages + repo_tag: str = Configs.repo_tag + + def packages(self): + for pkg in os.listdir(self.log_packages): + if pkg.endswith(self.repo_tag): + name = '-'.join(pkg.split('-')[:-3]) + installed_ver = pkg.replace(name + '-', '').split('-')[0] + repo_ver = SBoQueries(name).version() + + if LooseVersion(repo_ver) > LooseVersion(installed_ver): + yield name diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index 3db226b9..b0a822db 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -20,6 +20,7 @@ def usage(status: int): ' Packaging tool that interacts with the SBo repository.\n', f'{BOLD}COMMANDS:{ENDC}', f' {RED}update{ENDC} Update the package lists.', + 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}remove{ENDC} Remove installed packages.', From 86913ce886d8700a91c39cbfbc6b6d8c3369455e Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 17 Jul 2022 18:59:19 +0300 Subject: [PATCH 4/6] Updated readme Signed-off-by: Dimitris Zlatanidis --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index d1373bf0..ee1a4a94 100644 --- a/README.rst +++ b/README.rst @@ -49,6 +49,7 @@ Usage COMMANDS: update Update the package lists. + upgrade Upgrade all the packages. build Build only the packages. install Build and install the packages. remove Remove installed packages. From 0a63445f03a2ec3cc411c118463522259131d64c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 14 Aug 2022 11:32:08 +0300 Subject: [PATCH 5/6] Added comments Signed-off-by: Dimitris Zlatanidis --- slpkg/upgrade.py | 1 + 1 file changed, 1 insertion(+) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 7fe3065d..c6b112d0 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -15,6 +15,7 @@ class Upgrade: repo_tag: str = Configs.repo_tag def packages(self): + ''' Compares version of packages and returns the maximum. ''' for pkg in os.listdir(self.log_packages): if pkg.endswith(self.repo_tag): name = '-'.join(pkg.split('-')[:-3]) From 52fbb84088d5d9b0ad6198fe2cfd45acb2f03e14 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 28 Aug 2022 16:41:17 +0300 Subject: [PATCH 6/6] Updated changelog Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index ec1d553e..f16f18b5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,7 +1,7 @@ 4.1.4 - 17/07/2022 -Added - setup.cfg file -- Upgrade installed packages option +- Option to upgrade sbo packages 4.1.3 - 26/06/2022 Bugfixed: