slpkg/slpkg/install_data.py

1654 lines
64 KiB
Python
Raw Normal View History

#!/usr/bin/python3
# -*- coding: utf-8 -*-
2022-12-30 16:40:11 +01:00
2023-05-06 20:11:02 +02:00
import re
2022-12-30 16:40:11 +01:00
from pathlib import Path
2023-02-28 20:43:04 +01:00
2022-06-18 20:35:23 +02:00
from slpkg.configs import Configs
2023-02-28 20:43:04 +01:00
from slpkg.utilities import Utilities
2023-03-20 17:21:36 +01:00
from slpkg.repositories import Repositories
2022-06-17 18:36:07 +02:00
from slpkg.models.models import session as Session
2023-03-30 08:06:14 +02:00
from slpkg.models.models import (SBoTable, PonceTable,
BinariesTable, LastRepoUpdated)
2023-04-24 21:19:05 +02:00
class InstallData(Configs):
def __init__(self):
2023-01-16 23:47:01 +01:00
super(Configs, self).__init__()
self.session = Session
2023-02-28 20:43:04 +01:00
self.utils = Utilities()
2023-03-20 19:08:44 +01:00
self.repos = Repositories()
2023-03-30 08:06:14 +02:00
def last_updated(self, repo_file: Path) -> str:
""" Reads the first date of the changelog file."""
lines: list = self.utils.read_file(repo_file)
days = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
for line in lines:
if line.startswith(days):
return line.replace('\n', '')
2023-05-05 22:15:52 +02:00
def install_sbo_data(self) -> None:
2023-02-28 23:11:20 +01:00
""" Install the data for SBo repository. """
sbo_tags = [
'SLACKBUILD NAME:',
'SLACKBUILD LOCATION:',
'SLACKBUILD FILES:',
'SLACKBUILD VERSION:',
'SLACKBUILD DOWNLOAD:',
'SLACKBUILD DOWNLOAD_x86_64:',
'SLACKBUILD MD5SUM:',
'SLACKBUILD MD5SUM_x86_64:',
'SLACKBUILD REQUIRES:',
'SLACKBUILD SHORT DESCRIPTION:'
]
2023-05-05 22:15:52 +02:00
2023-04-18 20:20:52 +02:00
path_slackbuilds: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds)
2023-03-30 08:06:14 +02:00
path_changelog: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog)
2023-03-05 16:49:15 +01:00
2023-05-05 22:15:52 +02:00
slackbuilds_txt: list = self.utils.read_file(path_slackbuilds)
cache: list = [] # init cache
print(f"Updating the database for '{self.cyan}{self.repos.sbo_repo_name}{self.endc}'... ", end='', flush=True)
for i, line in enumerate(slackbuilds_txt, 1):
for tag in sbo_tags:
if line.startswith(tag):
line = line.replace(tag, '').strip()
cache.append(line)
if (i % 11) == 0:
data: str = SBoTable(name=cache[0], location=cache[1].split('/')[1],
files=cache[2], version=cache[3],
download=cache[4], download64=cache[5],
md5sum=cache[6], md5sum64=cache[7],
requires=cache[8], short_description=cache[9])
self.session.add(data)
cache: list = [] # reset cache after 11 lines
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.sbo_repo_name, date=last_updated)
self.session.add(date)
print(f'{self.byellow}Done{self.endc}\n')
self.session.commit()
def install_ponce_data(self) -> None:
""" Install the data for SBo repository. """
sbo_tags = [
'SLACKBUILD NAME:',
'SLACKBUILD LOCATION:',
'SLACKBUILD FILES:',
'SLACKBUILD VERSION:',
'SLACKBUILD DOWNLOAD:',
'SLACKBUILD DOWNLOAD_x86_64:',
'SLACKBUILD MD5SUM:',
'SLACKBUILD MD5SUM_x86_64:',
'SLACKBUILD REQUIRES:',
'SLACKBUILD SHORT DESCRIPTION:'
]
path_slackbuilds = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds)
path_changelog: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog)
2023-03-05 16:49:15 +01:00
2023-04-18 20:20:52 +02:00
slackbuilds_txt: list = self.utils.read_file(path_slackbuilds)
2023-02-28 22:54:56 +01:00
cache: list = [] # init cache
2023-05-05 22:15:52 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.ponce_repo_name}{self.endc}'... ", end='', flush=True)
2023-03-21 20:11:33 +01:00
for i, line in enumerate(slackbuilds_txt, 1):
2022-06-20 19:43:56 +02:00
for tag in sbo_tags:
if line.startswith(tag):
line = line.replace(tag, '').strip()
cache.append(line)
if (i % 11) == 0:
2023-05-05 22:15:52 +02:00
data: str = PonceTable(name=cache[0], location=cache[1].split('/')[1],
files=cache[2], version=cache[3],
download=cache[4], download64=cache[5],
md5sum=cache[6], md5sum64=cache[7],
requires=cache[8], short_description=cache[9])
self.session.add(data)
2023-02-28 22:54:56 +01:00
cache: list = [] # reset cache after 11 lines
2023-03-30 08:06:14 +02:00
last_updated: str = self.last_updated(path_changelog)
2023-05-05 22:15:52 +02:00
date: str = LastRepoUpdated(repo=self.repos.ponce_repo_name, date=last_updated)
2023-03-30 08:06:14 +02:00
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
self.session.commit()
2023-03-18 20:48:10 +01:00
2023-04-01 21:20:28 +02:00
def install_slack_data(self) -> None:
2023-04-01 20:35:00 +02:00
""" Install the data for slackware repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.slack_repo_name}{self.endc}'... ",
end='', flush=True)
2023-04-01 20:35:00 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
2023-04-01 21:20:28 +02:00
path_packages: Path = Path(self.repos.slack_repo_path, self.repos.slack_repo_packages)
path_checksums: Path = Path(self.repos.slack_repo_path, self.repos.slack_repo_checksums)
path_changelog: Path = Path(self.repos.slack_repo_path, self.repos.slack_repo_changelog)
2023-04-01 20:35:00 +02:00
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 16:07:15 +02:00
mirror: str = self.repos.slack_repo_mirror[0]
if self.repos.slack_repo_local[0].startswith('file'):
mirror: str = self.repos.slack_repo_local[0]
2023-04-01 20:35:00 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-04-01 20:35:00 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[2]):
package_location = line.replace(pkg_tag[2], '').strip()
cache.append(package_location[2:]) # Do not install (.) dot
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 20:35:00 +02:00
if line.startswith(pkg_tag[4]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 20:35:00 +02:00
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
2023-04-01 21:20:28 +02:00
repo=self.repos.slack_repo_name,
2023-04-01 20:35:00 +02:00
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-04-01 20:35:00 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
2023-04-01 21:20:28 +02:00
date: str = LastRepoUpdated(repo=self.repos.slack_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-04-01 21:20:28 +02:00
self.session.commit()
2023-04-02 10:05:51 +02:00
def install_slack_extra_data(self) -> None:
""" Install the data for slackware extra repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.slack_extra_repo_name}{self.endc}'... ",
end='', flush=True)
2023-04-02 10:05:51 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.slack_extra_repo_path, self.repos.slack_extra_repo_packages)
path_checksums: Path = Path(self.repos.slack_extra_repo_path, self.repos.slack_extra_repo_checksums)
path_changelog: Path = Path(self.repos.slack_extra_repo_path, self.repos.slack_extra_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 16:07:15 +02:00
mirror: str = self.repos.slack_extra_repo_mirror[0]
if self.repos.slack_extra_repo_local[0].startswith('file'):
mirror: str = self.repos.slack_extra_repo_local[0]
2023-04-02 10:05:51 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-04-02 10:05:51 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[2]):
package_location = line.replace(pkg_tag[2], '').strip()
cache.append(package_location[2:]) # Do not install (.) dot
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-02 10:05:51 +02:00
if line.startswith(pkg_tag[4]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-02 10:05:51 +02:00
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.slack_extra_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-04-02 10:05:51 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slack_extra_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-04-02 10:05:51 +02:00
self.session.commit()
2023-04-01 21:20:28 +02:00
def install_slack_patches_data(self) -> None:
""" Install the data for slackware patches repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.slack_patches_repo_name}{self.endc}'... ",
end='', flush=True)
2023-04-01 21:20:28 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.slack_patches_repo_path, self.repos.slack_patches_repo_packages)
path_checksums: Path = Path(self.repos.slack_patches_repo_path, self.repos.slack_patches_repo_checksums)
path_changelog: Path = Path(self.repos.slack_patches_repo_path, self.repos.slack_patches_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 16:07:15 +02:00
mirror: str = self.repos.slack_patches_repo_mirror[0]
if self.repos.slack_patches_repo_local[0].startswith('file'):
mirror: str = self.repos.slack_patches_repo_local[0]
2023-04-01 21:20:28 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-04-01 21:20:28 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[2]):
package_location = line.replace(pkg_tag[2], '').strip()
cache.append(package_location[2:]) # Do not install (.) dot
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 21:20:28 +02:00
if line.startswith(pkg_tag[4]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 21:20:28 +02:00
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.slack_patches_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-04-01 21:20:28 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slack_patches_repo_name, date=last_updated)
2023-04-01 20:35:00 +02:00
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-04-01 20:35:00 +02:00
self.session.commit()
2023-03-28 10:19:45 +02:00
def install_alien_data(self) -> None:
""" Install the data for alien repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.alien_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-28 10:19:45 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_packages)
path_checksums: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_checksums)
2023-03-30 08:06:14 +02:00
path_changelog: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_changelog)
2023-03-28 10:19:45 +02:00
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 16:07:15 +02:00
mirror: str = ''.join(self.repos.alien_repo_mirror)
if self.repos.alien_repo_local[0].startswith('file'):
mirror: str = ''.join(self.repos.alien_repo_local)
2023-03-28 10:19:45 +02:00
for line in checksums_md5:
line = line.strip()
2023-03-29 17:20:41 +02:00
if line.endswith(('.txz', '.tgz')):
2023-03-28 10:19:45 +02:00
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
2023-03-28 12:15:53 +02:00
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
2023-03-28 10:19:45 +02:00
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-03-28 10:19:45 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
2023-03-31 20:20:55 +02:00
cache.append(package_location[2:]) # Do not install (.) dot
2023-03-28 10:19:45 +02:00
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-28 10:19:45 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-28 10:19:45 +02:00
if line.startswith(pkg_tag[4]):
2023-03-28 11:11:29 +02:00
required = line.replace(pkg_tag[4], '').strip()
package_required = required.replace(',', ' ').strip()
2023-03-28 10:19:45 +02:00
cache.append(package_required)
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.alien_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
2023-04-02 18:13:50 +02:00
description=cache[9],
conflicts='',
suggests=''
2023-03-28 10:19:45 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
2023-03-30 08:06:14 +02:00
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.alien_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-28 10:19:45 +02:00
self.session.commit()
2023-03-30 21:44:40 +02:00
def install_multilib_data(self) -> None:
""" Install the data for multilib repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.multilib_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-30 21:44:40 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_packages)
path_checksums: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_checksums)
path_changelog: Path = Path(self.repos.multilib_repo_path, self.repos.multilib_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 16:07:15 +02:00
mirror: str = ''.join(self.repos.multilib_repo_mirror)
if self.repos.multilib_repo_local[0].startswith('file'):
mirror: str = ''.join(self.repos.multilib_repo_local)
2023-03-30 21:44:40 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-03-30 21:44:40 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
2023-03-31 20:20:55 +02:00
cache.append(package_location[2:]) # Do not install (./) dot
2023-03-30 21:44:40 +02:00
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-30 21:44:40 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-30 21:44:40 +02:00
if line.startswith(pkg_tag[4]):
package_description = line.replace(pkg_tag[4], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.multilib_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-03-30 21:44:40 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.multilib_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-30 21:44:40 +02:00
self.session.commit()
2023-03-30 22:41:29 +02:00
def install_restricted_data(self) -> None:
""" Install the data for multilib repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.restricted_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-30 22:41:29 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_packages)
path_checksums: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_checksums)
path_changelog: Path = Path(self.repos.restricted_repo_path, self.repos.restricted_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 16:07:15 +02:00
mirror: str = ''.join(self.repos.restricted_repo_mirror)
if self.repos.restricted_repo_local[0].startswith('file'):
mirror: str = ''.join(self.repos.restricted_repo_local)
2023-03-30 22:41:29 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-03-30 22:41:29 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
2023-03-31 20:20:55 +02:00
cache.append(package_location[2:]) # Do not install (./) dot
2023-03-30 22:41:29 +02:00
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-30 22:41:29 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-30 22:41:29 +02:00
if line.startswith(pkg_tag[4]):
package_description = line.replace(pkg_tag[4], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.restricted_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-03-30 22:41:29 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.restricted_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-30 22:41:29 +02:00
self.session.commit()
2023-03-20 17:21:36 +01:00
def install_gnome_data(self) -> None:
2023-03-21 20:11:33 +01:00
""" Install the data for gnome repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.gnome_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-25 19:38:49 +01:00
checksums_dict: dict = {}
2023-03-19 22:42:26 +01:00
pkg_tag = [
2023-03-18 20:48:10 +01:00
'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
2023-03-21 20:11:33 +01:00
'PACKAGE DESCRIPTION:'
2023-03-18 20:48:10 +01:00
]
2023-03-25 20:02:31 +01:00
path_packages: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_packages)
path_checksums: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_checksums)
2023-03-30 08:06:14 +02:00
path_changelog: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog)
2023-03-25 19:38:49 +01:00
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-03-18 20:48:10 +01:00
2023-04-30 16:07:15 +02:00
mirror: str = self.repos.gnome_repo_mirror[0]
if self.repos.gnome_repo_local[0].startswith('file'):
mirror: str = self.repos.gnome_repo_local[0]
2023-03-25 19:38:49 +01:00
for line in checksums_md5:
line = line.strip()
2023-03-29 17:20:41 +02:00
if line.endswith(('.txz', '.tgz')):
2023-03-25 20:02:31 +01:00
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
2023-03-18 20:48:10 +01:00
cache: list = [] # init cache
2023-03-21 20:11:33 +01:00
for line in packages_txt:
2023-03-18 20:48:10 +01:00
2023-03-19 22:42:26 +01:00
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
2023-03-28 12:15:53 +02:00
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
2023-03-19 22:42:26 +01:00
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-03-25 19:38:49 +01:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
2023-03-19 22:42:26 +01:00
if line.startswith(pkg_tag[2]):
package_location = line.replace(pkg_tag[2], '').strip()
2023-03-20 11:59:32 +01:00
cache.append(package_location[1:]) # Do not install (.) dot
2023-03-19 22:42:26 +01:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-19 22:42:26 +01:00
if line.startswith(pkg_tag[4]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-19 22:42:26 +01:00
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
2023-03-25 19:38:49 +01:00
if len(cache) == 9:
2023-03-19 22:42:26 +01:00
data: str = BinariesTable(
2023-03-21 15:37:56 +01:00
repo=self.repos.gnome_repo_name,
2023-03-19 22:42:26 +01:00
name=cache[0],
version=cache[1],
package=cache[2],
2023-03-30 09:00:37 +02:00
mirror=cache[3],
checksum=cache[4],
2023-03-25 19:38:49 +01:00
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
2023-03-30 20:34:53 +02:00
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-03-21 20:11:33 +01:00
)
self.session.add(data)
cache: list = [] # reset cache
2023-03-30 08:06:14 +02:00
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.gnome_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-21 20:11:33 +01:00
self.session.commit()
2023-04-01 13:21:48 +02:00
def install_msb_data(self) -> None:
""" Install the data for msb repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.msb_repo_name}{self.endc}'... ",
end='', flush=True)
2023-04-01 13:21:48 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_packages)
path_checksums: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_checksums)
path_changelog: Path = Path(self.repos.msb_repo_path, self.repos.msb_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 16:07:15 +02:00
mirror: str = ''.join(self.repos.msb_repo_mirror)
if self.repos.msb_repo_local[0].startswith('file'):
mirror: str = ''.join(self.repos.msb_repo_local)
2023-04-01 13:21:48 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 16:07:15 +02:00
cache.append(mirror)
2023-04-01 13:21:48 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 13:21:48 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 13:21:48 +02:00
if line.startswith(pkg_tag[4]):
package_description = line.replace(pkg_tag[4], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.msb_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-04-01 13:21:48 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.msb_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-04-01 13:21:48 +02:00
self.session.commit()
2023-04-01 15:56:47 +02:00
def install_csb_data(self) -> None:
""" Install the data for csb repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.csb_repo_name}{self.endc}'... ",
end='', flush=True)
2023-04-01 15:56:47 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.csb_repo_path, self.repos.csb_repo_packages)
path_checksums: Path = Path(self.repos.csb_repo_path, self.repos.csb_repo_checksums)
path_changelog: Path = Path(self.repos.csb_repo_path, self.repos.csb_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = ''.join(self.repos.csb_repo_mirror)
if self.repos.csb_repo_local[0].startswith('file'):
mirror: str = ''.join(self.repos.csb_repo_local)
2023-04-01 15:56:47 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-04-01 15:56:47 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 15:56:47 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-01 15:56:47 +02:00
if line.startswith(pkg_tag[4]):
package_description = line.replace(pkg_tag[4], '').strip()
cache.append(package_description)
if len(cache) == 9:
data: str = BinariesTable(
repo=self.repos.csb_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
description=cache[8],
2023-04-02 18:13:50 +02:00
required='',
conflicts='',
suggests=''
2023-04-01 15:56:47 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.csb_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-04-01 15:56:47 +02:00
self.session.commit()
2023-03-21 20:11:33 +01:00
def install_conraid_data(self) -> None:
""" Install the data for conraid repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.conraid_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-25 19:38:49 +01:00
checksums_dict: dict = {}
2023-03-21 20:11:33 +01:00
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE MIRROR:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:'
]
2023-03-25 20:02:31 +01:00
path_packages: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_packages)
path_checksums: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_checksums)
2023-03-30 08:06:14 +02:00
path_changelog: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog)
2023-04-30 17:04:01 +02:00
packages_txt: list = self.utils.read_file(path_packages)
2023-03-25 19:38:49 +01:00
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = self.repos.conraid_repo_mirror[0]
if self.repos.conraid_repo_local[0].startswith('file'):
mirror: str = self.repos.conraid_repo_local[0]
2023-03-25 19:38:49 +01:00
for line in checksums_md5:
line = line.strip()
2023-03-21 20:11:33 +01:00
2023-03-29 17:20:41 +02:00
if line.endswith(('.txz', '.tgz')):
2023-03-25 20:02:31 +01:00
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
2023-03-21 20:11:33 +01:00
cache: list = []
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name: str = line.replace(pkg_tag[0], '').strip()
2023-03-28 12:15:53 +02:00
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
2023-03-21 20:11:33 +01:00
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-03-25 19:38:49 +01:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
2023-03-21 20:11:33 +01:00
if line.startswith(pkg_tag[2]):
package_location: str = line.replace(pkg_tag[2], '').strip()
2023-03-25 11:35:18 +01:00
cache.append(package_location[2:]) # Do not install (./) dot
2023-03-21 20:11:33 +01:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-21 20:11:33 +01:00
if line.startswith(pkg_tag[4]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-21 20:11:33 +01:00
if line.startswith(pkg_tag[5]):
package_description: str = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
2023-03-25 19:38:49 +01:00
if len(cache) == 9:
2023-03-21 20:11:33 +01:00
data: str = BinariesTable(
repo=self.repos.conraid_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
2023-03-30 09:00:37 +02:00
mirror=cache[3],
checksum=cache[4],
2023-03-25 19:38:49 +01:00
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
2023-03-30 20:34:53 +02:00
description=cache[8],
required='',
2023-04-02 18:13:50 +02:00
conflicts='',
suggests=''
2023-03-19 22:42:26 +01:00
)
2023-03-18 20:48:10 +01:00
2023-03-19 22:42:26 +01:00
self.session.add(data)
2023-03-18 21:10:27 +01:00
2023-03-21 20:11:33 +01:00
cache: list = [] # reset cache
2023-03-18 21:10:27 +01:00
2023-03-30 08:06:14 +02:00
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.conraid_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-18 21:10:27 +01:00
2023-03-19 22:42:26 +01:00
self.session.commit()
2023-03-28 20:56:55 +02:00
def install_slackonly_data(self) -> None:
""" Install the data for slackonly repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.slackonly_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-28 20:56:55 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_packages)
path_checksums: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_checksums)
2023-03-30 08:06:14 +02:00
path_changelog: Path = Path(self.repos.slackonly_repo_path, self.repos.slackonly_repo_changelog)
2023-03-28 20:56:55 +02:00
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = self.repos.slackonly_repo_mirror[0]
if self.repos.slackonly_repo_local[0].startswith('file'):
mirror: str = self.repos.slackonly_repo_local[0]
2023-03-28 20:56:55 +02:00
for line in checksums_md5:
line = line.strip()
2023-03-29 17:20:41 +02:00
if line.endswith(('.txz', '.tgz')):
2023-03-28 20:56:55 +02:00
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-03-28 20:56:55 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
2023-03-31 20:20:55 +02:00
cache.append(package_location[2:]) # Do not install (./) dot
2023-03-28 20:56:55 +02:00
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-28 20:56:55 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-28 20:56:55 +02:00
if line.startswith(pkg_tag[4]):
required = line.replace(pkg_tag[4], '').strip()
package_required = required.replace(',', ' ').strip()
cache.append(package_required)
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.slackonly_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
2023-04-02 18:13:50 +02:00
description=cache[9],
conflicts='',
suggests=''
2023-03-28 20:56:55 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
2023-03-30 08:06:14 +02:00
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slackonly_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-28 20:56:55 +02:00
self.session.commit()
2023-03-30 20:21:29 +02:00
2023-03-31 11:16:18 +02:00
def install_salixos_data(self) -> None:
2023-03-31 19:08:39 +02:00
""" Install the data for salixos repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.salixos_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-31 11:16:18 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_packages)
path_checksums: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_checksums)
path_changelog: Path = Path(self.repos.salixos_repo_path, self.repos.salixos_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = self.repos.salixos_repo_mirror[0]
if self.repos.salixos_repo_local[0].startswith('file'):
mirror: str = self.repos.salixos_repo_local[0]
2023-03-31 11:16:18 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-03-31 11:16:18 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
2023-03-31 20:20:55 +02:00
cache.append(package_location[2:]) # Do not install (./) dot
2023-03-31 11:16:18 +02:00
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 11:16:18 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 11:16:18 +02:00
if line.startswith(pkg_tag[4]):
2023-03-31 18:08:12 +02:00
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
2023-05-06 21:28:21 +02:00
deps.extend(dep)
2023-03-31 18:08:12 +02:00
cache.append(' '.join(deps))
2023-03-31 11:16:18 +02:00
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.salixos_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
2023-04-02 18:13:50 +02:00
description=cache[9],
conflicts='',
suggests=''
2023-03-31 11:16:18 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.salixos_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-31 11:16:18 +02:00
self.session.commit()
2023-03-31 19:08:39 +02:00
2023-03-31 19:55:40 +02:00
def install_salixos_extra_data(self) -> None:
""" Install the data for salixos_extra repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.salixos_extra_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-31 19:55:40 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_packages)
path_checksums: Path = Path(self.repos.salixos_extra_repo_path, self.repos.salixos_extra_repo_checksums)
path_changelog: Path = Path(self.repos.salixos_extra_repo_path,
self.repos.salixos_extra_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = self.repos.salixos_extra_repo_mirror[0]
if self.repos.salixos_extra_repo_local[0].startswith('file'):
mirror: str = self.repos.salixos_extra_repo_local[0]
2023-03-31 19:55:40 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-03-31 19:55:40 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
2023-03-31 20:20:55 +02:00
cache.append(package_location[2:]) # Do not install (./) dot
2023-03-31 19:55:40 +02:00
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 19:55:40 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 19:55:40 +02:00
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
2023-05-06 21:28:21 +02:00
deps.extend(dep)
2023-03-31 19:55:40 +02:00
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.salixos_extra_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
2023-04-02 18:13:50 +02:00
description=cache[9],
conflicts='',
suggests=''
2023-03-31 19:55:40 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.salixos_extra_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-31 19:55:40 +02:00
self.session.commit()
2023-04-02 10:35:04 +02:00
def install_salixos_patches_data(self) -> None:
""" Install the data for salixos_patches repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.salixos_patches_repo_name}{self.endc}'... ",
end='', flush=True)
2023-04-02 10:35:04 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.salixos_patches_repo_path, self.repos.salixos_patches_repo_packages)
path_checksums: Path = Path(self.repos.salixos_patches_repo_path, self.repos.salixos_patches_repo_checksums)
path_changelog: Path = Path(self.repos.salixos_patches_repo_path,
self.repos.salixos_patches_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = self.repos.salixos_patches_repo_mirror[0]
if self.repos.salixos_patches_repo_local[0].startswith('file'):
mirror: str = self.repos.salixos_patches_repo_local[0]
2023-04-02 10:35:04 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-04-02 10:35:04 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-02 10:35:04 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-04-02 10:35:04 +02:00
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
2023-05-06 21:28:21 +02:00
deps.extend(dep)
2023-04-02 10:35:04 +02:00
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.salixos_patches_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
2023-04-02 18:13:50 +02:00
description=cache[9],
conflicts='',
suggests=''
2023-04-02 10:35:04 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.salixos_patches_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-04-02 10:35:04 +02:00
self.session.commit()
2023-03-31 19:08:39 +02:00
def install_slackel_data(self) -> None:
""" Install the data for slackel repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.slackel_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-31 19:08:39 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_packages)
path_checksums: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_checksums)
path_changelog: Path = Path(self.repos.slackel_repo_path, self.repos.slackel_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = self.repos.slackel_repo_mirror[0]
if self.repos.slackel_repo_local[0].startswith('file'):
mirror: str = self.repos.slackel_repo_local[0]
2023-03-31 19:08:39 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-03-31 19:08:39 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
2023-03-31 20:20:55 +02:00
cache.append(package_location[2:]) # Do not install (./) dot
2023-03-31 19:08:39 +02:00
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 19:08:39 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 19:08:39 +02:00
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
2023-05-06 21:28:21 +02:00
deps.extend(dep)
2023-03-31 19:08:39 +02:00
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.slackel_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
2023-04-02 18:13:50 +02:00
description=cache[9],
conflicts='',
suggests=''
2023-03-31 19:08:39 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slackel_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-31 19:08:39 +02:00
self.session.commit()
2023-03-31 21:12:28 +02:00
def install_slint_data(self) -> None:
""" Install the data for slint repository. """
2023-04-18 20:55:57 +02:00
print(f"Updating the database for '{self.cyan}{self.repos.slint_repo_name}{self.endc}'... ",
end='', flush=True)
2023-03-31 21:12:28 +02:00
checksums_dict: dict = {}
pkg_tag = [
'PACKAGE NAME:',
'PACKAGE LOCATION:',
'PACKAGE SIZE (compressed):',
'PACKAGE SIZE (uncompressed):',
'PACKAGE REQUIRED:',
'PACKAGE DESCRIPTION:'
]
path_packages: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_packages)
path_checksums: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_checksums)
path_changelog: Path = Path(self.repos.slint_repo_path, self.repos.slint_repo_changelog)
packages_txt: list = self.utils.read_file(path_packages)
checksums_md5: list = self.utils.read_file(path_checksums)
2023-04-30 17:04:01 +02:00
mirror: str = self.repos.slint_repo_mirror[0]
if self.repos.slint_repo_local[0].startswith('file'):
mirror: str = self.repos.slint_repo_local[0]
2023-03-31 21:12:28 +02:00
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
file: str = line.split('./')[1].split('/')[-1].strip()
checksum: str = line.split('./')[0].strip()
checksums_dict[file] = checksum
cache: list = [] # init cache
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package_name = line.replace(pkg_tag[0], '').strip()
split_package: list = self.utils.split_binary_pkg(package_name)
cache.append(split_package[0]) # package name
cache.append(split_package[1]) # package version
cache.append(package_name)
2023-04-30 17:04:01 +02:00
cache.append(mirror)
2023-03-31 21:12:28 +02:00
try:
cache.append(checksums_dict[package_name])
except KeyError:
cache.append('error checksum')
if line.startswith(pkg_tag[1]):
package_location = line.replace(pkg_tag[1], '').strip()
cache.append(package_location[2:]) # Do not install (./) dot
if line.startswith(pkg_tag[2]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 21:12:28 +02:00
if line.startswith(pkg_tag[3]):
2023-05-06 20:11:02 +02:00
cache.append(''.join(re.findall(r'\d+', line)))
2023-03-31 21:12:28 +02:00
if line.startswith(pkg_tag[4]):
deps: list = []
required = line.replace(pkg_tag[4], '').strip()
for req in required.split(','):
dep = req.split('|')
if len(dep) > 1:
deps.append(dep[1])
else:
2023-05-06 21:28:21 +02:00
deps.extend(dep)
2023-03-31 21:12:28 +02:00
cache.append(' '.join(deps))
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()
cache.append(package_description)
if len(cache) == 10:
data: str = BinariesTable(
repo=self.repos.slint_repo_name,
name=cache[0],
version=cache[1],
package=cache[2],
mirror=cache[3],
checksum=cache[4],
location=cache[5],
size_comp=cache[6],
size_uncomp=cache[7],
required=cache[8],
2023-04-02 18:13:50 +02:00
description=cache[9],
conflicts='',
suggests=''
2023-03-31 21:12:28 +02:00
)
self.session.add(data)
cache: list = [] # reset cache
last_updated: str = self.last_updated(path_changelog)
date: str = LastRepoUpdated(repo=self.repos.slint_repo_name, date=last_updated)
self.session.add(date)
2023-05-05 22:15:52 +02:00
print(f'{self.byellow}Done{self.endc}\n')
2023-03-31 21:12:28 +02:00
self.session.commit()