Updated for url & paths

This commit is contained in:
Dimitris Zlatanidis 2023-03-01 22:27:29 +02:00
parent b6639aa747
commit 8fd405cd35
8 changed files with 74 additions and 55 deletions

View file

@ -3,22 +3,22 @@
OS_ARCH = "x86_64" OS_ARCH = "x86_64"
# Tmp path for slpkg. # Tmp path for slpkg.
TMP_SLPKG = "/tmp/slpkg" TMP_SLPKG = "/tmp/slpkg/"
# Path for building source and the script. # Path for building source and the script.
BUILD_PATH = "/tmp/slpkg/build" BUILD_PATH = "/tmp/slpkg/build/"
# This path working only with the command download. # This path working only with the command download.
DOWNLOAD_ONLY_PATH = "/tmp/slpkg" DOWNLOAD_ONLY_PATH = "/tmp/slpkg/"
# The path that the SLACKBUILDS.TXT file downloaded. # The path that the SLACKBUILDS.TXT file downloaded.
SBO_REPO_PATH = "/var/lib/slpkg/repository" SBO_REPO_PATH = "/var/lib/slpkg/repository/"
# The name of the database. Default name is 'database.slpkg'. # The name of the database. Default name is 'database.slpkg'.
DATABASE_NAME = "database.slpkg" DATABASE_NAME = "database.slpkg"
# Slackbuilds.org repository url. # Slackbuilds.org repository url.
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0" SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
# The SLACKBUILDS.TXT repository file. # The SLACKBUILDS.TXT repository file.
SBO_TXT = "SLACKBUILDS.TXT" SBO_TXT = "SLACKBUILDS.TXT"
@ -50,7 +50,7 @@
DIALOG = true DIALOG = true
# You can choose downloader between wget and curl. # You can choose downloader between wget and curl.
# Default is wget. [wget/curl]. # Default is wget. [wget/curl/lftp].
DOWNLOADER = "wget" DOWNLOADER = "wget"
# Wget downloader options. # Wget downloader options.
@ -65,6 +65,10 @@
# Pass the options you want here. # Pass the options you want here.
CURL_OPTIONS = "" CURL_OPTIONS = ""
# Lftp downloader options.
LFTP_MIRROR_OPTIONS = "--delete-first --parallel=10"
LFTP_GET_OPTIONS = "-e"
# If silent mode is true, it does not print the commands as they are executed. # If silent mode is true, it does not print the commands as they are executed.
# Default is true. [true/false]. # Default is true. [true/false].
SILENT_MODE = true SILENT_MODE = true
@ -86,10 +90,8 @@
# include in the ponce repository. Default is false. [true/false]. # # include in the ponce repository. Default is false. [true/false]. #
######################################################################### #########################################################################
PONCE_REPO = false PONCE_REPO = false
PONCE_URL = "https://cgit.ponce.cc/slackbuilds/plain" PONCE_URL = "https://cgit.ponce.cc/slackbuilds/plain/"
# lftp is used to transfer files from the ponce repository.
LFTP_OPTIONS = "--delete-first --parallel=10"
# Use a mirror for your country, get one from /etc/slackpkg/mirrors # Use a mirror for your country, get one from /etc/slackpkg/mirrors
SLACK_CURRENT_MIRROR = "https://mirrors.slackware.com/slackware/slackware64-current" SLACK_CURRENT_MIRROR = "https://mirrors.slackware.com/slackware/slackware64-current/"
SLACK_CHGLOG_TXT = "ChangeLog.txt" SLACK_CHGLOG_TXT = "ChangeLog.txt"
SLACK_CHGLOG_PATH = "/var/lib/slpkg/repository/slack_current" SLACK_CHGLOG_PATH = "/var/lib/slpkg/repository/slack_current/"

View file

@ -29,7 +29,7 @@ class CheckUpdates(Configs):
local_chg_txt = Path(self.sbo_repo_path, self.sbo_chglog_txt) local_chg_txt = Path(self.sbo_repo_path, self.sbo_chglog_txt)
http = urllib3.PoolManager() http = urllib3.PoolManager()
repo = http.request('GET', f'{self.sbo_repo_url}/{self.sbo_chglog_txt}') repo = http.request('GET', f'{self.sbo_repo_url}{self.sbo_chglog_txt}')
if local_chg_txt.is_file(): if local_chg_txt.is_file():
local_date = int(os.stat(local_chg_txt).st_size) local_date = int(os.stat(local_chg_txt).st_size)

View file

@ -34,7 +34,7 @@ class Configs:
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')
download_only_path: str = Path(tmp_slpkg, '') download_only_path: str = Path(tmp_slpkg, '')
@ -48,7 +48,7 @@ class Configs:
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'
@ -56,10 +56,10 @@ class Configs:
# Ponce repo configs. # Ponce repo configs.
ponce_repo: bool = False ponce_repo: bool = False
ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain' ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current' slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/'
slack_chglog_txt: str = 'ChangeLog.txt' slack_chglog_txt: str = 'ChangeLog.txt'
slack_chglog_path: str = Path('/var/lib/slpkg/repository/slack_current') slack_chglog_path: str = Path('/var/lib/slpkg/repository/slack_current/')
# Slackware commands. # Slackware commands.
installpkg: str = 'upgradepkg --install-new' installpkg: str = 'upgradepkg --install-new'
@ -82,7 +82,8 @@ class Configs:
curl_options: str = '' curl_options: str = ''
# Lftp options' # Lftp options'
lftp_options: str = '--delete-first --parallel=10' lftp_mirror_options: str = '--delete-first --parallel=10'
lftp_get_options: str = ''
# Choose the view mode. # Choose the view mode.
silent_mode: bool = True silent_mode: bool = True
@ -146,7 +147,8 @@ class Configs:
curl_options: str = config['CURL_OPTIONS'] curl_options: str = config['CURL_OPTIONS']
# Lftp options. # Lftp options.
lftp_options: str = config['LFTP_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

@ -38,7 +38,7 @@ class Download(Configs, Utilities):
for sbo in slackbuilds: for sbo in slackbuilds:
file: str = f'{sbo}{self.sbo_tar_suffix}' file: str = f'{sbo}{self.sbo_tar_suffix}'
location: str = SBoQueries(sbo).location() location: str = SBoQueries(sbo).location()
url: str = f'{self.sbo_repo_url}/{location}/{file}' url: str = f'{self.sbo_repo_url}{location}/{file}'
down_sbo = Downloader(download_path, url, self.flags) down_sbo = Downloader(download_path, url, self.flags)
down_sbo.download() down_sbo.download()

View file

@ -50,6 +50,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':
print('-------------->', self.url)
if self.url.endswith('/'):
self.output = subprocess.call(f"lftp -c 'mirror {self.lftp_mirror_options} {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)
else:
self.output = subprocess.call(f"lftp -c 'get {self.lftp_get_options} {self.url} -o {self.path} ;exit'",
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")
@ -57,22 +72,22 @@ class Downloader(Configs, Utilities):
if self.output != 0: if self.output != 0:
raise SystemExit(self.output) raise SystemExit(self.output)
def lftp(self) -> NoReturn: # def lftp(self) -> NoReturn:
""" Downloads scripts from ponce repository. # """ Downloads scripts from ponce repository.
#
PONCE URL: https://cgit.ponce.cc/slackbuilds/plain/ # PONCE URL: https://cgit.ponce.cc/slackbuilds/plain/
""" # """
self.output = subprocess.call(f"lftp -c 'mirror {self.lftp_options} {self.url} {self.path} ;exit'", # self.output = subprocess.call(f"lftp -c 'mirror {self.lftp_options} {self.url} {self.path} ;exit'",
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)
#
if self.output != 0: # if self.output != 0:
raise SystemExit(self.output) # raise SystemExit(self.output)
def check_if_downloaded(self) -> NoReturn: def check_if_downloaded(self) -> NoReturn:
""" Checks if the file downloaded. """ """ Checks if the file downloaded. """
@ -95,11 +110,11 @@ class Downloader(Configs, Utilities):
message: str = f'[{self.green}Downloading{self.endc}]' message: str = f'[{self.green}Downloading{self.endc}]'
# Starting multiprocessing # Starting multiprocessing
if self.ponce_repo and 'ponce' in self.url: # if self.ponce_repo and 'ponce' in self.url:
p1 = Process(target=self.lftp) # p1 = Process(target=self.lftp)
else: # else:
p1 = Process(target=self.transfer_tools) # p1 = Process(target=self.transfer_tools)
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()
@ -124,9 +139,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:
if self.ponce_repo and 'ponce' in self.url: # if self.ponce_repo and 'ponce' in self.url:
self.lftp() # self.lftp()
else: # else:
self.transfer_tools() self.transfer_tools()
self.check_if_downloaded() self.check_if_downloaded()

View file

@ -141,8 +141,8 @@ class Slackbuilds(Configs):
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 = SBoQueries(sbo).location()
sbo_url: str = f'{self.sbo_repo_url}/{location}/{file}' 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_url}{location}/{sbo}'
if self.ponce_repo: if self.ponce_repo:
path = Path(self.build_path, sbo) path = Path(self.build_path, sbo)
@ -228,7 +228,7 @@ class Slackbuilds(Configs):
self.process_message: str = f"package '{pkg}' to upgrade" self.process_message: str = f"package '{pkg}' to upgrade"
message: str = f'{self.cyan}Upgrade{self.endc}' message: str = f'{self.cyan}Upgrade{self.endc}'
command: str = f'{execute} {self.tmp_path}/{package}' command: str = f'{execute} {self.tmp_path}{package}'
self.multi_process(command, package, message) self.multi_process(command, package, message)

View file

@ -41,9 +41,9 @@ class UpdateRepository(Configs):
self.delete_sbo_data() self.delete_sbo_data()
self.delete_ponce_data() self.delete_ponce_data()
slackbuilds_txt: str = f'{self.sbo_repo_url}/{self.sbo_txt}' slackbuilds_txt: str = f'{self.sbo_repo_url}{self.sbo_txt}'
changelog_txt: str = f'{self.sbo_repo_url}/{self.sbo_chglog_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}' 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 = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags)
down_slackbuilds.download() down_slackbuilds.download()

View file

@ -46,9 +46,9 @@ class ViewPackage(Configs, Utilities):
SBoTable.location SBoTable.location
).filter(SBoTable.name == package).first() ).filter(SBoTable.name == package).first()
readme = self.http_request(f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README') readme = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/README')
info_file = self.http_request(f'{self.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info') info_file = self.http_request(f'{self.sbo_repo_url}{info[9]}/{info[0]}/{info[0]}.info')
maintainer, email, homepage = '', '', '' maintainer, email, homepage = '', '', ''
for line in info_file.data.decode().splitlines(): for line in info_file.data.decode().splitlines():
@ -69,7 +69,7 @@ class ViewPackage(Configs, Utilities):
f'Version: {green}{info[1]}{endc}\n' f'Version: {green}{info[1]}{endc}\n'
f'Requires: {green}{deps}{endc}\n' f'Requires: {green}{deps}{endc}\n'
f'Homepage: {blue}{homepage}{endc}\n' f'Homepage: {blue}{homepage}{endc}\n'
f'Download SlackBuild: {blue}{self.sbo_repo_url}/{info[9]}/{info[0]}' f'Download SlackBuild: {blue}{self.sbo_repo_url}{info[9]}/{info[0]}'
f'{self.sbo_tar_suffix}{endc}\n' f'{self.sbo_tar_suffix}{endc}\n'
f'Download sources: {blue}{info[3]}{endc}\n' f'Download sources: {blue}{info[3]}{endc}\n'
f'Download_x86_64 sources: {blue}{info[4]}{endc}\n' f'Download_x86_64 sources: {blue}{info[4]}{endc}\n'
@ -79,7 +79,7 @@ class ViewPackage(Configs, Utilities):
f'Description: {green}{info[8]}{endc}\n' f'Description: {green}{info[8]}{endc}\n'
f'Slackware: {cyan}{self.sbo_repo_url.split("/")[-1]}{endc}\n' f'Slackware: {cyan}{self.sbo_repo_url.split("/")[-1]}{endc}\n'
f'Category: {red}{info[9]}{endc}\n' f'Category: {red}{info[9]}{endc}\n'
f'SBo url: {blue}{self.sbo_repo_url}/{info[9]}/{info[0]}{endc}\n' f'SBo url: {blue}{self.sbo_repo_url}{info[9]}/{info[0]}{endc}\n'
f'Maintainer: {yellow}{maintainer}{endc}\n' f'Maintainer: {yellow}{maintainer}{endc}\n'
f'Email: {yellow}{email}{endc}\n' f'Email: {yellow}{email}{endc}\n'
f'\nREADME: {cyan}{readme.data.decode()}{endc}') f'\nREADME: {cyan}{readme.data.decode()}{endc}')