diff --git a/ChangeLog.txt b/ChangeLog.txt index 53ee34ce..f16f18b5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,8 @@ +4.1.4 - 17/07/2022 +-Added +- setup.cfg file +- Option to upgrade sbo packages + 4.1.3 - 26/06/2022 Bugfixed: - /tmp permissions after installation diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/README.rst b/README.rst index cace843e..ee1a4a94 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. remove Remove installed packages. 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/setup.cfg b/setup.cfg new file mode 100644 index 00000000..eea47bcf --- /dev/null +++ b/setup.cfg @@ -0,0 +1,46 @@ +[metadata] +name = slpkg +version = 4.1.4 +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 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..c6b112d0 --- /dev/null +++ b/slpkg/upgrade.py @@ -0,0 +1,26 @@ +#!/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): + ''' 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]) + 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/version.py b/slpkg/version.py index 51f3fcd6..a322d90c 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, 3) + version_info: tuple = (4, 1, 4) 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 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.',