Updated for ponce

This commit is contained in:
Dimitris Zlatanidis 2023-03-04 18:44:17 +02:00
parent 4094b56b24
commit 979f8b7d34
6 changed files with 57 additions and 41 deletions

View file

@ -32,9 +32,7 @@
SBO_REPO_TAG = "_SBo" SBO_REPO_TAG = "_SBo"
# PONCE REPOSITORY CONFIGS. # PONCE REPOSITORY CONFIGS.
# Set the 'PONCE_REPO = true' and 'DOWNLOADER = lftp' to switch with # Set the 'PONCE_REPO = true' to switch with the ponce repository.
# 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]. # Default is false. [true/false].
PONCE_REPO = false PONCE_REPO = false
PONCE_REPO_PATH = "/var/lib/slpkg/repository/ponce/" PONCE_REPO_PATH = "/var/lib/slpkg/repository/ponce/"
@ -52,7 +50,7 @@
# 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].
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.
@ -64,7 +62,6 @@
# 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 only for the ponce repository to transfer files
# from a remote directory, and 'LFTP_GET_OPTIONS' are used to download the sources. # from the ponce repository.
LFTP_MIRROR_OPTIONS = "-c mirror --delete-first --parallel=100 --only-newer" LFTP_MIRROR_OPTIONS = "-c mirror --parallel=100 --only-newer"
LFTP_GET_OPTIONS = "-c get -e"

View file

@ -100,6 +100,9 @@ mkdir -p $PKG/etc/$PRGNAM
install -D -m0644 configs/slpkg.toml $PKG/etc/slpkg/slpkg.toml.new install -D -m0644 configs/slpkg.toml $PKG/etc/slpkg/slpkg.toml.new
install -D -m0644 configs/blacklist.toml $PKG/etc/slpkg/blacklist.toml.new install -D -m0644 configs/blacklist.toml $PKG/etc/slpkg/blacklist.toml.new
mkdir -p $PKG/var/lib/$PRGNAM/repository/ponce
cp tools/gen_sbo_txt.sh $PKG/var/lib/$PRGNAM/repository/ponce
mkdir -p $PKG/usr/man/man1 & mkdir -p $PKG/usr/man/fr/man1 mkdir -p $PKG/usr/man/man1 & mkdir -p $PKG/usr/man/fr/man1
cp man/slpkg.1 $PKG/usr/man/man1 cp man/slpkg.1 $PKG/usr/man/man1
cp man/slpkg-fr.1 $PKG/usr/man/fr/man1/slpkg.1 cp man/slpkg-fr.1 $PKG/usr/man/fr/man1/slpkg.1

View file

@ -58,6 +58,9 @@ class Configs:
ponce_repo: bool = False ponce_repo: bool = False
ponce_repo_path: str = Path(lib_path, 'repository', 'ponce') # type: ignore ponce_repo_path: str = Path(lib_path, 'repository', 'ponce') # type: ignore
ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/' ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
ponce_txt: str = 'SLACKBUILDS.TXT'
ponce_chglog_txt: str = 'ChangeLog.txt'
ponce_repo_tag: str = '_SBo'
# Slackware commands. # Slackware commands.
installpkg: str = 'upgradepkg --install-new' installpkg: str = 'upgradepkg --install-new'
@ -81,7 +84,6 @@ class Configs:
# Lftp options' # Lftp options'
lftp_mirror_options: str = '-c mirror --delete-first --parallel=10' lftp_mirror_options: str = '-c mirror --delete-first --parallel=10'
lftp_get_options: str = '-c get -e'
# Choose the view mode. # Choose the view mode.
silent_mode: bool = True silent_mode: bool = True
@ -121,6 +123,9 @@ class Configs:
ponce_repo: bool = config['PONCE_REPO'] ponce_repo: bool = config['PONCE_REPO']
ponce_repo_path: str = config['PONCE_REPO_PATH'] ponce_repo_path: str = config['PONCE_REPO_PATH']
ponce_repo_url: str = config['PONCE_REPO_URL'] ponce_repo_url: str = config['PONCE_REPO_URL']
ponce_txt: str = config['PONCE_TXT']
ponce_chglog_txt: str = config['PONCE_CHGLOG_TXT']
ponce_repo_tag: str = config['PONCE_REPO_TAG']
# Slackware commands. # Slackware commands.
installpkg: str = config['INSTALLPKG'] installpkg: str = config['INSTALLPKG']
@ -144,7 +149,6 @@ class Configs:
# Lftp options. # Lftp options.
lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS'] lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS']
lftp_get_options: str = config['LFTP_GET_OPTIONS']
# Choose the view mode. # Choose the view mode.
silent_mode: bool = config['SILENT_MODE'] silent_mode: bool = config['SILENT_MODE']

View file

@ -1,7 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from urllib.parse import unquote from urllib.parse import unquote
@ -55,22 +54,21 @@ class Downloader(Configs, Utilities):
self.output = subprocess.call(f'{self.downloader} {self.curl_options} "{self.url}" --output ' self.output = subprocess.call(f'{self.downloader} {self.curl_options} "{self.url}" --output '
f'{self.path}/{self.filename}', shell=True, stderr=self.stderr, f'{self.path}/{self.filename}', shell=True, stderr=self.stderr,
stdout=self.stdout) stdout=self.stdout)
elif self.downloader == 'lftp': # elif self.downloader == 'lftp':
#
if self.ponce_repo and 'ponce' in self.url: # if self.ponce_repo and 'ponce' in self.url:
# Download files from a directory. # # Download files from a directory.
self.output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.url} {self.path}', # self.output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.url} {self.path}',
shell=True, stderr=self.stderr, stdout=self.stdout) # shell=True, stderr=self.stderr, stdout=self.stdout)
# Create /path/name.Slackbuild # # Create /path/name.Slackbuild
slackbuild = Path(self.path, f'{str(self.path).split("/")[-1]}.SlackBuild') # slackbuild = Path(self.path, f'{str(self.path).split("/")[-1]}.SlackBuild')
#
if slackbuild.is_file(): # if slackbuild.is_file():
os.chmod(slackbuild, 0o775) # os.chmod(slackbuild, 0o775)
else: # else:
# Download binaries files and the sources. # # Download binaries files and the sources.
self.output = subprocess.call(f'lftp {self.lftp_get_options} {self.url} -o {self.path}', # self.output = subprocess.call(f'lftp {self.lftp_get_options} {self.url} -o {self.path}',
shell=True, stderr=self.stderr, stdout=self.stdout) # shell=True, stderr=self.stderr, stdout=self.stdout)
else: else:
raise SystemExit(f"{self.red}Error:{self.endc} Downloader '{self.downloader}' not supported.\n") raise SystemExit(f"{self.red}Error:{self.endc} Downloader '{self.downloader}' not supported.\n")

View file

@ -3,6 +3,7 @@
import os import os
import time import time
import shutil
import subprocess import subprocess
from pathlib import Path from pathlib import Path
@ -60,6 +61,10 @@ class Slackbuilds(Configs):
self.flag_jobs: list = ['-j', '--jobs'] self.flag_jobs: list = ['-j', '--jobs']
self.flag_no_silent: list = ['-n', '--no-silent'] self.flag_no_silent: list = ['-n', '--no-silent']
self.repo_tag: str = self.sbo_repo_tag
if self.ponce_repo:
self.repo_tag: str = self.ponce_repo_tag
def execute(self) -> None: def execute(self) -> None:
""" Starting build or install the slackbuilds. """ """ Starting build or install the slackbuilds. """
self.creating_dictionary() self.creating_dictionary()
@ -140,15 +145,23 @@ class Slackbuilds(Configs):
self.utils.remove_file_if_exists(self.tmp_slpkg, file) self.utils.remove_file_if_exists(self.tmp_slpkg, file)
self.utils.remove_folder_if_exists(self.build_path, sbo) self.utils.remove_folder_if_exists(self.build_path, sbo)
location = SBoQueries(sbo).location() location: str = SBoQueries(sbo).location()
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
ponce_url: str = f'{self.ponce_repo_url}{location}/{sbo}'
if self.ponce_repo: if self.ponce_repo:
path = Path(self.build_path, sbo) ponce_repo_path_package = Path(self.ponce_repo_path, location, sbo)
lftp = Downloader(path, ponce_url, self.flags) build_package_path = Path(self.build_path, sbo)
lftp.download()
if build_package_path.is_dir():
shutil.rmtree(build_package_path)
shutil.copytree(ponce_repo_path_package, f'{self.build_path}{sbo}')
slackbuild = Path(build_package_path, f'{sbo}.SlackBuild')
os.chmod(slackbuild, 0o775)
else: else:
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
down_sbo = Downloader(self.tmp_slpkg, sbo_url, self.flags) down_sbo = Downloader(self.tmp_slpkg, sbo_url, self.flags)
down_sbo.download() down_sbo.download()
@ -190,7 +203,7 @@ class Slackbuilds(Configs):
with open(sbo_script, 'w') as script: with open(sbo_script, 'w') as script:
for line in lines: for line in lines:
if line.startswith('TAG=$'): if line.startswith('TAG=$'):
line: str = f'TAG=${{TAG:-{self.sbo_repo_tag}}}\n' line: str = f'TAG=${{TAG:-{self.repo_tag}}}\n'
script.write(line) script.write(line)
def logging_installed_dependencies(self, name: str) -> None: def logging_installed_dependencies(self, name: str) -> None:
@ -237,7 +250,7 @@ class Slackbuilds(Configs):
installation. """ installation. """
version: str = SBoQueries(name).version() version: str = SBoQueries(name).version()
pattern: str = f'{name}-{version}*{self.sbo_repo_tag}*' pattern: str = f'{name}-{version}*{self.repo_tag}*'
tmp = Path(self.tmp_path) tmp = Path(self.tmp_path)
packages: list = [file.name for file in tmp.glob(pattern)] packages: list = [file.name for file in tmp.glob(pattern)]

View file

@ -37,24 +37,25 @@ class UpdateRepository(Configs):
view.question() view.question()
print('Updating the package list.\n') print('Updating the package list.\n')
print('Downloading some necessary files, please wait...\n')
if self.ponce_repo: if self.ponce_repo:
self.delete_sbo_data()
down_slackbuilds = Downloader(self.ponce_repo_path, self.ponce_repo_url, self.flags) print("Downloading the 'ponce' repository, please wait...\n")
down_slackbuilds.download() subprocess.call(f'lftp {self.lftp_mirror_options} {self.ponce_repo_url} {self.ponce_repo_path}',
shell=True)
print(f'Generating the {self.sbo_txt} file... ', end='', flush=True) print(f'Generating the {self.sbo_txt} file... ', end='', flush=True)
print('\n')
# Generating the SLACKBUILDS.TXT file.
os.chdir(self.ponce_repo_path) os.chdir(self.ponce_repo_path)
# Creating the SLACKBUILDS.TXT file.
subprocess.call(f'./gen_sbo_txt.sh > {self.sbo_txt}', shell=True) 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. # 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}') shutil.move(f'{self.ponce_repo_path}{self.sbo_txt}', f'{self.sbo_repo_path}{self.sbo_txt}')
self.delete_sbo_data()
else: else:
self.delete_file(self.sbo_repo_path, self.sbo_txt) 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.sbo_repo_path, self.sbo_chglog_txt)