mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Added config for delete sources
This commit is contained in:
parent
59fcb41ccb
commit
496a2be06b
6 changed files with 37 additions and 22 deletions
|
@ -1,9 +1,10 @@
|
||||||
## slpkg - ChangeLog
|
## slpkg - ChangeLog
|
||||||
|
|
||||||
### 5.0.9 - 12/05/2024
|
### 5.0.9 - 23/05/2024
|
||||||
|
|
||||||
- Added:
|
- Added:
|
||||||
* Inform message for invalid package version with the upgrade command
|
* 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
|
### 5.0.8 - 10/05/2024
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# This is the general configuration file of slpkg:
|
# This is the general configuration file of slpkg:
|
||||||
# /etc/slpkg/slpkg.toml
|
# /etc/slpkg/slpkg.toml
|
||||||
# Updated: 12/05/2024, Version: 5.0.9
|
# Updated: 23/05/2024, Version: 5.0.9
|
||||||
|
|
||||||
[CONFIGS]
|
[CONFIGS]
|
||||||
|
|
||||||
|
@ -37,6 +37,10 @@ DIALOG = true
|
||||||
# Default is true. [true/false]
|
# Default is true. [true/false]
|
||||||
VIEW_MISSING_DEPS = true
|
VIEW_MISSING_DEPS = true
|
||||||
|
|
||||||
|
# Delete downloaded sources after build or install packages.
|
||||||
|
# Default is false. [true/false]
|
||||||
|
DELETE_SOURCES = false
|
||||||
|
|
||||||
# Choose ascii printable characters.
|
# Choose ascii printable characters.
|
||||||
# If true, it uses the extended characters, otherwise the basic ones.
|
# If true, it uses the extended characters, otherwise the basic ones.
|
||||||
# Default is true. [true/false].
|
# Default is true. [true/false].
|
||||||
|
|
|
@ -140,7 +140,6 @@ class Packages(Configs): # pylint: disable=[R0902]
|
||||||
asc_files.append(asc_file)
|
asc_files.append(asc_file)
|
||||||
|
|
||||||
self.binary_packages.append(package)
|
self.binary_packages.append(package)
|
||||||
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
|
|
||||||
|
|
||||||
self.view_process.done()
|
self.view_process.done()
|
||||||
self.download_the_binary_packages(packages)
|
self.download_the_binary_packages(packages)
|
||||||
|
@ -183,6 +182,9 @@ class Packages(Configs): # pylint: disable=[R0902]
|
||||||
name: str = self.utils.split_package(package)['name']
|
name: str = self.utils.split_package(package)['name']
|
||||||
self.write_deps_log(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:
|
def write_deps_log(self, name: str) -> None:
|
||||||
"""Create log file with installed packages with dependencies.
|
"""Create log file with installed packages with dependencies.
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ class Configs: # pylint: disable=[R0902]
|
||||||
checksum_md5: bool = True
|
checksum_md5: bool = True
|
||||||
dialog: bool = True
|
dialog: bool = True
|
||||||
view_missing_deps: bool = True
|
view_missing_deps: bool = True
|
||||||
|
delete_sources: bool = False
|
||||||
downloader: str = 'wget'
|
downloader: str = 'wget'
|
||||||
wget_options: str = '--c -q --progress=bar:force:noscroll --show-progress'
|
wget_options: str = '--c -q --progress=bar:force:noscroll --show-progress'
|
||||||
curl_options: str = ''
|
curl_options: str = ''
|
||||||
|
@ -93,6 +94,7 @@ class Configs: # pylint: disable=[R0902]
|
||||||
checksum_md5: bool = config['checksum_md5']
|
checksum_md5: bool = config['checksum_md5']
|
||||||
dialog: bool = config['dialog']
|
dialog: bool = config['dialog']
|
||||||
view_missing_deps: bool = config['view_missing_deps']
|
view_missing_deps: bool = config['view_missing_deps']
|
||||||
|
delete_sources: bool = config['delete_sources']
|
||||||
downloader: str = config['downloader']
|
downloader: str = config['downloader']
|
||||||
wget_options: str = config['wget_options']
|
wget_options: str = config['wget_options']
|
||||||
curl_options: str = config['curl_options']
|
curl_options: str = config['curl_options']
|
||||||
|
|
|
@ -76,6 +76,7 @@ class FormConfigs(Configs):
|
||||||
'COLORS',
|
'COLORS',
|
||||||
'DIALOG',
|
'DIALOG',
|
||||||
'VIEW_MISSING_DEPS',
|
'VIEW_MISSING_DEPS',
|
||||||
|
'DELETE_SOURCES',
|
||||||
'SILENT_MODE',
|
'SILENT_MODE',
|
||||||
'ASCII_CHARACTERS',
|
'ASCII_CHARACTERS',
|
||||||
'ASK_QUESTION',
|
'ASK_QUESTION',
|
||||||
|
@ -127,6 +128,7 @@ class FormConfigs(Configs):
|
||||||
('COLORS =',
|
('COLORS =',
|
||||||
'DIALOG =',
|
'DIALOG =',
|
||||||
'VIEW_MISSING_DEPS =',
|
'VIEW_MISSING_DEPS =',
|
||||||
|
'DELETE_SOURCES =',
|
||||||
'SILENT_MODE =',
|
'SILENT_MODE =',
|
||||||
'ASCII_CHARACTERS =',
|
'ASCII_CHARACTERS =',
|
||||||
'ASK_QUESTION =',
|
'ASK_QUESTION =',
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
|
||||||
|
|
||||||
self.bar_process = None
|
self.bar_process = None
|
||||||
self.sources: dict = {}
|
self.sources: dict = {}
|
||||||
self.install_order: list = []
|
self.build_order: list = []
|
||||||
self.dependencies: list = []
|
self.dependencies: list = []
|
||||||
self.skipped_packages: list = []
|
self.skipped_packages: list = []
|
||||||
self.asc_files: list = []
|
self.asc_files: list = []
|
||||||
|
@ -80,7 +80,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
|
||||||
self.check_for_skipped()
|
self.check_for_skipped()
|
||||||
|
|
||||||
self.view_slackbuilds_before_build()
|
self.view_slackbuilds_before_build()
|
||||||
self.view.missing_dependencies(self.install_order)
|
self.view.missing_dependencies(self.build_order)
|
||||||
self.view.question()
|
self.view.question()
|
||||||
|
|
||||||
start: float = time.time()
|
start: float = time.time()
|
||||||
|
@ -105,7 +105,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
|
||||||
|
|
||||||
def add_dependencies_to_install_order(self) -> None:
|
def add_dependencies_to_install_order(self) -> None:
|
||||||
"""Add the dependency list in order for install."""
|
"""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:
|
def clean_the_main_slackbuilds(self) -> None:
|
||||||
"""Remove main packages if they already added as dependency."""
|
"""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:
|
def add_main_packages_to_install_order(self) -> None:
|
||||||
"""Add the main packages to order for install."""
|
"""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:
|
def check_for_skipped(self) -> None:
|
||||||
"""Check packages for skipped."""
|
"""Check packages for skipped."""
|
||||||
if self.option_for_skip_installed:
|
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)
|
installed: str = self.utils.is_package_installed(name)
|
||||||
if installed:
|
if installed:
|
||||||
self.skipped_packages.append(name)
|
self.skipped_packages.append(name)
|
||||||
|
|
||||||
# Remove packages from skipped packages.
|
# 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:
|
def view_slackbuilds_before_build(self) -> None:
|
||||||
"""View packages before build."""
|
"""View packages before build."""
|
||||||
|
@ -137,25 +137,26 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
|
||||||
|
|
||||||
def prepare_slackbuilds_for_build(self) -> None:
|
def prepare_slackbuilds_for_build(self) -> None:
|
||||||
"""Prepare slackbuilds for build."""
|
"""Prepare slackbuilds for build."""
|
||||||
if self.install_order:
|
if self.build_order:
|
||||||
self.view_process.message('Prepare sources for downloading')
|
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)
|
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']
|
location: str = self.data[sbo]['location']
|
||||||
slackbuild: Path = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
slackbuild: Path = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
||||||
|
|
||||||
# Copy slackbuilds to the build folder.
|
# Copy slackbuilds to the build folder.
|
||||||
path_repo_package: Path = Path(self.repos.repositories[self.repository]['path'], location, sbo)
|
repo_package: Path = Path(self.repos.repositories[self.repository]['path'], location, sbo)
|
||||||
shutil.copytree(path_repo_package, build_path)
|
|
||||||
|
shutil.copytree(repo_package, build_path, dirs_exist_ok=True)
|
||||||
|
|
||||||
os.chmod(slackbuild, 0o775)
|
os.chmod(slackbuild, 0o775)
|
||||||
|
|
||||||
if self.os_arch == 'x86_64' and self.data[sbo]['download64']:
|
if self.os_arch == 'x86_64' and self.data[sbo]['download64']:
|
||||||
sources: tuple = self.data[sbo]['download64']
|
sources: tuple = self.data[sbo]['download64']
|
||||||
else:
|
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:
|
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,
|
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:
|
def checksum_downloaded_sources(self) -> None:
|
||||||
"""Checksum the sources."""
|
"""Checksum the sources."""
|
||||||
for sbo in self.install_order:
|
for sbo in self.build_order:
|
||||||
path: Path = Path(self.build_path, sbo)
|
path: Path = Path(self.build_path, sbo)
|
||||||
|
|
||||||
if self.os_arch == 'x86_64' and self.data[sbo]['md5sum64']:
|
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)
|
self.check_md5.md5sum(path, source, checksum)
|
||||||
|
|
||||||
def build_and_install_the_slackbuilds(self) -> None:
|
def build_and_install_the_slackbuilds(self) -> None:
|
||||||
"""Build an install the slackbuilds."""
|
"""Build or install the slackbuilds."""
|
||||||
# Remove old slpkg.log file.
|
if self.slpkg_log_file.is_file(): # Remove old slpkg.log file.
|
||||||
if self.slpkg_log_file.is_file():
|
|
||||||
self.slpkg_log_file.unlink()
|
self.slpkg_log_file.unlink()
|
||||||
|
|
||||||
if self.gpg_verification and self.repository == self.repos.sbo_repo_name:
|
if self.gpg_verification and self.repository == self.repos.sbo_repo_name:
|
||||||
self.gpg.verify(self.asc_files)
|
self.gpg.verify(self.asc_files)
|
||||||
|
|
||||||
if self.install_order:
|
if self.build_order:
|
||||||
print(f'Started the processing of ({self.cyan}{len(self.install_order)}{self.endc}) packages:\n')
|
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.patch_slackbuild_tag(sbo)
|
||||||
self.build_the_script(self.build_path, sbo)
|
self.build_the_script(self.build_path, sbo)
|
||||||
|
|
||||||
if self.mode in ('install', 'upgrade'):
|
if self.mode in ('install', 'upgrade'):
|
||||||
self.install_package(sbo)
|
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:
|
def patch_slackbuild_tag(self, sbo: str) -> None:
|
||||||
"""Patch the slackbuild tag.
|
"""Patch the slackbuild tag.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue