diff --git a/configs/repositories.toml b/configs/repositories.toml index 6aea8775..a2ccfc8f 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -32,6 +32,15 @@ PONCE_REPO_CHANGELOG = "ChangeLog.txt" PONCE_REPO_TAG = "_SBo" + # Official repository for Slackware x86_64 15.0 stable. + # Official repository for Slackware x86_64 -current: https://slackware.uk/slackware/slackware64-current/ + SLACKWARE_REPO = false + SLACKWARE_REPO_NAME = "slackware" + SLACKWARE_REPO_MIRROR = "https://slackware.uk/slackware/slackware64-15.0/" + SLACKWARE_REPO_PACKAGES = "PACKAGES.TXT" + SLACKWARE_REPO_CHECKSUMS = "CHECKSUMS.md5" + SLACKWARE_REPO_CHANGELOG = "ChangeLog.txt" + # Repository for Slackware x86_64 15.0 stable. # Repository for Slackware x86_64 -current: http://slackware.uk/people/alien/sbrepos/current/x86_64/ ALIEN_REPO = false diff --git a/slpkg/check_updates.py b/slpkg/check_updates.py index 5715fab3..12ee4f71 100644 --- a/slpkg/check_updates.py +++ b/slpkg/check_updates.py @@ -37,6 +37,7 @@ class CheckUpdates(Configs): def check(self) -> dict: bin_repositories: dict = { + self.repos.slackware_repo_name: self.slackware_repository, self.repos.alien_repo_name: self.alien_repository, self.repos.multilib_repo_name: self.multilib_repository, self.repos.restricted_repo_name: self.restricted_repository, @@ -70,6 +71,11 @@ class CheckUpdates(Configs): return self.compare + def slackware_repository(self) -> None: + self.local_chg_txt: Path = Path(self.repos.slackware_repo_path, self.repos.slackware_repo_changelog) + self.repo_chg_txt: str = f'{self.repos.slackware_repo_mirror}{self.repos.slackware_repo_changelog}' + self.compare[self.repos.slackware_repo_name] = self.compare_dates() + def alien_repository(self) -> None: self.local_chg_txt: Path = Path(self.repos.alien_repo_path, self.repos.alien_repo_changelog) self.repo_chg_txt: str = f'{self.repos.alien_repo_changelog_mirror}{self.repos.alien_repo_changelog}' diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 5060f796..e8571cd3 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -89,6 +89,91 @@ class InstallData(Configs): self.session.commit() + def install_slackware_data(self) -> None: + """ Install the data for slackware repository. """ + 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.slackware_repo_path, self.repos.slackware_repo_packages) + path_checksums: Path = Path(self.repos.slackware_repo_path, self.repos.slackware_repo_checksums) + path_changelog: Path = Path(self.repos.slackware_repo_path, self.repos.slackware_repo_changelog) + packages_txt: list = self.utils.read_file(path_packages) + checksums_md5: list = self.utils.read_file(path_checksums) + + 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 + + print('Creating the database... ', end='', flush=True) + + 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) + cache.append(self.repos.slackware_repo_mirror) + 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]): + package_size_comp = line.replace(pkg_tag[3], '').strip() + cache.append(f'{package_size_comp}B') + + if line.startswith(pkg_tag[4]): + package_size_uncomp = line.replace(pkg_tag[4], '').strip() + cache.append(f'{package_size_uncomp}B') + + 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.slackware_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], + required='' + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.slackware_repo_name, date=last_updated) + self.session.add(date) + + print(f'{self.byellow}Done{self.endc}') + + self.session.commit() + def install_alien_data(self) -> None: """ Install the data for alien repository. """ checksums_dict: dict = {} diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 0b0e5dd8..a8f6a179 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -43,6 +43,14 @@ class Repositories: ponce_repo_changelog: str = 'ChangeLog.txt' ponce_repo_tag: str = '_SBo' + slackware_repo: bool = False + slackware_repo_name: str = 'slackware' + slackware_repo_path: Path = Path(config.lib_path, 'repositories', slackware_repo_name) + slackware_repo_mirror: str = 'https://slackware.uk/slackware/slackware64-15.0/' + slackware_repo_packages: str = 'PACKAGES.TXT' + slackware_repo_checksums: str = 'CHECKSUMS.md5' + slackware_repo_changelog: str = 'ChangeLog.txt' + alien_repo: bool = False alien_repo_name: str = 'alien' alien_repo_path: Path = Path(config.lib_path, 'repositories', alien_repo_name) @@ -178,6 +186,13 @@ class Repositories: ponce_repo_changelog: str = repos_config['PONCE_REPO_CHANGELOG'] ponce_repo_tag: str = repos_config['PONCE_REPO_TAG'] + slackware_repo: bool = repos_config['SLACKWARE_REPO'] + slackware_repo_name: str = repos_config['SLACKWARE_REPO_NAME'] + slackware_repo_mirror: str = repos_config['SLACKWARE_REPO_MIRROR'] + slackware_repo_packages: str = repos_config['SLACKWARE_REPO_PACKAGES'] + slackware_repo_checksums: str = repos_config['SLACKWARE_REPO_CHECKSUMS'] + slackware_repo_changelog: str = repos_config['SLACKWARE_REPO_CHANGELOG'] + alien_repo: bool = repos_config['ALIEN_REPO'] alien_repo_name: str = repos_config['ALIEN_REPO_NAME'] alien_repo_mirror: str = repos_config['ALIEN_REPO_MIRROR'] @@ -292,6 +307,7 @@ class Repositories: repositories = { sbo_repo_name: [sbo_enabled_repo, sbo_repo_path, sbo_repo_changelog], ponce_repo_name: [ponce_repo, ponce_repo_path, ponce_repo_changelog], + slackware_repo_name: [slackware_repo, slackware_repo_path, slackware_repo_changelog], alien_repo_name: [alien_repo, alien_repo_path, alien_repo_changelog], multilib_repo_name: [multilib_repo, multilib_repo_path, multilib_repo_changelog], restricted_repo_name: [restricted_repo, restricted_repo_path, restricted_repo_changelog], diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index e0c351bd..ec0b8c00 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -59,6 +59,7 @@ class UpdateRepository(Configs): print() bin_repositories: dict = { + self.repos.slackware_repo_name: self.slackware_repository, self.repos.alien_repo_name: self.alien_repository, self.repos.multilib_repo_name: self.multilib_repository, self.repos.restricted_repo_name: self.restricted_repository, @@ -87,6 +88,33 @@ class UpdateRepository(Configs): else: self.slackbuild_repositories() + def slackware_repository(self): + if self.repos.slackware_repo: + urls: list = [] + print('Updating the packages list...\n') + print(f"Downloading the '{self.green}{self.repos.slackware_repo_name}{self.endc}" + f"' repository, please wait...\n") + self.make_dirs(self.repos.slackware_repo_name) + + urls.append(f'{self.repos.slackware_repo_mirror}{self.repos.slackware_repo_packages}') + urls.append(f'{self.repos.slackware_repo_mirror}{self.repos.slackware_repo_changelog}') + urls.append(f'{self.repos.slackware_repo_mirror}{self.repos.slackware_repo_checksums}') + + self.utils.remove_file_if_exists(self.repos.slackware_repo_path, self.repos.slackware_repo_packages) + self.utils.remove_file_if_exists(self.repos.slackware_repo_path, self.repos.slackware_repo_changelog) + self.utils.remove_file_if_exists(self.repos.slackware_repo_path, self.repos.slackware_repo_checksums) + + down = Downloader(self.repos.slackware_repo_path, urls, self.flags) + down.download() + print() + + self.delete_binaries_data(self.repos.slackware_repo_name) + self.delete_last_updated(self.repos.slackware_repo_name) + self.data.install_slackware_data() + print() + else: + self.not_enabled_message(self.repos.slackware_repo_name) + def alien_repository(self): if self.repos.alien_repo: urls: list = []