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]
# OS architecture by default.
OS_ARCH = "x86_64"
# Tmp path for slpkg.
TMP_SLPKG = "/tmp/slpkg/"
# Path for building source and the script.
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'.
DATABASE_NAME = "database.slpkg"
# Slackbuilds.org repository url.
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"
# This path working only with the command download.
DOWNLOAD_ONLY_PATH = "/tmp/slpkg/"
# Cli menu colors configs. Default is true. [true/false].
COLORS = true
# Dialog is a program that will let you to presenta variety of questions
# or display messages using dialog boxes from a shell script.
# Default is true. [true/false].
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.
# Ponce repository works only with 'lftp' downloader.
# Default is wget. [wget/curl/lftp].
DOWNLOADER = "wget"
# Wget downloader options.
# -c, --continue: resume getting a partially-downloaded file.
# -N, --timestamping: don't re-retrieve files unless newer.
# -q, Turn off Wget's output.
# --show-progress, Force wget to display the progress bar in any verbosity.
WGET_OPTIONS = "-c -N -q --show-progress"
# Curl downloader options.
# Pass the options you want here.
CURL_OPTIONS = ""
# Lftp downloader options.
# '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.
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"
# 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: bool = False
ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/'
slack_chglog_txt: str = 'ChangeLog.txt'
slack_chglog_path: str = Path('/var/lib/slpkg/repository/slack_current/') # type: ignore
ponce_repo_path: str = Path(lib_path, 'repository', 'ponce') # type: ignore
ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
# Slackware commands.
installpkg: str = 'upgradepkg --install-new'
@ -121,10 +119,8 @@ class Configs:
# Ponce repo configs.
ponce_repo: bool = config['PONCE_REPO']
ponce_url: str = config['PONCE_URL']
slack_current_mirror: str = config['SLACK_CURRENT_MIRROR']
slack_chglog_txt: str = config['SLACK_CHGLOG_TXT']
slack_chglog_path: str = config['SLACK_CHGLOG_PATH']
ponce_repo_path: str = config['PONCE_REPO_PATH']
ponce_repo_url: str = config['PONCE_REPO_URL']
# Slackware commands.
installpkg: str = config['INSTALLPKG']
@ -170,7 +166,7 @@ class Configs:
lib_path,
etc_path,
db_path,
slack_chglog_path]
ponce_repo_path]
for path in paths:
if not os.path.isdir(path):

View file

@ -1,7 +1,6 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
from pathlib import Path
from typing import Union
@ -9,7 +8,7 @@ from slpkg.queries import SBoQueries
from slpkg.configs import Configs
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
@ -65,37 +64,6 @@ class CreateData(Configs):
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
def read_file(file: Union[str, Path]) -> list:
""" Reads the text file. """

View file

@ -142,7 +142,7 @@ class Slackbuilds(Configs):
location = SBoQueries(sbo).location()
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:
path = Path(self.build_path, sbo)

View file

@ -1,13 +1,16 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
import shutil
import subprocess
from pathlib import Path
from multiprocessing import Process
from slpkg.configs import Configs
from slpkg.downloader import Downloader
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.progress_bar import ProgressBar
from slpkg.check_updates import CheckUpdates
@ -35,33 +38,41 @@ class UpdateRepository(Configs):
print('Updating the package list.\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:
down_slack_current_changelog = Downloader(self.slack_chglog_path, slack_changelog_txt, self.flags)
down_slack_current_changelog.download()
self.delete_sbo_data()
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.insert_sbo_table()
if self.ponce_repo:
data.insert_ponce_blacklist_packages()
def check(self) -> None:
check_updates = CheckUpdates()
if not check_updates.check():
@ -106,9 +117,3 @@ class UpdateRepository(Configs):
""" Delete the table from the database. """
self.session.query(SBoTable).delete()
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()