Date: Thu, 2 Jun 2022 01:45:54 +0300
Subject: [PATCH 22/25] Removed --network option
---
ChangeLog.txt | 3 +-
conf/slpkg.bash-completion | 2 +-
conf/slpkg.fish | 2 -
man/slpkg.8 | 13 --
man/slpkg.html | 23 --
slpkg/arguments.py | 6 -
slpkg/main.py | 37 ----
slpkg/sbo/network.py | 419 -------------------------------------
8 files changed, 3 insertions(+), 502 deletions(-)
delete mode 100644 slpkg/sbo/network.py
diff --git a/ChangeLog.txt b/ChangeLog.txt
index 98bdce7b..b7d3ac55 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,8 +1,9 @@
4.0.2 - 30/05/2022
Removed:
-- Repositories rlw, mles, ktown, rested, slacke, slacky
+- Repositories rlw, mles, ktown, rested, slacke, slacky, slackl
- Option --directory-prefix
- Option --autobuild
+- Option --network
4.0.1 - 30/05/2022
Added:
diff --git a/conf/slpkg.bash-completion b/conf/slpkg.bash-completion
index 1ad16262..63f36205 100644
--- a/conf/slpkg.bash-completion
+++ b/conf/slpkg.bash-completion
@@ -4,7 +4,7 @@ _slpkg()
cur=${COMP_WORDS[COMP_CWORD]}
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W "--autobuild --blacklist --queue --list --check --sync --tracking --print --network --FIND --find --installpkg --upgradepkg --removepkg --display" -- $cur ))
+ COMPREPLY=( $( compgen -W "--blacklist --queue --list --check --sync --tracking --print --FIND --find --installpkg --upgradepkg --removepkg --display" -- $cur ))
else
_filedir
diff --git a/conf/slpkg.fish b/conf/slpkg.fish
index 3bcaa55f..6b80d70b 100644
--- a/conf/slpkg.fish
+++ b/conf/slpkg.fish
@@ -1,6 +1,5 @@
complete --command slpkg --long-option help --short-option h --description 'Print this help message and exit.'
complete --command slpkg --long-option version --short-option v --description 'Print program version and exit.'
-complete --command slpkg --long-option autobuild --short-option a --description 'Auto build SBo packages. If you already have downloaded the script and the source code you can build a new package with this command.'
complete --command slpkg --long-option blacklist --short-option b --description 'Manage packages in the blacklist. Add or remove packages and print the list. Each package is added here will not be accessible by the program.'
complete --command slpkg --long-option queue --short-option q --description 'Manage SBo packages in the queue. Add or remove and print the list build-install of packages. Build and then install the packages from the queue.'
complete --command slpkg --long-option config --short-option g --description 'Configuration file management. Print the configuration file or edit.'
@@ -9,7 +8,6 @@ complete --command slpkg --long-option check --short-option c --description 'Che
complete --command slpkg --long-option sync --short-option s --description 'Sync packages. Install packages directly from remote repositories with all dependencies.'
complete --command slpkg --long-option tracking --short-option t --description 'Tracking package dependencies and print package dependenies tree with highlight if packages is installed.'
complete --command slpkg --long-option print --short-option p --description 'Print description of a package directly from the repository and change color text.'
-complete --command slpkg --long-option network --short-option n --description 'View a standard of SBo page in terminal and manage multiple options like reading downloading building installation etc.'
complete --command slpkg --long-option find --short-option f --description 'Find and print installed packages reporting the size and the sum.'
complete --command slpkg --long-option FIND --short-option F --description 'Find packages from repositories and search at each enabled repository and prints results.'
complete --command slpkg --long-option installpkg --short-option i --description 'Installs single or multiple Slackware binary packages.'
diff --git a/man/slpkg.8 b/man/slpkg.8
index bfd16472..2e1cefd1 100644
--- a/man/slpkg.8
+++ b/man/slpkg.8
@@ -257,19 +257,6 @@ Additional options:
.PP
\fB--third-party\fP : View all the third-party packages.
-.SS -n, --network, view SBo packages
-\fBslpkg\fP \fB-n\fP <\fIname of package\fP>, <\fI[pattern], --checklist\fP>, \fB--case-ins\fP
-.PP
-View complete slackbuilds.org site in your terminal. Read file, download,
-build or install etc. Use "--checklist" additional option to load all repository, example:
-"# slpkg -n --checklist".
-.PP
-Additional options:
-.PP
-\fB--checklist\fP : Enable dialog utility and checklist option. (Require python3-pythondialog)
-.PP
-\fB--case-ins\fP : Search package name in repository with case insensitive.
-
.SS -i, --installpkg, install Slackware binary packages
\fBslpkg\fP \fB-i\fP \fB[--warn, --md5sum, --root /otherroot, --infobox, --menu, --terse,
--ask, --priority ADD|REC|OPT|SKP, --tagfile /somedir/tagfile]\fP <\fIpackages.t?z\fP>
diff --git a/man/slpkg.html b/man/slpkg.html
index b8bdc38b..d6e624d0 100644
--- a/man/slpkg.html
+++ b/man/slpkg.html
@@ -470,29 +470,6 @@ options:
--third-party
: View all the third-party packages.
--n,
---network, view SBo packages
-slpkg -n <name of package>,
-<[pattern], --checklist>, --case-ins
-
-View complete
-slackbuilds.org site in your terminal. Read file, download,
-build or install etc. Use "--checklist" additional
-option to load all repository, example: "# slpkg -n
---checklist".
-
-Additional
-options:
-
-
---checklist
-: Enable dialog utility and checklist option. (Require
-python3-pythondialog)
-
-
---case-ins
-: Search package name in repository with case
-insensitive.
-i,
--installpkg, install Slackware binary packages
diff --git a/slpkg/arguments.py b/slpkg/arguments.py
index d1ab2989..31ceb221 100644
--- a/slpkg/arguments.py
+++ b/slpkg/arguments.py
@@ -126,11 +126,6 @@ Optional arguments:
--color=[] directly from the repository and
change color text.
- -n | --network, [package], --checklist, View a standard of SBo page in
- --case-ins terminal and manage multiple
- options like reading, downloading,
- building, installation, etc.
-
-F | --FIND, [package...], --case-ins Find packages from each enabled
repository and view results.
@@ -197,7 +192,6 @@ def usage(repo, stderr):
[-t [repository] [package], --check-deps, --graph=[type],
--case-ins]
[-p [repository] [package], --color=[]]
- [-n [SBo package], --checklist, --case-ins]
[-F [package...], --case-ins]
[-f [package...], --case-ins, --third-party]
[-i [options] [package...]]
diff --git a/slpkg/main.py b/slpkg/main.py
index b61f419b..3c35e93b 100644
--- a/slpkg/main.py
+++ b/slpkg/main.py
@@ -57,7 +57,6 @@ from slpkg.pkg.manager import PackageManager
from slpkg.sbo.queue import QueuePkgs
from slpkg.sbo.check import sbo_upgrade
-from slpkg.sbo.network import SBoNetwork
from slpkg.sbo.slackbuild import SBoInstall
from slpkg.slack.patches import Patches
@@ -509,40 +508,6 @@ class ArgParse:
else:
usage("", 1)
- def sbo_network(self):
- """Views slackbuilds packages
- """
- flag = []
- options = [
- "-n",
- "--network"
- ]
- additional_options = [
- "--checklist",
- "--case-ins"
- ]
-
- for add in additional_options:
-
- if add in self.args:
- flag.append(add)
- self.args.remove(add)
-
- if "--checklist" in flag:
- self.if_checklist()
-
- if (len(self.args) == 2 and self.args[0] in options and
- "sbo" in self.meta.repositories):
- SBoNetwork(self.args[1], flag).view()
-
- elif (len(self.args) == 1 and self.args[0] in options and
- "sbo" in self.meta.repositories and
- additional_options[0] in flag):
- SBoNetwork("", flag).view()
-
- else:
- usage("sbo", 1)
-
def pkg_blacklist(self):
"""Manages blacklist packages
"""
@@ -991,8 +956,6 @@ def main():
"--sync": argparse.pkg_install,
"-t": argparse.pkg_tracking,
"--tracking": argparse.pkg_tracking,
- "-n": argparse.sbo_network,
- "--netwotk": argparse.sbo_network,
"-b": argparse.pkg_blacklist,
"--blacklist": argparse.pkg_blacklist,
"-q": argparse.pkg_queue,
diff --git a/slpkg/sbo/network.py b/slpkg/sbo/network.py
deleted file mode 100644
index 019e9a04..00000000
--- a/slpkg/sbo/network.py
+++ /dev/null
@@ -1,419 +0,0 @@
-#!/usr/bin/python3
-# -*- coding: utf-8 -*-
-
-# network.py file is part of slpkg.
-
-# Copyright 2014-2022 Dimitris Zlatanidis
-# All rights reserved.
-
-# Slpkg is a user-friendly package manager for Slackware installations
-
-# https://gitlab.com/dslackw/slpkg
-
-# Slpkg is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-
-import os
-import pydoc
-
-from slpkg.utils import Utils
-from slpkg.messages import Msg
-from slpkg.blacklist import BlackList
-from slpkg.downloader import Download
-from slpkg.remove import delete_folder
-from slpkg.dialog_box import DialogUtil
-from slpkg.security import pkg_security
-from slpkg.__metadata__ import MetaData as _meta_
-
-from slpkg.pkg.find import find_package
-from slpkg.pkg.build import BuildPackage
-from slpkg.pkg.manager import PackageManager
-
-from slpkg.sbo.read import ReadSBo
-from slpkg.sbo.queries import SboQuery
-from slpkg.sbo.sbo_arch import SBoArch
-from slpkg.sbo.compressed import SBoLink
-from slpkg.sbo.search import sbo_search_pkg
-from slpkg.sbo.slack_find import slack_package
-
-from slpkg.slack.slack_version import slack_ver
-
-
-class SBoNetwork(Utils):
- """View SBo site in the terminal and also read, build or
- install packages
- """
- def __init__(self, name, flag):
- super().__init__()
- self.name = name
- self.flag = flag
- self.meta = _meta_
- self.msg = Msg()
- self.data = SboQuery(name="").names()
- self.check_pkg_exist()
- self.arch = SBoArch().get()
- self.comp_tar = ".tar.gz"
- self.choice = ""
- self.FAULT = ""
- self.green = self.meta.color["GREEN"]
- self.red = self.meta.color["RED"]
- self.yellow = self.meta.color["YELLOW"]
- self.cyan = self.meta.color["CYAN"]
- self.grey = self.meta.color["GREY"]
- self.endc = self.meta.color["ENDC"]
- self.build_folder = self.meta.build_path
- self._SOURCES = self.meta.SBo_SOURCES
- self.msg.reading()
- self.case_insensitive()
-
- if "--checklist" in self.flag:
- self.with_checklist()
-
- grep = SboQuery(self.name)
-
- self.sbo_files = grep.files()
- self.sbo_url = sbo_search_pkg(self.name)
-
- if self.sbo_url:
- self.sbo_desc = grep.description()[len(self.name) + 2:-1]
- self.source_dwn = grep.source().split()
- self.sbo_req = grep.requires()
- self.sbo_dwn = SBoLink(self.sbo_url).tar_gz()
- self.sbo_version = grep.version()
- self.dwn_srcs = self.sbo_dwn.split() + self.source_dwn
-
- if "--checklist" not in self.flag or not self.sbo_url and self.name:
- self.msg.done()
-
- def check_pkg_exist(self):
- if self.name not in self.data:
- self.msg.pkg_not_found("\n", self.name, "can't find", "\n")
- raise SystemExit(1)
-
- def view(self):
- """View SlackBuild package, read or install them
- from slackbuilds.org
- """
- if self.sbo_url and self.name not in BlackList().get():
- self.prgnam = f"{self.name}-{self.sbo_version}"
- self.view_sbo()
-
- while True:
-
- self.read_choice()
-
- choice = {
- "r": self.choice_README,
- "R": self.choice_README,
- "s": self.choice_SlackBuild,
- "S": self.choice_SlackBuild,
- "f": self.choice_info,
- "F": self.choice_info,
- "o": self.choice_doinst,
- "O": self.choice_doinst,
- "d": self.choice_download,
- "D": self.choice_download,
- "download": self.choice_download,
- "b": self.choice_build,
- "B": self.choice_build,
- "build": self.choice_build,
- "i": self.choice_install,
- "I": self.choice_install,
- "install": self.choice_install,
- "c": self.choice_clear_screen,
- "C": self.choice_clear_screen,
- "clear": self.choice_clear_screen,
- "q": self.choice_quit,
- "quit": self.choice_quit,
- "Q": self.choice_quit
- }
-
- try:
- choice[self.choice]()
- except KeyError:
- pass
-
- else:
- self.msg.pkg_not_found("\n", self.name, "Can't view", "\n")
- raise SystemExit(1)
-
- def case_insensitive(self):
- """Matching packages distinguish between uppercase and
- lowercase
- """
-
- if "--case-ins" in self.flag:
- data_dict = self.case_sensitive(self.data)
-
- for key, value in data_dict.items():
-
- if key == self.name.lower():
- self.name = value
-
- def read_choice(self):
- """Return choice
- """
- commands = {
- "r": "README",
- "R": "README",
- "s": f"{self.name}.SlackBuild",
- "S": f"{self.name}.SlackBuild",
- "f": f"{self.name}.info",
- "F": f"{self.name}.info",
- "o": "doinst.sh",
- "O": "doinst.sh",
- "d": "download",
- "D": "download",
- "download": "download",
- "b": "build",
- "B": "build",
- "build": "build",
- "i": "install",
- "I": "install",
- "install": "install",
- "c": "clear",
- "C": "clear",
- "clear": "clear",
- "q": "quit",
- "quit": "quit",
- "Q": "quit"
- }
-
- try:
- message = " Choose an option > "
- self.choice = input(f"{self.grey}{message}{self.endc}")
- except EOFError:
- raise SystemExit('\n')
-
- try:
- print("{0}\x1b[1A{1}{2}{3}\n".format(
- " " * len(message), self.cyan, commands[self.choice],
- self.endc), end="")
- print(end="", flush=True)
- except KeyError:
- pass
-
- def choice_README(self):
- """View README file
- """
- README = ReadSBo(self.sbo_url).readme("README")
- fill = self.fill_pager(README)
- self.pager(README + fill)
-
- def choice_SlackBuild(self):
- """View .SlackBuild file
- """
- SlackBuild = ReadSBo(self.sbo_url).slackbuild(self.name, ".SlackBuild")
- fill = self.fill_pager(SlackBuild)
- self.pager(SlackBuild + fill)
-
- def choice_info(self):
- """View .info file
- """
- info = ReadSBo(self.sbo_url).info(self.name, ".info")
- fill = self.fill_pager(info)
- self.pager(info + fill)
-
- def choice_doinst(self):
- """View doinst.sh file
- """
- if "doinst.sh" in self.sbo_files.split():
- doinst_sh = ReadSBo(self.sbo_url).doinst("doinst.sh")
- fill = self.fill_pager(doinst_sh)
- self.pager(doinst_sh + fill)
-
- def choice_download(self):
- """Download script.tar.gz and sources
- """
- Download(path="", url=self.dwn_srcs, repo="sbo").start()
- raise SystemExit()
-
- def choice_build(self):
- """Build package
- """
- self.build()
- delete_folder(self.build_folder)
- raise SystemExit()
-
- def choice_install(self):
- """Download, build and install the package
- """
- pkg_security([self.name])
-
- if not find_package(self.prgnam, self.meta.pkg_path):
- self.build()
- self.install()
- delete_folder(self.build_folder)
-
- raise SystemExit()
-
- else:
- self.msg.template(78)
- self.msg.pkg_found(self.prgnam)
- self.msg.template(78)
-
- raise SystemExit()
-
- def choice_clear_screen(self):
- """Clear screen
- """
- os.system("clear")
- self.view()
-
- def choice_quit(self):
- """Quit from choices
- """
- raise SystemExit()
-
- def view_sbo(self):
- """View slackbuild.org
- """
- sbo_url = self.sbo_url.replace("/slackbuilds/", "/repository/")
- br1, br2, fix_sp = "", "", " "
-
- if self.meta.use_colors in ["off", "OFF"]:
- br1 = "("
- br2 = ")"
- fix_sp = ""
-
- print() # new line at start
- self.msg.template(78)
- print(f"| {' ' * 28}{self.grey}SlackBuilds Repository{self.endc}")
- self.msg.template(78)
- print(f"| {slack_ver()} > {sbo_url.split('/')[-3].title()} > {self.cyan}{self.name}{self.endc}")
- self.msg.template(78)
- print(f"| {self.green}Package url{self.endc}: {sbo_url}")
- self.msg.template(78)
- print(f"| {self.green}Description: {self.endc}{self.sbo_desc}")
- print(f"| {self.green}SlackBuild: {self.endc}{self.sbo_dwn.split('/')[-1]}")
- print(f"| {self.green}Sources: {self.endc}{', '.join([src.split('/')[-1] for src in self.source_dwn])}")
- print(f"| {self.yellow}Requirements: {self.endc}{', '.join(self.sbo_req)}")
- self.msg.template(78)
- print(f"| {self.red}R{self.endc}{br2}EADME View the README file")
- print(f"| {self.red}S{self.endc}{br2}lackBuild View the .SlackBuild file")
- print(f"| In{br1}{self.red}f{self.endc}{br2}o{fix_sp} View the .info file")
-
- if "doinst.sh" in self.sbo_files.split():
- print(f"| D{br1}{self.red}o{self.endc}{br2}inst.sh{fix_sp} View the doinst.sh file")
-
- print(f"| {self.red}D{self.endc}{br2}ownload Download this package")
- print(f"| {self.red}B{self.endc}{br2}uild Download and build")
- print(f"| {self.red}I{self.endc}{br2}nstall Download/Build/Install")
- print(f"| {self.red}C{self.endc}{br2}lear Clear screen")
- print(f"| {self.red}Q{self.endc}{br2}uit Quit")
- self.msg.template(78)
-
- def with_checklist(self):
- """Using dialog and checklist option
- """
- data = []
-
- if not self.name:
- data = self.data
-
- else:
- for name in self.data:
- if self.name in name:
- data.append(name)
-
- if data:
- text = "Press 'spacebar' to choose SlackBuild for view"
- title = " SlackBuilds.org "
- backtitle = f"{_meta_.__all__} {_meta_.__version__}"
- status = False
- pkg = DialogUtil(data, text, title, backtitle, status).checklist()
-
- if pkg and len(pkg) > 1:
- os.system("clear")
- raise SystemExit("\nslpkg: Error: Choose only one package\n")
-
- if pkg is None:
- raise SystemExit(1)
-
- self.name = "".join(pkg)
- os.system("clear")
-
- def pager(self, text):
- """Read text
- """
- pydoc.pager(text)
-
- def fill_pager(self, page):
- """Fixes pager spaces
- """
- tty_size = os.popen("stty size", "r").read().split()
- rows = int(tty_size[0]) - 1
- lines = sum(1 for line in page.splitlines())
- diff = rows - lines
- fill = "\n" * diff
-
- if diff > 0:
- return fill
-
- else:
- return ""
-
- def error_uns(self):
- """Checks if the package supported by an arch
- before proceeding to install
- """
- self.FAULT = ""
- UNST = ["UNSUPPORTED", "UNTESTED"]
-
- if "".join(self.source_dwn) in UNST:
- self.FAULT = "".join(self.source_dwn)
-
- def build(self):
- """Builds slackware package
- """
- pkg_security([self.name])
- self.error_uns()
-
- if self.FAULT:
- print()
- self.msg.template(78)
- print(f"| Package {self.prgnam} {self.red} {self.FAULT} "
- f"{self.endc}")
- self.msg.template(78)
-
- else:
- sources = []
-
- if not os.path.exists(self.meta.build_path):
- os.makedirs(self.meta.build_path)
-
- if not os.path.exists(self._SOURCES):
- os.makedirs(self._SOURCES)
-
- os.chdir(self.meta.build_path)
-
- Download(self.meta.build_path, self.sbo_dwn.split(),
- repo="sbo").start()
-
- Download(self._SOURCES, self.source_dwn, repo="sbo").start()
-
- script = self.sbo_dwn.split("/")[-1]
-
- for src in self.source_dwn:
- sources.append(src.split("/")[-1])
-
- BuildPackage(script, sources, self.meta.build_path,
- auto=False).build()
-
- slack_package(self.prgnam) # check if build
-
- def install(self):
- """Installs SBo package found in /tmp directory.
- """
- binary = slack_package(self.prgnam)
- print(f"[ {self.green}Installing{self.endc} ] --> {self.name}")
- PackageManager(binary).upgrade(flag="--install-new")
From 1e59c78dcc0451386cabdcee69490be9b1a79367 Mon Sep 17 00:00:00 2001
From: Dimitris Zlatanidis
Date: Thu, 2 Jun 2022 12:42:56 +0300
Subject: [PATCH 23/25] Added alien table
---
slpkg/binaries/check.py | 2 +-
slpkg/binaries/dependency.py | 2 +-
slpkg/binaries/install.py | 2 +-
slpkg/binaries/{greps.py => queries.py} | 0
slpkg/init.py | 24 ++++++++----
slpkg/models/data.py | 50 +++++++++++++++++++++++--
slpkg/models/models.py | 15 ++++++++
slpkg/slack/patches.py | 2 +-
slpkg/slack/slackware_repo.py | 2 +-
9 files changed, 82 insertions(+), 17 deletions(-)
rename slpkg/binaries/{greps.py => queries.py} (100%)
diff --git a/slpkg/binaries/check.py b/slpkg/binaries/check.py
index 418b763b..09b14f3f 100644
--- a/slpkg/binaries/check.py
+++ b/slpkg/binaries/check.py
@@ -31,7 +31,7 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
-from slpkg.binaries.greps import repo_data
+from slpkg.binaries.queries import repo_data
from slpkg.binaries.repo_init import RepoInit
diff --git a/slpkg/binaries/dependency.py b/slpkg/binaries/dependency.py
index 64bcee6f..d0159f61 100644
--- a/slpkg/binaries/dependency.py
+++ b/slpkg/binaries/dependency.py
@@ -27,7 +27,7 @@ from functools import lru_cache
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.blacklist import BlackList
-from slpkg.binaries.greps import Requires
+from slpkg.binaries.queries import Requires
class Dependencies:
diff --git a/slpkg/binaries/install.py b/slpkg/binaries/install.py
index 2ce9aa72..4ff06aea 100644
--- a/slpkg/binaries/install.py
+++ b/slpkg/binaries/install.py
@@ -43,7 +43,7 @@ from slpkg.pkg.find import find_package
from slpkg.pkg.manager import PackageManager
from slpkg.pkg.installed import GetFromInstalled
-from slpkg.binaries.greps import repo_data
+from slpkg.binaries.queries import repo_data
from slpkg.binaries.repo_init import RepoInit
from slpkg.binaries.dependency import Dependencies
diff --git a/slpkg/binaries/greps.py b/slpkg/binaries/queries.py
similarity index 100%
rename from slpkg/binaries/greps.py
rename to slpkg/binaries/queries.py
diff --git a/slpkg/init.py b/slpkg/init.py
index 37f2f076..a9311d70 100644
--- a/slpkg/init.py
+++ b/slpkg/init.py
@@ -34,7 +34,7 @@ from slpkg.__metadata__ import MetaData as _meta_
from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver
-from slpkg.models.models import SBoTable, session
+from slpkg.models.models import SBoTable, AlienTable, session
class Init(Utils):
@@ -527,9 +527,7 @@ class Init(Utils):
self.down(lib_path, FILELIST_TXT, repo)
self.down(log_path, ChangeLog_txt, repo)
- if repo == 'sbo':
- self.session.query(SBoTable).delete() # delete all data
- self.session.commit()
+ delete_table_data(repo)
def merge(self, path, outfile, infiles):
"""Merging files
@@ -612,10 +610,7 @@ class Upgrade:
update = Update()
update.run(repos)
- def del_tables(self, repo):
- if repo == 'sbo':
- self.session.query(SBoTable).delete() # delete all data
- self.session.commit()
+ delete_table_data(repo)
class Update:
@@ -675,12 +670,25 @@ class Update:
if self.session.query(SBoTable).first() is None:
db.insert_sbo_table()
+ if self.session.query(AlienTable).first() is None:
+ db.insert_alien_table()
+
def done_msg(self, repo):
print(f"{self.grey}Checking repository "
f"[{self.cyan}{repo}{self.grey}] ... "
f"{self.endc}", end="", flush=True)
+def delete_table_data(repo):
+ if repo == 'sbo':
+ session.query(SBoTable).delete()
+ session.commit()
+
+ if repo == 'alien':
+ session.query(AlienTable).delete()
+ session.commit()
+
+
def check_exists_repositories(repo):
"""Checking if repositories exists by PACKAGES.TXT file
"""
diff --git a/slpkg/models/data.py b/slpkg/models/data.py
index 53fcf214..3f6c11bd 100644
--- a/slpkg/models/data.py
+++ b/slpkg/models/data.py
@@ -24,7 +24,7 @@
from progress.bar import Bar
from slpkg.__metadata__ import MetaData as _meta_
-from slpkg.models.models import SBoTable, session
+from slpkg.models.models import SBoTable, AlienTable, session
class Database:
@@ -33,6 +33,21 @@ class Database:
self.lib_path = _meta_.lib_path
self.session = session
+ self.pkg_tags = [
+ "PACKAGE NAME:",
+ "PACKAGE LOCATION:",
+ "PACKAGE SIZE (compressed):",
+ "PACKAGE SIZE (uncompressed):",
+ "PACKAGE REQUIRED:",
+ "PACKAGE CONFLICTS:",
+ "PACKAGE SUGGESTS:",
+ "PACKAGE DESCRIPTION:"
+ ]
+
+ def open_file(self, file):
+ with open(file, "r", encoding="utf-8") as f:
+ return f.readlines()
+
def insert_sbo_table(self):
"""Grabbing data line by line and inserting them into the database
"""
@@ -80,6 +95,33 @@ class Database:
self.session.commit()
- def open_file(self, file):
- with open(file, "r", encoding="utf-8") as f:
- return f.readlines()
+ def insert_alien_table(self):
+ pkg_file = self.open_file(f"{self.lib_path}alien_repo/PACKAGES.TXT")
+
+ bar = Bar("Creating alien database", max=len(pkg_file),
+ suffix="%(percent)d%% - %(eta)ds")
+
+ cache = [] # init cache
+
+ for i, line in enumerate(pkg_file, 1):
+
+ for p in self.pkg_tags:
+ if line.startswith(p):
+ line = line.replace(p, "").strip()
+ cache.append(line)
+
+ if (i % 20) == 0:
+ data = AlienTable(name=cache[0],
+ location=cache[1][2:],
+ comp_size=cache[2][:-2],
+ uncomp_size=cache[3][:-2],
+ required=cache[4], conflicts=cache[5],
+ suggests=cache[6], description=cache[7])
+ self.session.add(data)
+
+ cache = [] # reset cache after 11 lines
+
+ bar.next()
+ bar.finish()
+
+ self.session.commit()
diff --git a/slpkg/models/models.py b/slpkg/models/models.py
index 5dfd0958..a278b0d5 100644
--- a/slpkg/models/models.py
+++ b/slpkg/models/models.py
@@ -55,4 +55,19 @@ class SBoTable(Base):
short_description = Column(Text)
+class AlienTable(Base):
+
+ __tablename__ = "alientable"
+
+ id = Column(Integer, primary_key=True)
+ name = Column(Text)
+ location = Column(Text)
+ comp_size = Column(Integer)
+ uncomp_size = Column(Integer)
+ required = Column(Text)
+ conflicts = Column(Text)
+ suggests = Column(Text)
+ description = Column(Text)
+
+
Base.metadata.create_all(engine)
diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py
index d7d27b3e..df8e1a80 100644
--- a/slpkg/slack/patches.py
+++ b/slpkg/slack/patches.py
@@ -46,7 +46,7 @@ from slpkg.pkg.find import find_package
from slpkg.pkg.manager import PackageManager
from slpkg.pkg.installed import GetFromInstalled
-from slpkg.binaries.greps import repo_data
+from slpkg.binaries.queries import repo_data
from slpkg.slack.mirrors import mirrors
from slpkg.slack.slack_version import slack_ver
diff --git a/slpkg/slack/slackware_repo.py b/slpkg/slack/slackware_repo.py
index 06564934..1234e520 100644
--- a/slpkg/slack/slackware_repo.py
+++ b/slpkg/slack/slackware_repo.py
@@ -23,7 +23,7 @@
from slpkg.utils import Utils
-from slpkg.binaries.greps import repo_data
+from slpkg.binaries.queries import repo_data
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_
From 91a2016026b86da28ba7c4452ff5c9d4f0ef124a Mon Sep 17 00:00:00 2001
From: Dimitris Zlatanidis
Date: Thu, 2 Jun 2022 12:58:06 +0300
Subject: [PATCH 24/25] Removed unused
---
slpkg/sbo/queries.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/slpkg/sbo/queries.py b/slpkg/sbo/queries.py
index 387b182a..f090bc69 100644
--- a/slpkg/sbo/queries.py
+++ b/slpkg/sbo/queries.py
@@ -22,18 +22,16 @@
# along with this program. If not, see .
-from slpkg.utils import Utils
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.models.models import SBoTable, session
-class SboQuery(Utils):
+class SboQuery:
"""Grabs data from sbo database
"""
def __init__(self, name):
self.name = name
self.meta = _meta_
- self.db = self.meta.db
self.arch64 = "x86_64"
self.session = session
From 7927e3e7eee895af36aa15cc5dcd1c78f2c1af4d Mon Sep 17 00:00:00 2001
From: Dimitris Zlatanidis
Date: Thu, 2 Jun 2022 15:39:03 +0300
Subject: [PATCH 25/25] Added package query
---
slpkg/binaries/queries.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py
index 16adad7b..2f431655 100644
--- a/slpkg/binaries/queries.py
+++ b/slpkg/binaries/queries.py
@@ -27,6 +27,21 @@ from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.slack.slack_version import slack_ver
+from slpkg.models.models import AlienTable, session
+
+
+class PkgQuery:
+
+ def __init__(self, name):
+ self.name = name
+ self.session = session
+
+ def location(self):
+
+ location = self.session.query(AlienTable).filter(
+ AlienTable.location == self.name).first()
+
+ return location[0]
def repo_data(PACKAGES_TXT, repo, flag):
@@ -36,7 +51,6 @@ def repo_data(PACKAGES_TXT, repo, flag):
rname, rlocation, rsize, runsize) = ([] for i in range(8))
for line in PACKAGES_TXT.splitlines():
-
if line.startswith("PACKAGE NAME:"):
name.append(line[15:].strip())