From 2437a3fe0b25c671ff1ccdf7a49477bc15d6eda6 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 09:12:37 +0300 Subject: [PATCH 01/14] Creating all necessary paths from the config file Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 4 ++++ slackbuild/slpkg.SlackBuild | 2 +- slpkg/configs.py | 17 +++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index a0edf413..b8d49156 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +4.2.3 - 28/10/2022 +Updated: +- Creating all necessary paths from config file + 4.2.2 - 20/10/2022 Updated: - Removed version for skip installed option diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index 2475de78..93000c36 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -97,7 +97,7 @@ find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | gr | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true # Install configuration files and creating lib directory -mkdir -p $PKG/etc/$PRGNAM $PKG/var/lib/$PRGNAM/database $PKG/var/lib/$PRGNAM/repository +mkdir -p $PKG/etc/$PRGNAM install -D -m0644 configs/slpkg.yml $PKG/etc/slpkg/slpkg.yml.new install -D -m0645 configs/blacklist.yml $PKG/etc/slpkg/blacklist.yml.new diff --git a/slpkg/configs.py b/slpkg/configs.py index d79dab7f..84ee3622 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -49,10 +49,6 @@ class Configs: # Wget options wget_options = '-c -N' - # Creating the build path - if not os.path.isdir(build_path): - os.makedirs(build_path) - ''' Overwrite with user configuration. ''' config_file: str = f'{etc_path}/{prog_name}.yml' if os.path.isfile(config_file): @@ -95,6 +91,19 @@ class Configs: except KeyError: pass + # Creating the paths if they doesn't exists + paths = [tmp_path, + build_path, + download_only, + sbo_repo_path, + lib_path, + etc_path, + db_path] + + for path in paths: + if not os.path.isdir(path): + os.makedirs(path) + @classmethod def colour(cls): color = { From 7e4888c4ee454ce634b14a886efe9bd2218bf3e1 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 09:13:37 +0300 Subject: [PATCH 02/14] Fixed typo Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index b8d49156..e7685220 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,6 @@ 4.2.3 - 28/10/2022 Updated: -- Creating all necessary paths from config file +- Creating all necessary paths from the config file 4.2.2 - 20/10/2022 Updated: From 9ec96c6565f96521e85778f763fce377b61d610a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 09:24:25 +0300 Subject: [PATCH 03/14] Updated installed message Signed-off-by: Dimitris Zlatanidis --- slpkg/views/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index 6b0f7f39..f19b2800 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -116,6 +116,10 @@ class ViewMessage: self.arch = 'noarch' if installed: + + if '--reinstall' not in self.flags: + install = 'installed' + print(f'[{set_color} {install} {color["ENDC"]}] -> ' f'{sbo}-{version} {set_color}' f'({installed.split(self.arch)[0][:-1].split("-")[-1]})' From 86a5871193fd4842c8060a44be9feac4de6dc112 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 09:26:56 +0300 Subject: [PATCH 04/14] Set color off by default Signed-off-by: Dimitris Zlatanidis --- configs/slpkg.yml | 4 ++-- slpkg/configs.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configs/slpkg.yml b/configs/slpkg.yml index 163cf606..6690a9e8 100644 --- a/configs/slpkg.yml +++ b/configs/slpkg.yml @@ -39,8 +39,8 @@ configs: # Slackware command fro remove packages. removepkg: removepkg - # Cli menu colors configs. Default is on. [on/off] - colors: on + # Cli menu colors configs. Default is off. [on/off] + colors: off # Wget downloader options. # -c, --continue: resume getting a partially-downloaded file. diff --git a/slpkg/configs.py b/slpkg/configs.py index 84ee3622..824de870 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -44,7 +44,7 @@ class Configs: removepkg: str = 'removepkg' # Cli menu colors configs - colors: str = 'on' + colors: str = 'off' # Wget options wget_options = '-c -N' From 665f081e732a93adcb4051bf0c47770a1def28b5 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 10:55:26 +0300 Subject: [PATCH 05/14] Fixed slpkg tmp path Signed-off-by: Dimitris Zlatanidis --- slpkg/configs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slpkg/configs.py b/slpkg/configs.py index 824de870..170bfc22 100644 --- a/slpkg/configs.py +++ b/slpkg/configs.py @@ -92,7 +92,7 @@ class Configs: pass # Creating the paths if they doesn't exists - paths = [tmp_path, + paths = [tmp_slpkg, build_path, download_only, sbo_repo_path, From ddadb5ef37f90d00c9632e0789631a5c63f45806 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 11:03:27 +0300 Subject: [PATCH 06/14] Updated view cleaning logs dependencies Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 1 + slpkg/views/views.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e7685220..8b02ddeb 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ 4.2.3 - 28/10/2022 Updated: - Creating all necessary paths from the config file +- Logs cleaning view dependencies 4.2.2 - 20/10/2022 Updated: diff --git a/slpkg/views/views.py b/slpkg/views/views.py index f19b2800..e0ef8079 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -170,8 +170,8 @@ class ViewMessage: for dep in dependencies: print(f'{color["CYAN"]}{dep[0]}{color["ENDC"]}') - print('Dependencies:') - print(f'{color["CYAN"]} {dep[1]}{color["ENDC"]}\n') + print(' |') + print(f' +->{color["CYAN"]} {dep[1]}{color["ENDC"]}\n') print('Note: After cleaning you should remove them one by one.') def question(self): From 6569bdf721fdd8c42e60fb76bbc7c22a4f830669 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 20:27:00 +0300 Subject: [PATCH 07/14] Bugfixed to check if database is empty #145 Signed-off-by: Dimitris Zlatanidis --- slpkg/checks.py | 6 ++++-- slpkg/main.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/slpkg/checks.py b/slpkg/checks.py index 4a701292..f57e9413 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -14,10 +14,11 @@ class Check: ''' Some checks before proceed. ''' log_packages: str = Configs.log_packages sbo_repo_tag: str = Configs.sbo_repo_tag + db_path: str = Configs.db_path + database_name: str = Configs.database def exists(self, slackbuilds: list): ''' Checking if the slackbuild exists in the repository. ''' - self.database() packages = [] for sbo in slackbuilds: @@ -59,6 +60,7 @@ class Check: def database(self): ''' Checking for empty table ''' - if not SBoQueries('').names(): + db = f'{self.db_path}/{self.database_name}' + if not SBoQueries('').names() or not os.path.isfile(db): raise SystemExit('\nYou need to update the package lists first.\n' 'Please run slpkg update.\n') diff --git a/slpkg/main.py b/slpkg/main.py index fc2c49a3..991d2894 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -70,6 +70,8 @@ class Argparse: upgrade = Upgrade() packages = list(upgrade.packages()) + self.check.database() + if not packages: print('\nEverything is up-to-date.\n') raise SystemExit() @@ -83,6 +85,7 @@ class Argparse: if len(self.args) >= 2 and '--reinstall' not in self.flags: packages = list(set(self.args[1:])) + self.check.database() self.check.exists(packages) self.check.unsupported(packages) @@ -95,6 +98,7 @@ class Argparse: if len(self.args) >= 2: packages = list(set(self.args[1:])) + self.check.database() self.check.exists(packages) self.check.unsupported(packages) @@ -110,6 +114,7 @@ class Argparse: if len(self.args) >= 2: packages = list(set(self.args[1:])) + self.check.database() self.check.exists(packages) download = Download(self.flags) download.packages(packages) @@ -125,6 +130,7 @@ class Argparse: packages = list(set(self.args[1:])) packages = self.check.blacklist(packages) + self.check.database() self.check.installed(packages) remove = RemovePackages(packages, self.flags) @@ -137,6 +143,7 @@ class Argparse: packages = list(set(self.args[1:])) packages = self.check.blacklist(packages) + self.check.database() self.check.exists(packages) view = ViewPackage() @@ -149,6 +156,7 @@ class Argparse: packages = list(set(self.args[1:])) packages = self.check.blacklist(packages) + self.check.database() search = SearchPackage() search.package(packages) raise SystemExit() @@ -159,6 +167,7 @@ class Argparse: packages = list(set(self.args[1:])) packages = self.check.blacklist(packages) + self.check.database() find = FindInstalled() find.find(packages) raise SystemExit() @@ -169,6 +178,8 @@ class Argparse: usage(1) if len(self.args) == 1: + self.check.database() + logs = CleanLogsDependencies(self.flags) logs.clean() raise SystemExit() From d0db9c2fe74b8f862d5fd687bb4118fefe0b9446 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 21:07:42 +0300 Subject: [PATCH 08/14] Updated check database before Signed-off-by: Dimitris Zlatanidis --- slpkg/main.py | 20 ++++++++++++++------ slpkg/upgrade.py | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/slpkg/main.py b/slpkg/main.py index 991d2894..4ca2d99f 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -67,11 +67,11 @@ class Argparse: def upgrade(self): if len(self.args) == 1: + self.check.database() + upgrade = Upgrade() packages = list(upgrade.packages()) - self.check.database() - if not packages: print('\nEverything is up-to-date.\n') raise SystemExit() @@ -128,9 +128,11 @@ class Argparse: if len(self.args) >= 2: packages = list(set(self.args[1:])) - packages = self.check.blacklist(packages) self.check.database() + + packages = self.check.blacklist(packages) + self.check.installed(packages) remove = RemovePackages(packages, self.flags) @@ -141,9 +143,11 @@ class Argparse: def view(self): if len(self.args) >= 2 and not self.flags: packages = list(set(self.args[1:])) - packages = self.check.blacklist(packages) self.check.database() + + packages = self.check.blacklist(packages) + self.check.exists(packages) view = ViewPackage() @@ -154,9 +158,11 @@ class Argparse: def search(self): if len(self.args) >= 2 and not self.flags: packages = list(set(self.args[1:])) - packages = self.check.blacklist(packages) self.check.database() + + packages = self.check.blacklist(packages) + search = SearchPackage() search.package(packages) raise SystemExit() @@ -165,9 +171,11 @@ class Argparse: def find(self): if len(self.args) >= 2 and not self.flags: packages = list(set(self.args[1:])) - packages = self.check.blacklist(packages) self.check.database() + + packages = self.check.blacklist(packages) + find = FindInstalled() find.find(packages) raise SystemExit() diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 9045bda7..669164db 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -19,6 +19,7 @@ class Upgrade: for pkg in os.listdir(self.log_packages): if pkg.endswith(self.sbo_repo_tag): name = '-'.join(pkg.split('-')[:-3]) + installed_ver = pkg.replace(name + '-', '').split('-')[0] repo_ver = SBoQueries(name).version() From 0236ad507b1a932e4d6a9ed7a1c2ce5fce100ef0 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 21:32:27 +0300 Subject: [PATCH 09/14] Added warning message 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 669164db..0ae9d1dd 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -16,6 +16,7 @@ class Upgrade: def packages(self): ''' Compares version of packages and returns the maximum. ''' + print("Do not forget to run 'slpkg update' before.") for pkg in os.listdir(self.log_packages): if pkg.endswith(self.sbo_repo_tag): name = '-'.join(pkg.split('-')[:-3]) From 6bf22f40aeb8f27d24232f4035d6ff7eaa501733 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 21:38:55 +0300 Subject: [PATCH 10/14] Updated ChangeLog.txt Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8b02ddeb..32d16d3a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,8 @@ Updated: - Creating all necessary paths from the config file - Logs cleaning view dependencies +Added: +- Check database if file exists 4.2.2 - 20/10/2022 Updated: From 2544e0cae7e9e639a65a200821bec7ce601adbbe Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Fri, 28 Oct 2022 22:04:29 +0300 Subject: [PATCH 11/14] Updated for version 4.2.3 Signed-off-by: Dimitris Zlatanidis --- README.rst | 6 +++--- setup.cfg | 2 +- slpkg/version.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.rst b/README.rst index 82f0a21c..f5233117 100644 --- a/README.rst +++ b/README.rst @@ -30,8 +30,8 @@ Install from the official third-party `SBo repository Date: Sat, 29 Oct 2022 19:49:35 +0300 Subject: [PATCH 12/14] Fixed: upgrade fails with python trackback message #145 Signed-off-by: Dimitris Zlatanidis --- slpkg/upgrade.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index 0ae9d1dd..dab5883f 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -17,12 +17,16 @@ class Upgrade: def packages(self): ''' Compares version of packages and returns the maximum. ''' print("Do not forget to run 'slpkg update' before.") + + repo_packages = SBoQueries('').names() + for pkg in os.listdir(self.log_packages): if pkg.endswith(self.sbo_repo_tag): name = '-'.join(pkg.split('-')[:-3]) - installed_ver = pkg.replace(name + '-', '').split('-')[0] - repo_ver = SBoQueries(name).version() + if name in repo_packages: + installed_ver = pkg.replace(name + '-', '').split('-')[0] + repo_ver = SBoQueries(name).version() - if LooseVersion(repo_ver) > LooseVersion(installed_ver): - yield name + if LooseVersion(repo_ver) > LooseVersion(installed_ver): + yield name From e064584e146d597de1ade1753b40260c6afdf452 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 29 Oct 2022 19:52:52 +0300 Subject: [PATCH 13/14] Updated names Signed-off-by: Dimitris Zlatanidis --- slpkg/upgrade.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index dab5883f..a9aa11be 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -22,11 +22,12 @@ class Upgrade: for pkg in os.listdir(self.log_packages): if pkg.endswith(self.sbo_repo_tag): - name = '-'.join(pkg.split('-')[:-3]) + inst_pkg_name = '-'.join(pkg.split('-')[:-3]) - if name in repo_packages: - installed_ver = pkg.replace(name + '-', '').split('-')[0] - repo_ver = SBoQueries(name).version() + if inst_pkg_name in repo_packages: + installed_ver = pkg.replace( + inst_pkg_name + '-', '').split('-')[0] + repo_ver = SBoQueries(inst_pkg_name).version() if LooseVersion(repo_ver) > LooseVersion(installed_ver): - yield name + yield inst_pkg_name From c606944e1094f41835134505a405861ced7f3f9a Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 29 Oct 2022 20:01:06 +0300 Subject: [PATCH 14/14] Updated ChangeLog.txt Signed-off-by: Dimitris Zlatanidis --- ChangeLog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 32d16d3a..311902d8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,7 +3,8 @@ Updated: - Creating all necessary paths from the config file - Logs cleaning view dependencies Added: -- Check database if file exists +- Check if database file exists +- Check if the package exists in the database before upgrade 4.2.2 - 20/10/2022 Updated: