mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Added table for ponce
This commit is contained in:
parent
db9eb8d2bf
commit
867a8894f7
8 changed files with 85 additions and 44 deletions
|
@ -24,7 +24,7 @@
|
|||
ASCII_CHARACTERS = true
|
||||
|
||||
# SLACKBUILDS.ORG REPOSITORY CONFIGS.
|
||||
SBO_REPO_PATH = "/var/lib/slpkg/repository/"
|
||||
SBO_REPO_PATH = "/var/lib/slpkg/repository/sbo/"
|
||||
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
|
||||
SBO_TXT = "SLACKBUILDS.TXT"
|
||||
SBO_CHGLOG_TXT = "ChangeLog.txt"
|
||||
|
|
|
@ -41,13 +41,13 @@ class Configs:
|
|||
lib_path: str = Path('/var/lib/', prog_name) # type: ignore
|
||||
etc_path: str = Path('/etc/', prog_name) # type: ignore
|
||||
db_path: str = Path(lib_path, 'database') # type: ignore
|
||||
sbo_repo_path: str = Path(lib_path, 'repository') # type: ignore
|
||||
log_packages: str = Path('/var', 'log', 'packages') # type: ignore
|
||||
|
||||
# Database name.
|
||||
database_name: str = f'database.{prog_name}'
|
||||
|
||||
# SBo repository configs.
|
||||
sbo_repo_path: str = Path(lib_path, 'repository', 'sbo') # type: ignore
|
||||
sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0/'
|
||||
sbo_txt: str = 'SLACKBUILDS.TXT'
|
||||
sbo_chglog_txt: str = 'ChangeLog.txt'
|
||||
|
|
|
@ -6,8 +6,8 @@ from slpkg.configs import Configs
|
|||
from slpkg.views.ascii import Ascii
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import SBoTable, PonceTable
|
||||
|
||||
|
||||
class Dependees(Configs, Utilities):
|
||||
|
@ -36,6 +36,11 @@ class Dependees(Configs, Utilities):
|
|||
self.flag_full_reverse: list = ['-E', '--full-reverse']
|
||||
self.flag_pkg_version: list = ['-p', '--pkg-version']
|
||||
|
||||
# Switch between sbo and ponce repository.
|
||||
self.sbo_table = SBoTable
|
||||
if self.ponce_repo:
|
||||
self.sbo_table = PonceTable
|
||||
|
||||
def slackbuilds(self):
|
||||
""" Collecting the dependees. """
|
||||
print(f"The list below shows the "
|
||||
|
@ -79,7 +84,7 @@ class Dependees(Configs, Utilities):
|
|||
|
||||
def find_requires(self, sbo: str) -> Generator[str, None, None]:
|
||||
""" Find requires that slackbuild dependees. """
|
||||
requires: list = self.session.query(SBoTable.name, SBoTable.requires).all() # type: ignore
|
||||
requires: list = self.session.query(self.sbo_table.name, self.sbo_table.requires).all() # type: ignore
|
||||
for req in requires:
|
||||
if [r for r in req[1].split() if r == sbo]:
|
||||
yield req
|
||||
|
|
|
@ -8,8 +8,8 @@ from slpkg.queries import SBoQueries
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import SBoTable, PonceTable
|
||||
|
||||
|
||||
class CreateData(Configs):
|
||||
|
@ -36,7 +36,13 @@ class CreateData(Configs):
|
|||
'SLACKBUILD REQUIRES:',
|
||||
'SLACKBUILD SHORT DESCRIPTION:'
|
||||
]
|
||||
sbo_table = SBoTable
|
||||
path = Path(self.sbo_repo_path, self.sbo_txt)
|
||||
|
||||
if self.ponce_repo:
|
||||
sbo_table = PonceTable
|
||||
path = Path(self.ponce_repo_path, self.ponce_txt)
|
||||
|
||||
sbo_file: list = self.read_file(path)
|
||||
|
||||
cache: list = [] # init cache
|
||||
|
@ -51,7 +57,7 @@ class CreateData(Configs):
|
|||
cache.append(line)
|
||||
|
||||
if (i % 11) == 0:
|
||||
data: str = SBoTable(name=cache[0], location=cache[1].split('/')[1],
|
||||
data: str = sbo_table(name=cache[0], location=cache[1].split('/')[1],
|
||||
files=cache[2], version=cache[3],
|
||||
download=cache[4], download64=cache[5],
|
||||
md5sum=cache[6], md5sum64=cache[7],
|
|
@ -38,6 +38,25 @@ class SBoTable(Base):
|
|||
short_description: str = Column(Text) # type: ignore
|
||||
|
||||
|
||||
@dataclass
|
||||
class PonceTable(Base):
|
||||
""" The main table for the SBo repository. """
|
||||
|
||||
__tablename__ = 'poncetable'
|
||||
|
||||
id: int = Column(Integer, primary_key=True) # type: ignore
|
||||
name: str = Column(Text) # type: ignore
|
||||
location: str = Column(Text) # type: ignore
|
||||
files: str = Column(Text) # type: ignore
|
||||
version: str = Column(Text) # type: ignore
|
||||
download: str = Column(Text) # type: ignore
|
||||
download64: str = Column(Text) # type: ignore
|
||||
md5sum: str = Column(Text) # type: ignore
|
||||
md5sum64: str = Column(Text) # type: ignore
|
||||
requires: str = Column(Text) # type: ignore
|
||||
short_description: str = Column(Text) # type: ignore
|
||||
|
||||
|
||||
@dataclass
|
||||
class LogsDependencies(Base):
|
||||
""" The table that stores the dependencies after installing a package. """
|
||||
|
|
|
@ -5,8 +5,8 @@ from typing import Union
|
|||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.blacklist import Blacklist
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import SBoTable, PonceTable
|
||||
|
||||
|
||||
class SBoQueries(Configs):
|
||||
|
@ -21,15 +21,20 @@ class SBoQueries(Configs):
|
|||
if self.name in self.black.packages():
|
||||
self.name: str = ''
|
||||
|
||||
# Switch between sbo and ponce repository.
|
||||
self.sbo_table = SBoTable
|
||||
if self.ponce_repo:
|
||||
self.sbo_table = PonceTable
|
||||
|
||||
def sbos(self) -> list:
|
||||
""" Returns all the slackbuilds. """
|
||||
sbos: tuple = self.session.query(SBoTable.name).all() # type: ignore
|
||||
sbos: tuple = self.session.query(self.sbo_table.name).all() # type: ignore
|
||||
return [sbo[0] for sbo in sbos]
|
||||
|
||||
def slackbuild(self) -> str:
|
||||
""" Returns a slackbuild. """
|
||||
sbo: tuple = self.session.query(
|
||||
SBoTable.name).filter(SBoTable.name == self.name).first() # type: ignore
|
||||
self.sbo_table.name).filter(self.sbo_table.name == self.name).first() # type: ignore
|
||||
|
||||
if sbo:
|
||||
return sbo[0]
|
||||
|
@ -38,7 +43,7 @@ class SBoQueries(Configs):
|
|||
def location(self) -> str:
|
||||
""" Returns the category of a slackbuild. """
|
||||
location: tuple = self.session.query(
|
||||
SBoTable.location).filter(SBoTable.name == self.name).first() # type: ignore
|
||||
self.sbo_table.location).filter(self.sbo_table.name == self.name).first() # type: ignore
|
||||
|
||||
if location:
|
||||
return location[0]
|
||||
|
@ -47,8 +52,8 @@ class SBoQueries(Configs):
|
|||
def sources(self) -> list:
|
||||
""" Returns the source of a slackbuild. """
|
||||
source, source64 = self.session.query(
|
||||
SBoTable.download, SBoTable.download64).filter( # type: ignore
|
||||
SBoTable.name == self.name).first()
|
||||
self.sbo_table.download, self.sbo_table.download64).filter( # type: ignore
|
||||
self.sbo_table.name == self.name).first()
|
||||
|
||||
if self.os_arch == 'x86_64' and source64:
|
||||
return source64.split()
|
||||
|
@ -58,8 +63,8 @@ class SBoQueries(Configs):
|
|||
def requires(self) -> Union[str, list]:
|
||||
""" Returns the requirements of a slackbuild. """
|
||||
requires: tuple = self.session.query( # type: ignore
|
||||
SBoTable.requires).filter( # type: ignore
|
||||
SBoTable.name == self.name).first()
|
||||
self.sbo_table.requires).filter( # type: ignore
|
||||
self.sbo_table.name == self.name).first()
|
||||
|
||||
if requires:
|
||||
requires: list = requires[0].split()
|
||||
|
@ -72,8 +77,8 @@ class SBoQueries(Configs):
|
|||
def version(self) -> str:
|
||||
""" Returns the version of a slackbuild. """
|
||||
version: tuple = self.session.query(
|
||||
SBoTable.version).filter( # type: ignore
|
||||
SBoTable.name == self.name).first()
|
||||
self.sbo_table.version).filter( # type: ignore
|
||||
self.sbo_table.name == self.name).first()
|
||||
|
||||
if version:
|
||||
return version[0]
|
||||
|
@ -82,8 +87,8 @@ class SBoQueries(Configs):
|
|||
def checksum(self) -> list:
|
||||
""" Returns the source checksum. """
|
||||
mds5, md5s64 = self.session.query(
|
||||
SBoTable.md5sum, SBoTable.md5sum64).filter( # type: ignore
|
||||
SBoTable.name == self.name).first()
|
||||
self.sbo_table.md5sum, self.sbo_table.md5sum64).filter( # type: ignore
|
||||
self.sbo_table.name == self.name).first()
|
||||
|
||||
if self.os_arch == 'x86_64' and md5s64:
|
||||
return md5s64.split()
|
||||
|
@ -93,8 +98,8 @@ class SBoQueries(Configs):
|
|||
def description(self) -> str:
|
||||
""" Returns the slackbuild description. """
|
||||
desc: tuple = self.session.query(
|
||||
SBoTable.short_description).filter( # type: ignore
|
||||
SBoTable.name == self.name).first()
|
||||
self.sbo_table.short_description).filter( # type: ignore
|
||||
self.sbo_table.name == self.name).first()
|
||||
|
||||
if desc:
|
||||
return desc[0]
|
||||
|
@ -103,8 +108,8 @@ class SBoQueries(Configs):
|
|||
def files(self) -> str:
|
||||
""" Returns the files of a slackbuild. """
|
||||
files: tuple = self.session.query(
|
||||
SBoTable.files).filter( # type: ignore
|
||||
SBoTable.name == self.name).first()
|
||||
self.sbo_table.files).filter( # type: ignore
|
||||
self.sbo_table.name == self.name).first()
|
||||
|
||||
if files:
|
||||
return files[0]
|
||||
|
|
|
@ -10,12 +10,12 @@ from multiprocessing import Process
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.downloader import Downloader
|
||||
from slpkg.create_data import CreateData
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.install_data import CreateData
|
||||
from slpkg.views.views import ViewMessage
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
from slpkg.check_updates import CheckUpdates
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import SBoTable, PonceTable
|
||||
|
||||
|
||||
class UpdateRepository(Configs, Utilities):
|
||||
|
@ -63,8 +63,6 @@ class UpdateRepository(Configs, Utilities):
|
|||
self.delete_file(self.sbo_repo_path, self.sbo_txt)
|
||||
self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt)
|
||||
|
||||
self.delete_sbo_data()
|
||||
|
||||
slackbuilds_txt: str = f'{self.sbo_repo_url}{self.sbo_txt}'
|
||||
changelog_txt: str = f'{self.sbo_repo_url}{self.sbo_chglog_txt}'
|
||||
|
||||
|
@ -74,6 +72,8 @@ class UpdateRepository(Configs, Utilities):
|
|||
down_sbo_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags)
|
||||
down_sbo_changelog.download()
|
||||
|
||||
self.delete_sbo_data()
|
||||
|
||||
print()
|
||||
data = CreateData()
|
||||
data.insert_sbo_table()
|
||||
|
@ -120,5 +120,8 @@ class UpdateRepository(Configs, Utilities):
|
|||
|
||||
def delete_sbo_data(self) -> None:
|
||||
""" Delete the table from the database. """
|
||||
if self.ponce_repo:
|
||||
self.session.query(PonceTable).delete()
|
||||
else:
|
||||
self.session.query(SBoTable).delete()
|
||||
self.session.commit()
|
||||
|
|
|
@ -6,8 +6,8 @@ import urllib3
|
|||
from slpkg.configs import Configs
|
||||
from slpkg.queries import SBoQueries
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.models.models import SBoTable
|
||||
from slpkg.models.models import session as Session
|
||||
from slpkg.models.models import SBoTable, PonceTable
|
||||
|
||||
|
||||
class ViewPackage(Configs, Utilities):
|
||||
|
@ -21,9 +21,12 @@ class ViewPackage(Configs, Utilities):
|
|||
self.session = Session
|
||||
self.flag_pkg_version: list = ['-p', '--pkg-version']
|
||||
|
||||
# Switch between sbo and ponce repository.
|
||||
self.sbo_table = SBoTable
|
||||
self.repo_url: str = self.sbo_repo_url
|
||||
self.repo_tar_suffix: str = self.sbo_tar_suffix
|
||||
if self.ponce_repo:
|
||||
self.sbo_table = PonceTable
|
||||
self.repo_url: str = self.ponce_repo_url
|
||||
self.repo_tar_suffix: str = ''
|
||||
|
||||
|
@ -40,17 +43,17 @@ class ViewPackage(Configs, Utilities):
|
|||
for package in packages:
|
||||
|
||||
info: list = self.session.query(
|
||||
SBoTable.name, # type: ignore
|
||||
SBoTable.version, # type: ignore
|
||||
SBoTable.requires, # type: ignore
|
||||
SBoTable.download, # type: ignore
|
||||
SBoTable.download64, # type: ignore
|
||||
SBoTable.md5sum, # type: ignore
|
||||
SBoTable.md5sum64, # type: ignore
|
||||
SBoTable.files, # type: ignore
|
||||
SBoTable.short_description, # type: ignore
|
||||
SBoTable.location # type: ignore
|
||||
).filter(SBoTable.name == package).first()
|
||||
self.sbo_table.name, # type: ignore
|
||||
self.sbo_table.version, # type: ignore
|
||||
self.sbo_table.requires, # type: ignore
|
||||
self.sbo_table.download, # type: ignore
|
||||
self.sbo_table.download64, # type: ignore
|
||||
self.sbo_table.md5sum, # type: ignore
|
||||
self.sbo_table.md5sum64, # type: ignore
|
||||
self.sbo_table.files, # type: ignore
|
||||
self.sbo_table.short_description, # type: ignore
|
||||
self.sbo_table.location # type: ignore
|
||||
).filter(self.sbo_table.name == package).first()
|
||||
|
||||
readme = self.http_request(f'{self.repo_url}{info[9]}/{info[0]}/README')
|
||||
|
||||
|
|
Loading…
Reference in a new issue