mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
Updated for ponce repo
This commit is contained in:
parent
2b42d6d99b
commit
f577ead8eb
4 changed files with 73 additions and 51 deletions
|
@ -32,11 +32,10 @@
|
|||
# The sbo repository tag.
|
||||
SBO_REPO_TAG = "_SBo"
|
||||
|
||||
# Ponce default url: https://cgit.ponce.cc/slackbuilds/plain
|
||||
# Set true and set the url here if you going to use ponce repository.
|
||||
# Do not unset
|
||||
PONCE_REPO = false
|
||||
PONCE_REPO_URL = ''
|
||||
# Set the PONCE_REPO and PONCE_REPO_URL if you are going to use it.
|
||||
# Do not unset SBO_REPO_URL and SBO_TXT.
|
||||
# PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain"
|
||||
PONCE_REPO_URL = ""
|
||||
|
||||
# Slackware command for install packages, instead, you can use 'installpkg'.
|
||||
INSTALLPKG = "upgradepkg --install-new"
|
||||
|
|
|
@ -27,13 +27,13 @@ class LoadConfigs:
|
|||
class Configs:
|
||||
""" Default configurations. """
|
||||
|
||||
# Programme name
|
||||
# Programme name.
|
||||
prog_name: str = 'slpkg'
|
||||
|
||||
# OS architecture by default
|
||||
os_arch: str = platform.machine()
|
||||
|
||||
# All necessary paths
|
||||
# All necessary paths.
|
||||
tmp_path: str = '/tmp'
|
||||
tmp_slpkg: str = Path(tmp_path, prog_name)
|
||||
build_path: str = Path('tmp', prog_name, 'build')
|
||||
|
@ -44,41 +44,41 @@ class Configs:
|
|||
sbo_repo_path: str = Path(lib_path, 'repository')
|
||||
log_packages: str = Path('/var', 'log', 'packages')
|
||||
|
||||
# Database name
|
||||
# Database name.
|
||||
database_name: str = f'database.{prog_name}'
|
||||
|
||||
# SBo repository configs
|
||||
# SBo repository configs.
|
||||
sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0'
|
||||
sbo_txt: str = 'SLACKBUILDS.TXT'
|
||||
sbo_chglog_txt: str = 'ChangeLog.txt'
|
||||
sbo_tar_suffix: str = '.tar.gz'
|
||||
sbo_repo_tag: str = '_SBo'
|
||||
|
||||
# ponce repo configs
|
||||
ponce_repo: bool = False
|
||||
ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain'
|
||||
# Ponce repo configs.
|
||||
# PONCE URL: https://cgit.ponce.cc/slackbuilds/plain
|
||||
ponce_repo_url: str = ''
|
||||
|
||||
# Slackware commands
|
||||
# Slackware commands.
|
||||
installpkg: str = 'upgradepkg --install-new'
|
||||
reinstall: str = 'upgradepkg --reinstall'
|
||||
removepkg: str = 'removepkg'
|
||||
|
||||
# Cli menu colors configs
|
||||
# Cli menu colors configs.
|
||||
colors: bool = True
|
||||
|
||||
# Dialog utility
|
||||
# Dialog utility.
|
||||
dialog: bool = True
|
||||
|
||||
# Downloader command. Wget and curl.
|
||||
downloader = 'wget'
|
||||
|
||||
# Wget options
|
||||
# Wget options.
|
||||
wget_options = '-c -N -q --show-progress'
|
||||
|
||||
# Curl options
|
||||
# Curl options.
|
||||
curl_options = ''
|
||||
|
||||
# Choose the view mode
|
||||
# Choose the view mode.
|
||||
silent_mode: bool = True
|
||||
|
||||
# Choose ascii characters.
|
||||
|
@ -92,49 +92,49 @@ class Configs:
|
|||
|
||||
if config:
|
||||
try:
|
||||
# OS architecture by default
|
||||
# OS architecture by default.
|
||||
os_arch: str = config['OS_ARCH']
|
||||
|
||||
# All necessary paths
|
||||
# All necessary paths.
|
||||
tmp_slpkg: str = config['TMP_SLPKG']
|
||||
build_path: str = config['BUILD_PATH']
|
||||
download_only_path: str = config['DOWNLOAD_ONLY_PATH']
|
||||
sbo_repo_path: str = config['SBO_REPO_PATH']
|
||||
|
||||
# Database name
|
||||
# Database name.
|
||||
database_name: str = config['DATABASE_NAME']
|
||||
|
||||
# SBo repository details
|
||||
# SBo repository details.
|
||||
sbo_repo_url: str = config['SBO_REPO_URL']
|
||||
sbo_txt: str = config['SBO_TXT']
|
||||
sbo_chglog_txt: str = config['SBO_CHGLOG_TXT']
|
||||
sbo_tar_suffix: str = config['SBO_TAR_SUFFIX']
|
||||
sbo_repo_tag: str = config['SBO_REPO_TAG']
|
||||
|
||||
ponce_repo: bool = config['PONCE_REPO']
|
||||
# Ponce repo configs.
|
||||
ponce_repo_url: str = config['PONCE_REPO_URL']
|
||||
|
||||
# Slackware commands
|
||||
# Slackware commands.
|
||||
installpkg: str = config['INSTALLPKG']
|
||||
reinstall: str = config['REINSTALL']
|
||||
removepkg: str = config['REMOVEPKG']
|
||||
|
||||
# Cli menu colors configs
|
||||
# Cli menu colors configs.
|
||||
colors: str = config['COLORS']
|
||||
|
||||
# Dialog utility
|
||||
# Dialog utility.
|
||||
dialog: str = config['DIALOG']
|
||||
|
||||
# Downloader command
|
||||
# Downloader command.
|
||||
downloader: str = config['DOWNLOADER']
|
||||
|
||||
# Wget options
|
||||
# Wget options.
|
||||
wget_options: str = config['WGET_OPTIONS']
|
||||
|
||||
# Curl options
|
||||
# Curl options.
|
||||
curl_options: str = config['CURL_OPTIONS']
|
||||
|
||||
# Choose the view mode
|
||||
# Choose the view mode.
|
||||
silent_mode: bool = config['SILENT_MODE']
|
||||
|
||||
# Choose ascii characters. Extended or basic.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
@ -37,7 +38,7 @@ class Downloader(Configs, Utilities):
|
|||
self.stderr = None
|
||||
self.stdout = None
|
||||
|
||||
def wget(self):
|
||||
def transfer_tools(self):
|
||||
""" Wget downloader. """
|
||||
if self.downloader == 'wget':
|
||||
self.output = subprocess.call(f'{self.downloader} {self.wget_options} --directory-prefix={self.path} '
|
||||
|
@ -46,30 +47,39 @@ 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)
|
||||
|
||||
else:
|
||||
raise SystemExit(f"{self.red}Error:{self.endc} Downloader '{self.downloader}' not supported.\n")
|
||||
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
# def lftp(self):
|
||||
# # TEST FOR PONCE REPOSITORY
|
||||
# # https://cgit.ponce.cc/slackbuilds/plain/
|
||||
# self.output = subprocess.call(f"lftp -c 'mirror --parallel=100 {self.url} {self.path} ;exit'", shell=True,
|
||||
# stderr=self.stderr, stdout=self.stdout)
|
||||
# file = f'{self.path}/{self.path.split("/")[-1]}.SlackBuild'
|
||||
# if os.path.isfile(file):
|
||||
# os.chmod(file, 0o775)
|
||||
# return True
|
||||
def lftp(self):
|
||||
""" Downloads scripts from ponce repository.
|
||||
|
||||
PONCE URL: https://cgit.ponce.cc/slackbuilds/plain/
|
||||
"""
|
||||
self.output = subprocess.call(f"lftp -c 'mirror --parallel=100 {self.url} {self.path} ;exit'", 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)
|
||||
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def check_if_downloaded(self):
|
||||
""" Checks if the file downloaded. """
|
||||
url = unquote(self.url)
|
||||
file = url.split('/')[-1]
|
||||
path_file = Path(self.path, file)
|
||||
if not path_file.exists():
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' "
|
||||
f"to download.\n")
|
||||
if 'ponce' not in self.url:
|
||||
url = unquote(self.url)
|
||||
file = url.split('/')[-1]
|
||||
path_file = Path(self.path, file)
|
||||
if not path_file.exists():
|
||||
raise SystemExit(f"\n{self.red}FAILED {self.output}:{self.endc} '{self.blue}{self.url}{self.endc}' "
|
||||
f"to download.\n")
|
||||
|
||||
def download(self):
|
||||
""" Starting multiprocessing download process. """
|
||||
|
@ -82,7 +92,11 @@ class Downloader(Configs, Utilities):
|
|||
message = f'[{self.green}Downloading{self.endc}]'
|
||||
|
||||
# Starting multiprocessing
|
||||
p1 = Process(target=self.wget)
|
||||
if 'ponce' in self.url:
|
||||
p1 = Process(target=self.lftp)
|
||||
else:
|
||||
p1 = Process(target=self.transfer_tools)
|
||||
|
||||
p2 = Process(target=self.progress.bar, args=(message, self.filename))
|
||||
|
||||
p1.start()
|
||||
|
@ -107,6 +121,9 @@ class Downloader(Configs, Utilities):
|
|||
# Restore the terminal cursor
|
||||
print('\x1b[?25h', self.endc)
|
||||
else:
|
||||
self.wget()
|
||||
if 'ponce' in self.url:
|
||||
self.lftp()
|
||||
else:
|
||||
self.transfer_tools()
|
||||
|
||||
self.check_if_downloaded()
|
||||
|
|
|
@ -139,11 +139,17 @@ class Slackbuilds(Configs):
|
|||
|
||||
location = SBoQueries(sbo).location()
|
||||
url = f'{self.sbo_repo_url}/{location}/{file}'
|
||||
ponce_url = f'{self.ponce_repo_url}/{location}/{sbo}'
|
||||
|
||||
down_sbo = Downloader(self.tmp_slpkg, url, self.flags)
|
||||
down_sbo.download()
|
||||
if 'ponce' in self.ponce_repo_url:
|
||||
path = Path(self.build_path, sbo)
|
||||
lftp = Downloader(path, ponce_url, self.flags)
|
||||
lftp.download()
|
||||
else:
|
||||
down_sbo = Downloader(self.tmp_slpkg, url, self.flags)
|
||||
down_sbo.download()
|
||||
|
||||
self.utils.untar_archive(self.tmp_slpkg, file, self.build_path)
|
||||
self.utils.untar_archive(self.tmp_slpkg, file, self.build_path)
|
||||
|
||||
self.patch_sbo_tag(sbo)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue