Updated for ponce repo

This commit is contained in:
Dimitris Zlatanidis 2023-03-03 23:33:57 +02:00
parent 43341cab90
commit 915cc201e9
5 changed files with 77 additions and 138 deletions

View file

@ -1,100 +1,70 @@
[CONFIGS] [CONFIGS]
# OS architecture by default. # OS architecture by default.
OS_ARCH = "x86_64" OS_ARCH = "x86_64"
# Tmp path for slpkg. # Tmp path for slpkg.
TMP_SLPKG = "/tmp/slpkg/" TMP_SLPKG = "/tmp/slpkg/"
# Path for building source and the script. # Path for building source and the script.
BUILD_PATH = "/tmp/slpkg/build/" BUILD_PATH = "/tmp/slpkg/build/"
# This path working only with the command download.
DOWNLOAD_ONLY_PATH = "/tmp/slpkg/"
# The path that the SLACKBUILDS.TXT file downloaded.
SBO_REPO_PATH = "/var/lib/slpkg/repository/"
# The name of the database. Default name is 'database.slpkg'. # The name of the database. Default name is 'database.slpkg'.
DATABASE_NAME = "database.slpkg" DATABASE_NAME = "database.slpkg"
# This path working only with the command download.
# Slackbuilds.org repository url. DOWNLOAD_ONLY_PATH = "/tmp/slpkg/"
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
# The SLACKBUILDS.TXT repository file.
SBO_TXT = "SLACKBUILDS.TXT"
# The ChangeLog.txt file.
SBO_CHGLOG_TXT = "ChangeLog.txt"
# The sbo tar suffix.
SBO_TAR_SUFFIX = ".tar.gz"
# The sbo repository tag.
SBO_REPO_TAG = "_SBo"
# Slackware command for install packages, instead, you can use 'installpkg'.
INSTALLPKG = "upgradepkg --install-new"
# Slackware command to reinstall packages.
REINSTALL = "upgradepkg --reinstall"
# Slackware command to remove packages.
REMOVEPKG = "removepkg"
# Cli menu colors configs. Default is true. [true/false]. # Cli menu colors configs. Default is true. [true/false].
COLORS = true COLORS = true
# Dialog is a program that will let you to presenta variety of questions # Dialog is a program that will let you to presenta variety of questions
# or display messages using dialog boxes from a shell script. # or display messages using dialog boxes from a shell script.
# Default is true. [true/false]. # Default is true. [true/false].
DIALOG = true DIALOG = true
# If silent mode is true, it does not print the commands as they are executed.
# Default is true. [true/false].
SILENT_MODE = true
# Choose ascii printable characters.
# If true, it uses the extended characters, otherwise the basic ones.
# Default is true. [true/false].
ASCII_CHARACTERS = true
# SLACKBUILDS.ORG REPOSITORY CONFIGS.
SBO_REPO_PATH = "/var/lib/slpkg/repository/"
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
SBO_TXT = "SLACKBUILDS.TXT"
SBO_CHGLOG_TXT = "ChangeLog.txt"
SBO_TAR_SUFFIX = ".tar.gz"
SBO_REPO_TAG = "_SBo"
# PONCE REPOSITORY CONFIGS.
# Set the 'PONCE_REPO = true' and 'DOWNLOADER = lftp' to switch with
# the ponce repository. Do not unset SBO_REPO_URL and SBO_TXT.
# NOTE: Ponce repository works only with 'lftp' downloader.
# Default is false. [true/false].
PONCE_REPO = false
PONCE_REPO_PATH = "/var/lib/slpkg/repository/ponce/"
PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain/"
PONCE_TXT = "SLACKBUILDS.TXT"
PONCE_CHGLOG_TXT = "ChangeLog.txt"
PONCE_REPO_TAG = "_SBo"
# Slackware command for install packages, instead, you can use 'installpkg'.
INSTALLPKG = "upgradepkg --install-new"
# Slackware command to reinstall packages.
REINSTALL = "upgradepkg --reinstall"
# Slackware command to remove packages.
REMOVEPKG = "removepkg"
# You can choose downloader between wget and curl. # You can choose downloader between wget and curl.
# Ponce repository works only with 'lftp' downloader. # Ponce repository works only with 'lftp' downloader.
# Default is wget. [wget/curl/lftp]. # Default is wget. [wget/curl/lftp].
DOWNLOADER = "wget" DOWNLOADER = "wget"
# Wget downloader options. # Wget downloader options.
# -c, --continue: resume getting a partially-downloaded file. # -c, --continue: resume getting a partially-downloaded file.
# -N, --timestamping: don't re-retrieve files unless newer. # -N, --timestamping: don't re-retrieve files unless newer.
# -q, Turn off Wget's output. # -q, Turn off Wget's output.
# --show-progress, Force wget to display the progress bar in any verbosity. # --show-progress, Force wget to display the progress bar in any verbosity.
WGET_OPTIONS = "-c -N -q --show-progress" WGET_OPTIONS = "-c -N -q --show-progress"
# Curl downloader options. # Curl downloader options.
# Pass the options you want here. # Pass the options you want here.
CURL_OPTIONS = "" CURL_OPTIONS = ""
# Lftp downloader options. # Lftp downloader options.
# 'LFTP_MIRROR_OPTIONS' are used for the ponce repository to download files # 'LFTP_MIRROR_OPTIONS' are used for the ponce repository to download files
# from a remote directory, and 'LFTP_GET_OPTIONS' are used to download the sources. # from a remote directory, and 'LFTP_GET_OPTIONS' are used to download the sources.
LFTP_MIRROR_OPTIONS = "-c mirror --delete-first --parallel=10" LFTP_MIRROR_OPTIONS = "-c mirror --delete-first --parallel=100 --only-newer"
LFTP_GET_OPTIONS = "-c get -e" LFTP_GET_OPTIONS = "-c get -e"
# If silent mode is true, it does not print the commands as they are executed.
# Default is true. [true/false].
SILENT_MODE = true
# Choose ascii printable characters.
# If true, it uses the extended characters, otherwise the basic ones.
# Default is true. [true/false].
ASCII_CHARACTERS = true
# Set the 'PONCE_REPO = true' and 'DOWNLOADER = lftp' to switch with
# the ponce repository. Do not unset SBO_REPO_URL and SBO_TXT.
# NOTE: Ponce repository works only with 'lftp' downloader.
#########################################################################
# This is not going to fully support this repository, since it does not #
# provide its own SLACKBUILDS.TXT file. The only difference is that #
# scripts are used from ponce repository and not from SBo repository. #
# Slpkg is still going to use SLACKBUILDS.TXT and ChangeLog.txt from #
# SBo repository and compare these with the Slackware -current #
# ChangeLog.txt file for auto-add blacklisted packages that do not #
# include in the ponce repository. Default is false. [true/false]. #
#########################################################################
PONCE_REPO = false
PONCE_URL = "https://cgit.ponce.cc/slackbuilds/plain/"
# Use a Slackware mirror for your country, get one from /etc/slackpkg/mirrors.
SLACK_CURRENT_MIRROR = "https://mirrors.slackware.com/slackware/slackware64-current/"
SLACK_CHGLOG_TXT = "ChangeLog.txt"
SLACK_CHGLOG_PATH = "/var/lib/slpkg/repository/slack_current/"

View file

@ -56,10 +56,8 @@ class Configs:
# Ponce repo configs. # Ponce repo configs.
ponce_repo: bool = False ponce_repo: bool = False
ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/' ponce_repo_path: str = Path(lib_path, 'repository', 'ponce') # type: ignore
slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/' ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
slack_chglog_txt: str = 'ChangeLog.txt'
slack_chglog_path: str = Path('/var/lib/slpkg/repository/slack_current/') # type: ignore
# Slackware commands. # Slackware commands.
installpkg: str = 'upgradepkg --install-new' installpkg: str = 'upgradepkg --install-new'
@ -121,10 +119,8 @@ class Configs:
# Ponce repo configs. # Ponce repo configs.
ponce_repo: bool = config['PONCE_REPO'] ponce_repo: bool = config['PONCE_REPO']
ponce_url: str = config['PONCE_URL'] ponce_repo_path: str = config['PONCE_REPO_PATH']
slack_current_mirror: str = config['SLACK_CURRENT_MIRROR'] ponce_repo_url: str = config['PONCE_REPO_URL']
slack_chglog_txt: str = config['SLACK_CHGLOG_TXT']
slack_chglog_path: str = config['SLACK_CHGLOG_PATH']
# Slackware commands. # Slackware commands.
installpkg: str = config['INSTALLPKG'] installpkg: str = config['INSTALLPKG']
@ -170,7 +166,7 @@ class Configs:
lib_path, lib_path,
etc_path, etc_path,
db_path, db_path,
slack_chglog_path] ponce_repo_path]
for path in paths: for path in paths:
if not os.path.isdir(path): if not os.path.isdir(path):

View file

@ -1,7 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import re
from pathlib import Path from pathlib import Path
from typing import Union from typing import Union
@ -9,7 +8,7 @@ from slpkg.queries import SBoQueries
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.models.models import SBoTable, PonceTable from slpkg.models.models import SBoTable
from slpkg.models.models import session as Session from slpkg.models.models import session as Session
@ -65,37 +64,6 @@ class CreateData(Configs):
self.session.commit() self.session.commit()
def insert_ponce_blacklist_packages(self) -> None:
""" Install data for ponce repository. """
sbos: list = self.query.sbos()
path = Path(self.slack_chglog_path, self.slack_chglog_txt)
slack_chglog: list = self.read_file(path)
for line in slack_chglog:
# Clean the line from white spaces.
line: str = line.strip()
if re.findall('Added[.]', line):
# Clean the line.
line = re.sub(r'Added.|.txz:', '', line)
pkg: str = line.split('/')[-1]
# Split and get the name only.
name = self.utils.split_installed_pkg(pkg)[0]
if name in sbos:
data = PonceTable(name=name)
self.session.add(data)
# Stop the date when the Slackware 15.0 released.
if line == 'Wed Feb 2 22:22:22 UTC 2022':
break
self.session.commit()
@staticmethod @staticmethod
def read_file(file: Union[str, Path]) -> list: def read_file(file: Union[str, Path]) -> list:
""" Reads the text file. """ """ Reads the text file. """

View file

@ -142,7 +142,7 @@ class Slackbuilds(Configs):
location = SBoQueries(sbo).location() location = SBoQueries(sbo).location()
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}' sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
ponce_url: str = f'{self.ponce_url}{location}/{sbo}' ponce_url: str = f'{self.ponce_repo_url}{location}/{sbo}'
if self.ponce_repo: if self.ponce_repo:
path = Path(self.build_path, sbo) path = Path(self.build_path, sbo)

View file

@ -1,13 +1,16 @@
#!/usr/bin/python3 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
import shutil
import subprocess
from pathlib import Path from pathlib import Path
from multiprocessing import Process from multiprocessing import Process
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.downloader import Downloader from slpkg.downloader import Downloader
from slpkg.create_data import CreateData from slpkg.create_data import CreateData
from slpkg.models.models import SBoTable, PonceTable from slpkg.models.models import SBoTable
from slpkg.views.views import ViewMessage from slpkg.views.views import ViewMessage
from slpkg.progress_bar import ProgressBar from slpkg.progress_bar import ProgressBar
from slpkg.check_updates import CheckUpdates from slpkg.check_updates import CheckUpdates
@ -35,33 +38,41 @@ class UpdateRepository(Configs):
print('Updating the package list.\n') print('Updating the package list.\n')
print('Downloading some necessary files, please wait...\n') print('Downloading some necessary files, please wait...\n')
self.delete_file(self.sbo_repo_path, self.sbo_txt)
self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt)
self.delete_file(self.slack_chglog_path, self.slack_chglog_txt)
self.delete_sbo_data()
self.delete_ponce_data()
slackbuilds_txt: str = f'{self.sbo_repo_url}{self.sbo_txt}'
changelog_txt: str = f'{self.sbo_repo_url}{self.sbo_chglog_txt}'
slack_changelog_txt: str = f'{self.slack_current_mirror}{self.slack_chglog_txt}'
down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags)
down_slackbuilds.download()
down_sbo_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags)
down_sbo_changelog.download()
if self.ponce_repo: if self.ponce_repo:
down_slack_current_changelog = Downloader(self.slack_chglog_path, slack_changelog_txt, self.flags) self.delete_sbo_data()
down_slack_current_changelog.download()
down_slackbuilds = Downloader(self.ponce_repo_path, self.ponce_repo_url, self.flags)
down_slackbuilds.download()
print(f'Generating the {self.sbo_txt} file... ', end='', flush=True)
os.chdir(self.ponce_repo_path)
# Creating the SLACKBUILDS.TXT file.
subprocess.call(f'./gen_sbo_txt.sh > {self.sbo_txt}', shell=True)
# Move the SLACKBUILDS.TXT to the repository for install the data into the database.
shutil.move(f'{self.ponce_repo_path}{self.sbo_txt}', f'{self.sbo_repo_path}{self.sbo_txt}')
else:
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}'
down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags)
down_slackbuilds.download()
down_sbo_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags)
down_sbo_changelog.download()
data = CreateData() data = CreateData()
data.insert_sbo_table() data.insert_sbo_table()
if self.ponce_repo:
data.insert_ponce_blacklist_packages()
def check(self) -> None: def check(self) -> None:
check_updates = CheckUpdates() check_updates = CheckUpdates()
if not check_updates.check(): if not check_updates.check():
@ -106,9 +117,3 @@ class UpdateRepository(Configs):
""" Delete the table from the database. """ """ Delete the table from the database. """
self.session.query(SBoTable).delete() self.session.query(SBoTable).delete()
self.session.commit() self.session.commit()
def delete_ponce_data(self) -> None:
""" Delete the table from the database. """
if self.ponce_repo:
self.session.query(PonceTable).delete()
self.session.commit()