mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
Updated for ponce
This commit is contained in:
parent
4094b56b24
commit
979f8b7d34
6 changed files with 57 additions and 41 deletions
|
@ -32,9 +32,7 @@
|
|||
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.
|
||||
# Set the 'PONCE_REPO = true' to switch with the ponce repository.
|
||||
# Default is false. [true/false].
|
||||
PONCE_REPO = false
|
||||
PONCE_REPO_PATH = "/var/lib/slpkg/repository/ponce/"
|
||||
|
@ -52,7 +50,7 @@
|
|||
|
||||
# You can choose downloader between wget and curl.
|
||||
# Ponce repository works only with 'lftp' downloader.
|
||||
# Default is wget. [wget/curl/lftp].
|
||||
# Default is wget. [wget/curl].
|
||||
DOWNLOADER = "wget"
|
||||
# Wget downloader options.
|
||||
# -c, --continue: resume getting a partially-downloaded file.
|
||||
|
@ -64,7 +62,6 @@
|
|||
# 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=100 --only-newer"
|
||||
LFTP_GET_OPTIONS = "-c get -e"
|
||||
# 'LFTP_MIRROR_OPTIONS' are used only for the ponce repository to transfer files
|
||||
# from the ponce repository.
|
||||
LFTP_MIRROR_OPTIONS = "-c mirror --parallel=100 --only-newer"
|
||||
|
|
|
@ -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/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
|
||||
cp man/slpkg.1 $PKG/usr/man/man1
|
||||
cp man/slpkg-fr.1 $PKG/usr/man/fr/man1/slpkg.1
|
||||
|
|
|
@ -58,6 +58,9 @@ class Configs:
|
|||
ponce_repo: bool = False
|
||||
ponce_repo_path: str = Path(lib_path, 'repository', 'ponce') # type: ignore
|
||||
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.
|
||||
installpkg: str = 'upgradepkg --install-new'
|
||||
|
@ -81,7 +84,6 @@ class Configs:
|
|||
|
||||
# Lftp options'
|
||||
lftp_mirror_options: str = '-c mirror --delete-first --parallel=10'
|
||||
lftp_get_options: str = '-c get -e'
|
||||
|
||||
# Choose the view mode.
|
||||
silent_mode: bool = True
|
||||
|
@ -121,6 +123,9 @@ class Configs:
|
|||
ponce_repo: bool = config['PONCE_REPO']
|
||||
ponce_repo_path: str = config['PONCE_REPO_PATH']
|
||||
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.
|
||||
installpkg: str = config['INSTALLPKG']
|
||||
|
@ -144,7 +149,6 @@ class Configs:
|
|||
|
||||
# Lftp options.
|
||||
lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS']
|
||||
lftp_get_options: str = config['LFTP_GET_OPTIONS']
|
||||
|
||||
# Choose the view mode.
|
||||
silent_mode: bool = config['SILENT_MODE']
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
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 '
|
||||
f'{self.path}/{self.filename}', shell=True, stderr=self.stderr,
|
||||
stdout=self.stdout)
|
||||
elif self.downloader == 'lftp':
|
||||
|
||||
if self.ponce_repo and 'ponce' in self.url:
|
||||
# Download files from a directory.
|
||||
self.output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.url} {self.path}',
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
# Create /path/name.Slackbuild
|
||||
slackbuild = Path(self.path, f'{str(self.path).split("/")[-1]}.SlackBuild')
|
||||
|
||||
if slackbuild.is_file():
|
||||
os.chmod(slackbuild, 0o775)
|
||||
else:
|
||||
# Download binaries files and the sources.
|
||||
self.output = subprocess.call(f'lftp {self.lftp_get_options} {self.url} -o {self.path}',
|
||||
shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
|
||||
# elif self.downloader == 'lftp':
|
||||
#
|
||||
# if self.ponce_repo and 'ponce' in self.url:
|
||||
# # Download files from a directory.
|
||||
# self.output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.url} {self.path}',
|
||||
# shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
# # Create /path/name.Slackbuild
|
||||
# slackbuild = Path(self.path, f'{str(self.path).split("/")[-1]}.SlackBuild')
|
||||
#
|
||||
# if slackbuild.is_file():
|
||||
# os.chmod(slackbuild, 0o775)
|
||||
# else:
|
||||
# # Download binaries files and the sources.
|
||||
# self.output = subprocess.call(f'lftp {self.lftp_get_options} {self.url} -o {self.path}',
|
||||
# shell=True, stderr=self.stderr, stdout=self.stdout)
|
||||
else:
|
||||
raise SystemExit(f"{self.red}Error:{self.endc} Downloader '{self.downloader}' not supported.\n")
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from pathlib import Path
|
||||
|
@ -60,6 +61,10 @@ class Slackbuilds(Configs):
|
|||
self.flag_jobs: list = ['-j', '--jobs']
|
||||
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:
|
||||
""" Starting build or install the slackbuilds. """
|
||||
self.creating_dictionary()
|
||||
|
@ -140,15 +145,23 @@ class Slackbuilds(Configs):
|
|||
self.utils.remove_file_if_exists(self.tmp_slpkg, file)
|
||||
self.utils.remove_folder_if_exists(self.build_path, sbo)
|
||||
|
||||
location = SBoQueries(sbo).location()
|
||||
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
|
||||
ponce_url: str = f'{self.ponce_repo_url}{location}/{sbo}'
|
||||
location: str = SBoQueries(sbo).location()
|
||||
|
||||
if self.ponce_repo:
|
||||
path = Path(self.build_path, sbo)
|
||||
lftp = Downloader(path, ponce_url, self.flags)
|
||||
lftp.download()
|
||||
ponce_repo_path_package = Path(self.ponce_repo_path, location, sbo)
|
||||
build_package_path = Path(self.build_path, sbo)
|
||||
|
||||
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:
|
||||
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
|
||||
down_sbo = Downloader(self.tmp_slpkg, sbo_url, self.flags)
|
||||
down_sbo.download()
|
||||
|
||||
|
@ -190,7 +203,7 @@ class Slackbuilds(Configs):
|
|||
with open(sbo_script, 'w') as script:
|
||||
for line in lines:
|
||||
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)
|
||||
|
||||
def logging_installed_dependencies(self, name: str) -> None:
|
||||
|
@ -237,7 +250,7 @@ class Slackbuilds(Configs):
|
|||
installation. """
|
||||
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)
|
||||
packages: list = [file.name for file in tmp.glob(pattern)]
|
||||
|
|
|
@ -37,24 +37,25 @@ class UpdateRepository(Configs):
|
|||
view.question()
|
||||
|
||||
print('Updating the package list.\n')
|
||||
print('Downloading some necessary files, please wait...\n')
|
||||
|
||||
if self.ponce_repo:
|
||||
self.delete_sbo_data()
|
||||
|
||||
down_slackbuilds = Downloader(self.ponce_repo_path, self.ponce_repo_url, self.flags)
|
||||
down_slackbuilds.download()
|
||||
print("Downloading the 'ponce' repository, please wait...\n")
|
||||
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('\n')
|
||||
|
||||
# Generating the SLACKBUILDS.TXT file.
|
||||
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}')
|
||||
|
||||
self.delete_sbo_data()
|
||||
|
||||
else:
|
||||
self.delete_file(self.sbo_repo_path, self.sbo_txt)
|
||||
self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt)
|
||||
|
|
Loading…
Reference in a new issue