Added config for delete sources

This commit is contained in:
Dimitris Zlatanidis 2024-05-23 20:39:38 +03:00
parent 59fcb41ccb
commit 496a2be06b
6 changed files with 37 additions and 22 deletions

View file

@ -1,9 +1,10 @@
## slpkg - ChangeLog
### 5.0.9 - 12/05/2024
### 5.0.9 - 23/05/2024
- Added:
* Inform message for invalid package version with the upgrade command
* Config to delete sources after build or install packages
### 5.0.8 - 10/05/2024

View file

@ -1,6 +1,6 @@
# This is the general configuration file of slpkg:
# /etc/slpkg/slpkg.toml
# Updated: 12/05/2024, Version: 5.0.9
# Updated: 23/05/2024, Version: 5.0.9
[CONFIGS]
@ -37,6 +37,10 @@ DIALOG = true
# Default is true. [true/false]
VIEW_MISSING_DEPS = true
# Delete downloaded sources after build or install packages.
# Default is false. [true/false]
DELETE_SOURCES = false
# Choose ascii printable characters.
# If true, it uses the extended characters, otherwise the basic ones.
# Default is true. [true/false].

View file

@ -140,7 +140,6 @@ class Packages(Configs): # pylint: disable=[R0902]
asc_files.append(asc_file)
self.binary_packages.append(package)
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
self.view_process.done()
self.download_the_binary_packages(packages)
@ -183,6 +182,9 @@ class Packages(Configs): # pylint: disable=[R0902]
name: str = self.utils.split_package(package)['name']
self.write_deps_log(name)
if self.delete_sources:
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
def write_deps_log(self, name: str) -> None:
"""Create log file with installed packages with dependencies.

View file

@ -46,6 +46,7 @@ class Configs: # pylint: disable=[R0902]
checksum_md5: bool = True
dialog: bool = True
view_missing_deps: bool = True
delete_sources: bool = False
downloader: str = 'wget'
wget_options: str = '--c -q --progress=bar:force:noscroll --show-progress'
curl_options: str = ''
@ -93,6 +94,7 @@ class Configs: # pylint: disable=[R0902]
checksum_md5: bool = config['checksum_md5']
dialog: bool = config['dialog']
view_missing_deps: bool = config['view_missing_deps']
delete_sources: bool = config['delete_sources']
downloader: str = config['downloader']
wget_options: str = config['wget_options']
curl_options: str = config['curl_options']

View file

@ -76,6 +76,7 @@ class FormConfigs(Configs):
'COLORS',
'DIALOG',
'VIEW_MISSING_DEPS',
'DELETE_SOURCES',
'SILENT_MODE',
'ASCII_CHARACTERS',
'ASK_QUESTION',
@ -127,6 +128,7 @@ class FormConfigs(Configs):
('COLORS =',
'DIALOG =',
'VIEW_MISSING_DEPS =',
'DELETE_SOURCES =',
'SILENT_MODE =',
'ASCII_CHARACTERS =',
'ASK_QUESTION =',

View file

@ -52,7 +52,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.bar_process = None
self.sources: dict = {}
self.install_order: list = []
self.build_order: list = []
self.dependencies: list = []
self.skipped_packages: list = []
self.asc_files: list = []
@ -80,7 +80,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.check_for_skipped()
self.view_slackbuilds_before_build()
self.view.missing_dependencies(self.install_order)
self.view.missing_dependencies(self.build_order)
self.view.question()
start: float = time.time()
@ -105,7 +105,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
def add_dependencies_to_install_order(self) -> None:
"""Add the dependency list in order for install."""
self.install_order.extend(self.dependencies)
self.build_order.extend(self.dependencies)
def clean_the_main_slackbuilds(self) -> None:
"""Remove main packages if they already added as dependency."""
@ -115,18 +115,18 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
def add_main_packages_to_install_order(self) -> None:
"""Add the main packages to order for install."""
self.install_order.extend(self.slackbuilds)
self.build_order.extend(self.slackbuilds)
def check_for_skipped(self) -> None:
"""Check packages for skipped."""
if self.option_for_skip_installed:
for name in self.install_order:
for name in self.build_order:
installed: str = self.utils.is_package_installed(name)
if installed:
self.skipped_packages.append(name)
# Remove packages from skipped packages.
self.install_order: list = [pkg for pkg in self.install_order if pkg not in self.skipped_packages]
self.build_order: list = [pkg for pkg in self.build_order if pkg not in self.skipped_packages]
def view_slackbuilds_before_build(self) -> None:
"""View packages before build."""
@ -137,25 +137,26 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
def prepare_slackbuilds_for_build(self) -> None:
"""Prepare slackbuilds for build."""
if self.install_order:
if self.build_order:
self.view_process.message('Prepare sources for downloading')
for sbo in self.install_order:
for sbo in self.build_order:
build_path: Path = Path(self.build_path, sbo)
self.utils.remove_folder_if_exists(build_path)
# self.utils.remove_folder_if_exists(build_path)
location: str = self.data[sbo]['location']
slackbuild: Path = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
# Copy slackbuilds to the build folder.
path_repo_package: Path = Path(self.repos.repositories[self.repository]['path'], location, sbo)
shutil.copytree(path_repo_package, build_path)
repo_package: Path = Path(self.repos.repositories[self.repository]['path'], location, sbo)
shutil.copytree(repo_package, build_path, dirs_exist_ok=True)
os.chmod(slackbuild, 0o775)
if self.os_arch == 'x86_64' and self.data[sbo]['download64']:
sources: tuple = self.data[sbo]['download64']
else:
sources: tuple = self.data[sbo]['download'] # type: ignore[no-redef]
sources: tuple = self.data[sbo]['download']
if self.gpg_verification and self.repository == self.repos.sbo_repo_name:
asc_file: Path = Path(self.repos.repositories_path, self.repos.sbo_repo_name,
@ -177,7 +178,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
def checksum_downloaded_sources(self) -> None:
"""Checksum the sources."""
for sbo in self.install_order:
for sbo in self.build_order:
path: Path = Path(self.build_path, sbo)
if self.os_arch == 'x86_64' and self.data[sbo]['md5sum64']:
@ -191,24 +192,27 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
self.check_md5.md5sum(path, source, checksum)
def build_and_install_the_slackbuilds(self) -> None:
"""Build an install the slackbuilds."""
# Remove old slpkg.log file.
if self.slpkg_log_file.is_file():
"""Build or install the slackbuilds."""
if self.slpkg_log_file.is_file(): # Remove old slpkg.log file.
self.slpkg_log_file.unlink()
if self.gpg_verification and self.repository == self.repos.sbo_repo_name:
self.gpg.verify(self.asc_files)
if self.install_order:
print(f'Started the processing of ({self.cyan}{len(self.install_order)}{self.endc}) packages:\n')
if self.build_order:
print(f'Started the processing of ({self.cyan}{len(self.build_order)}{self.endc}) packages:\n')
for sbo in self.install_order:
for sbo in self.build_order:
self.patch_slackbuild_tag(sbo)
self.build_the_script(self.build_path, sbo)
if self.mode in ('install', 'upgrade'):
self.install_package(sbo)
if self.delete_sources:
sbo_build_folder: Path = Path(self.build_path, sbo)
self.utils.remove_folder_if_exists(sbo_build_folder)
def patch_slackbuild_tag(self, sbo: str) -> None:
"""Patch the slackbuild tag.