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