mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-17 06:11:35 +01:00
Updated for url & paths
This commit is contained in:
parent
b6639aa747
commit
8fd405cd35
8 changed files with 74 additions and 55 deletions
|
@ -3,22 +3,22 @@
|
|||
OS_ARCH = "x86_64"
|
||||
|
||||
# Tmp path for slpkg.
|
||||
TMP_SLPKG = "/tmp/slpkg"
|
||||
TMP_SLPKG = "/tmp/slpkg/"
|
||||
|
||||
# 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.
|
||||
DOWNLOAD_ONLY_PATH = "/tmp/slpkg"
|
||||
DOWNLOAD_ONLY_PATH = "/tmp/slpkg/"
|
||||
|
||||
# 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'.
|
||||
DATABASE_NAME = "database.slpkg"
|
||||
|
||||
# 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.
|
||||
SBO_TXT = "SLACKBUILDS.TXT"
|
||||
|
@ -50,7 +50,7 @@
|
|||
DIALOG = true
|
||||
|
||||
# You can choose downloader between wget and curl.
|
||||
# Default is wget. [wget/curl].
|
||||
# Default is wget. [wget/curl/lftp].
|
||||
DOWNLOADER = "wget"
|
||||
|
||||
# Wget downloader options.
|
||||
|
@ -65,6 +65,10 @@
|
|||
# Pass the options you want here.
|
||||
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.
|
||||
# Default is true. [true/false].
|
||||
SILENT_MODE = true
|
||||
|
@ -86,10 +90,8 @@
|
|||
# include in the ponce repository. Default is false. [true/false]. #
|
||||
#########################################################################
|
||||
PONCE_REPO = false
|
||||
PONCE_URL = "https://cgit.ponce.cc/slackbuilds/plain"
|
||||
# lftp is used to transfer files from the ponce repository.
|
||||
LFTP_OPTIONS = "--delete-first --parallel=10"
|
||||
PONCE_URL = "https://cgit.ponce.cc/slackbuilds/plain/"
|
||||
# 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_PATH = "/var/lib/slpkg/repository/slack_current"
|
||||
SLACK_CHGLOG_PATH = "/var/lib/slpkg/repository/slack_current/"
|
||||
|
|
|
@ -29,7 +29,7 @@ class CheckUpdates(Configs):
|
|||
local_chg_txt = Path(self.sbo_repo_path, self.sbo_chglog_txt)
|
||||
|
||||
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():
|
||||
local_date = int(os.stat(local_chg_txt).st_size)
|
||||
|
|
|
@ -34,7 +34,7 @@ class Configs:
|
|||
os_arch: str = platform.machine()
|
||||
|
||||
# All necessary paths.
|
||||
tmp_path: str = '/tmp'
|
||||
tmp_path: str = '/tmp/'
|
||||
tmp_slpkg: str = Path(tmp_path, prog_name)
|
||||
build_path: str = Path('tmp', prog_name, 'build')
|
||||
download_only_path: str = Path(tmp_slpkg, '')
|
||||
|
@ -48,7 +48,7 @@ class Configs:
|
|||
database_name: str = f'database.{prog_name}'
|
||||
|
||||
# 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_chglog_txt: str = 'ChangeLog.txt'
|
||||
sbo_tar_suffix: str = '.tar.gz'
|
||||
|
@ -56,10 +56,10 @@ class Configs:
|
|||
|
||||
# Ponce repo configs.
|
||||
ponce_repo: bool = False
|
||||
ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain'
|
||||
slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current'
|
||||
ponce_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
|
||||
slack_current_mirror: str = 'https://mirrors.slackware.com/slackware/slackware64-current/'
|
||||
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.
|
||||
installpkg: str = 'upgradepkg --install-new'
|
||||
|
@ -82,7 +82,8 @@ class Configs:
|
|||
curl_options: str = ''
|
||||
|
||||
# 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.
|
||||
silent_mode: bool = True
|
||||
|
@ -146,7 +147,8 @@ class Configs:
|
|||
curl_options: str = config['CURL_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.
|
||||
silent_mode: bool = config['SILENT_MODE']
|
||||
|
|
|
@ -38,7 +38,7 @@ class Download(Configs, Utilities):
|
|||
for sbo in slackbuilds:
|
||||
file: str = f'{sbo}{self.sbo_tar_suffix}'
|
||||
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.download()
|
||||
|
|
|
@ -50,6 +50,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':
|
||||
|
||||
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:
|
||||
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:
|
||||
raise SystemExit(self.output)
|
||||
|
||||
def lftp(self) -> NoReturn:
|
||||
""" Downloads scripts from ponce repository.
|
||||
|
||||
PONCE URL: https://cgit.ponce.cc/slackbuilds/plain/
|
||||
"""
|
||||
self.output = subprocess.call(f"lftp -c 'mirror {self.lftp_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)
|
||||
|
||||
if self.output != 0:
|
||||
raise SystemExit(self.output)
|
||||
# def lftp(self) -> NoReturn:
|
||||
# """ Downloads scripts from ponce repository.
|
||||
#
|
||||
# PONCE URL: https://cgit.ponce.cc/slackbuilds/plain/
|
||||
# """
|
||||
# self.output = subprocess.call(f"lftp -c 'mirror {self.lftp_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)
|
||||
#
|
||||
# if self.output != 0:
|
||||
# raise SystemExit(self.output)
|
||||
|
||||
def check_if_downloaded(self) -> NoReturn:
|
||||
""" Checks if the file downloaded. """
|
||||
|
@ -95,11 +110,11 @@ class Downloader(Configs, Utilities):
|
|||
message: str = f'[{self.green}Downloading{self.endc}]'
|
||||
|
||||
# Starting multiprocessing
|
||||
if self.ponce_repo and 'ponce' in self.url:
|
||||
p1 = Process(target=self.lftp)
|
||||
else:
|
||||
p1 = Process(target=self.transfer_tools)
|
||||
|
||||
# if self.ponce_repo and 'ponce' in self.url:
|
||||
# p1 = Process(target=self.lftp)
|
||||
# else:
|
||||
# p1 = Process(target=self.transfer_tools)
|
||||
p1 = Process(target=self.transfer_tools)
|
||||
p2 = Process(target=self.progress.bar, args=(message, self.filename))
|
||||
|
||||
p1.start()
|
||||
|
@ -124,9 +139,9 @@ class Downloader(Configs, Utilities):
|
|||
# Restore the terminal cursor
|
||||
print('\x1b[?25h', self.endc)
|
||||
else:
|
||||
if self.ponce_repo and 'ponce' in self.url:
|
||||
self.lftp()
|
||||
else:
|
||||
self.transfer_tools()
|
||||
# if self.ponce_repo and 'ponce' in self.url:
|
||||
# self.lftp()
|
||||
# else:
|
||||
self.transfer_tools()
|
||||
|
||||
self.check_if_downloaded()
|
||||
|
|
|
@ -141,8 +141,8 @@ class Slackbuilds(Configs):
|
|||
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_url}/{location}/{sbo}'
|
||||
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
|
||||
ponce_url: str = f'{self.ponce_url}{location}/{sbo}'
|
||||
|
||||
if self.ponce_repo:
|
||||
path = Path(self.build_path, sbo)
|
||||
|
@ -228,7 +228,7 @@ class Slackbuilds(Configs):
|
|||
self.process_message: str = f"package '{pkg}' to upgrade"
|
||||
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)
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ class UpdateRepository(Configs):
|
|||
self.delete_sbo_data()
|
||||
self.delete_ponce_data()
|
||||
|
||||
slackbuilds_txt: str = f'{self.sbo_repo_url}/{self.sbo_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}'
|
||||
slackbuilds_txt: str = f'{self.sbo_repo_url}{self.sbo_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}'
|
||||
|
||||
down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags)
|
||||
down_slackbuilds.download()
|
||||
|
|
|
@ -46,9 +46,9 @@ class ViewPackage(Configs, Utilities):
|
|||
SBoTable.location
|
||||
).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 = '', '', ''
|
||||
for line in info_file.data.decode().splitlines():
|
||||
|
@ -69,7 +69,7 @@ class ViewPackage(Configs, Utilities):
|
|||
f'Version: {green}{info[1]}{endc}\n'
|
||||
f'Requires: {green}{deps}{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'Download sources: {blue}{info[3]}{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'Slackware: {cyan}{self.sbo_repo_url.split("/")[-1]}{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'Email: {yellow}{email}{endc}\n'
|
||||
f'\nREADME: {cyan}{readme.data.decode()}{endc}')
|
||||
|
|
Loading…
Reference in a new issue