mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-31 10:26:39 +01:00
Updated for slackbuild
This commit is contained in:
parent
76e0ee92cd
commit
544f5ec764
1 changed files with 53 additions and 70 deletions
|
@ -50,7 +50,6 @@ class Slackbuilds(Configs):
|
||||||
|
|
||||||
self.stderr = None
|
self.stderr = None
|
||||||
self.stdout = None
|
self.stdout = None
|
||||||
self.sbos: dict = {}
|
|
||||||
self.install_order: list = []
|
self.install_order: list = []
|
||||||
self.dependencies: list = []
|
self.dependencies: list = []
|
||||||
self.process_message: str = ''
|
self.process_message: str = ''
|
||||||
|
@ -84,62 +83,57 @@ class Slackbuilds(Configs):
|
||||||
|
|
||||||
def execute(self) -> None:
|
def execute(self) -> None:
|
||||||
""" Starting build or install the slackbuilds. """
|
""" Starting build or install the slackbuilds. """
|
||||||
self.creating_dictionary()
|
self.creating_dependencies_list()
|
||||||
self.creating_dependencies_for_build()
|
self.remove_duplicate_slackbuilds_from_dependencies()
|
||||||
self.creating_main_for_build()
|
self.add_dependencies_slackbuilds_to_install_list()
|
||||||
self.view_before_build()
|
self.clean_the_main_slackbuilds()
|
||||||
|
self.add_main_packages_to_install_list()
|
||||||
|
self.view_slackbuilds_before_build()
|
||||||
|
|
||||||
start: float = time.time()
|
start: float = time.time()
|
||||||
self.prepare_slackbuilds_for_build()
|
self.prepare_slackbuilds_for_build()
|
||||||
self.build_and_install()
|
self.build_and_install_the_slackbuilds()
|
||||||
elapsed_time: float = time.time() - start
|
elapsed_time: float = time.time() - start
|
||||||
|
|
||||||
self.utils.finished_time(elapsed_time)
|
self.utils.finished_time(elapsed_time)
|
||||||
|
|
||||||
def creating_dictionary(self) -> None:
|
def creating_dependencies_list(self) -> None:
|
||||||
""" Dictionary with the main slackbuilds and dependencies. """
|
""" Dictionary with the main slackbuilds and dependencies. """
|
||||||
for sbo in self.slackbuilds:
|
if not self.option_for_resolve_off:
|
||||||
if self.option_for_resolve_off:
|
for sbo in self.slackbuilds:
|
||||||
self.sbos[sbo] = []
|
deps: list = Requires(self.data, sbo).resolve()
|
||||||
else:
|
|
||||||
self.sbos[sbo] = Requires(self.data, sbo).resolve()
|
|
||||||
|
|
||||||
def creating_dependencies_for_build(self) -> None:
|
for dep in deps:
|
||||||
""" List with the dependencies. """
|
# Skip installed package when the option --skip-installed is applied.
|
||||||
for deps in self.sbos.values():
|
if self.option_for_skip_installed and self.utils.is_package_installed(dep):
|
||||||
for dep in deps:
|
continue
|
||||||
|
|
||||||
# Skip installed package when the option --skip-installed is applied.
|
self.dependencies.append(dep)
|
||||||
if self.option_for_skip_installed and self.utils.is_package_installed(dep):
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.dependencies.append(dep)
|
def remove_duplicate_slackbuilds_from_dependencies(self):
|
||||||
|
if self.dependencies:
|
||||||
# Remove duplicate packages and keeps the order.
|
# Remove duplicate packages and keeps the order.
|
||||||
dependencies = list(OrderedDict.fromkeys(self.dependencies))
|
dependencies = list(OrderedDict.fromkeys(self.dependencies))
|
||||||
|
self.dependencies: list = self.choose_dependencies_for_build_or_install(dependencies)
|
||||||
if dependencies:
|
|
||||||
self.dependencies: list = self.choose_dependencies(dependencies)
|
|
||||||
|
|
||||||
# Clean up the main packages if they were selected for dependencies.
|
|
||||||
for dep in self.dependencies:
|
|
||||||
if dep in self.slackbuilds:
|
|
||||||
self.slackbuilds.remove(dep)
|
|
||||||
|
|
||||||
|
def add_dependencies_slackbuilds_to_install_list(self) -> None:
|
||||||
self.install_order.extend(self.dependencies)
|
self.install_order.extend(self.dependencies)
|
||||||
|
|
||||||
def creating_main_for_build(self) -> None:
|
def clean_the_main_slackbuilds(self) -> None:
|
||||||
""" List with the main slackbuilds. """
|
""" Clean up the main packages if they were selected for dependencies. """
|
||||||
[self.install_order.append(main) for main in self.sbos.keys() if main not in self.install_order]
|
for dep in self.dependencies:
|
||||||
|
if dep in self.slackbuilds:
|
||||||
|
self.slackbuilds.remove(dep)
|
||||||
|
|
||||||
def view_before_build(self) -> None:
|
def add_main_packages_to_install_list(self) -> None:
|
||||||
|
self.install_order.extend(self.slackbuilds)
|
||||||
|
|
||||||
|
def view_slackbuilds_before_build(self) -> None:
|
||||||
""" View slackbuilds before proceed. """
|
""" View slackbuilds before proceed. """
|
||||||
if not self.mode == 'build':
|
if self.mode == 'build':
|
||||||
self.view_message.install_upgrade_packages(self.slackbuilds, self.dependencies, self.mode)
|
|
||||||
else:
|
|
||||||
self.view_message.build_packages(self.slackbuilds, self.dependencies)
|
self.view_message.build_packages(self.slackbuilds, self.dependencies)
|
||||||
|
else:
|
||||||
del self.dependencies # no more needed
|
self.view_message.install_upgrade_packages(self.slackbuilds, self.dependencies, self.mode)
|
||||||
|
|
||||||
self.view_message.question()
|
self.view_message.question()
|
||||||
|
|
||||||
|
@ -192,9 +186,9 @@ class Slackbuilds(Configs):
|
||||||
down_urls.download()
|
down_urls.download()
|
||||||
print()
|
print()
|
||||||
|
|
||||||
self.checksum_downloads()
|
self.checksum_downloaded_sources()
|
||||||
|
|
||||||
def checksum_downloads(self) -> None:
|
def checksum_downloaded_sources(self) -> None:
|
||||||
""" Checking the correct checksums. """
|
""" Checking the correct checksums. """
|
||||||
for sbo in self.install_order:
|
for sbo in self.install_order:
|
||||||
path = Path(self.build_path, sbo)
|
path = Path(self.build_path, sbo)
|
||||||
|
@ -210,34 +204,29 @@ class Slackbuilds(Configs):
|
||||||
md5sum = Md5sum(self.flags)
|
md5sum = Md5sum(self.flags)
|
||||||
md5sum.check(path, source, checksum)
|
md5sum.check(path, source, checksum)
|
||||||
|
|
||||||
def build_and_install(self) -> None:
|
def build_and_install_the_slackbuilds(self) -> None:
|
||||||
""" Build the slackbuilds and install. """
|
""" Build the slackbuilds and install. """
|
||||||
for sbo in self.install_order:
|
for sbo in self.install_order:
|
||||||
|
|
||||||
if self.continue_build_or_install(sbo):
|
if self.continue_build_or_install(sbo):
|
||||||
|
self.patch_slackbuild_tag(sbo)
|
||||||
self.patch_sbo_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)
|
||||||
pkg: str = self.package_for_install(sbo)
|
|
||||||
self.install_package(pkg)
|
|
||||||
|
|
||||||
if not self.option_for_resolve_off:
|
if not self.option_for_resolve_off:
|
||||||
self.logs_deps.logging(sbo)
|
self.logs_deps.logging(sbo)
|
||||||
else:
|
else:
|
||||||
package: str = self.utils.is_package_installed(sbo)
|
installed_package: str = self.utils.is_package_installed(sbo)
|
||||||
version: str = self.utils.split_binary_pkg(package)[1]
|
installed_version: str = self.utils.split_binary_pkg(installed_package)[1]
|
||||||
self.view_message.view_skipping_packages(sbo, version)
|
self.view_message.view_skipping_packages(sbo, installed_version)
|
||||||
|
|
||||||
def patch_sbo_tag(self, sbo: str) -> None:
|
def patch_slackbuild_tag(self, sbo: str) -> None:
|
||||||
""" Patching SBo TAG from the configuration file. """
|
""" Patching SBo TAG from the configuration file. """
|
||||||
sbo_script: Path = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
sbo_script: Path = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
|
||||||
|
|
||||||
if sbo_script.is_file() and self.repo_tag:
|
if sbo_script.is_file() and self.repo_tag:
|
||||||
|
|
||||||
lines: list = self.utils.read_file(sbo_script)
|
lines: list = self.utils.read_file(sbo_script)
|
||||||
|
|
||||||
with open(sbo_script, 'w') as script:
|
with open(sbo_script, 'w') as script:
|
||||||
|
@ -246,9 +235,9 @@ class Slackbuilds(Configs):
|
||||||
line: str = f'TAG=${{TAG:-{self.repo_tag}}}\n'
|
line: str = f'TAG=${{TAG:-{self.repo_tag}}}\n'
|
||||||
script.write(line)
|
script.write(line)
|
||||||
|
|
||||||
def install_package(self, package: str) -> None:
|
def install_package(self, pkg: str) -> None:
|
||||||
""" Install the packages that before created in the tmp directory. """
|
""" Install the packages that before created in the tmp directory. """
|
||||||
pkg: str = self.utils.split_binary_pkg(package)[0]
|
package: str = self.find_package_for_install(pkg)
|
||||||
|
|
||||||
execute: str = self.installpkg
|
execute: str = self.installpkg
|
||||||
if self.option_for_reinstall and self.utils.is_package_installed(pkg):
|
if self.option_for_reinstall and self.utils.is_package_installed(pkg):
|
||||||
|
@ -258,44 +247,40 @@ class Slackbuilds(Configs):
|
||||||
self.process_message: str = f"package '{pkg}' to install"
|
self.process_message: str = f"package '{pkg}' to install"
|
||||||
|
|
||||||
if self.mode == 'upgrade':
|
if self.mode == 'upgrade':
|
||||||
self.process_message: str = f"package '{pkg}' to upgrade"
|
|
||||||
message: str = f'{self.cyan}Upgrade{self.endc}'
|
message: str = f'{self.cyan}Upgrade{self.endc}'
|
||||||
|
self.process_message: str = f"package '{pkg}' to upgrade"
|
||||||
|
|
||||||
command: str = f'{execute} {self.tmp_path}/{package}'
|
command: str = f'{execute} {self.tmp_path}/{package}'
|
||||||
|
|
||||||
self.multi_process(command, package, message)
|
self.multi_process(command, package, message)
|
||||||
|
|
||||||
def package_for_install(self, name: str) -> str:
|
def find_package_for_install(self, name: str) -> str:
|
||||||
""" Returns the package for install. """
|
""" Returns the package for install. """
|
||||||
package: str = ''
|
|
||||||
version: str = self.data[name][2]
|
version: str = self.data[name][2]
|
||||||
pattern: str = f'{name}-{version}*{self.repo_tag}*'
|
pattern: str = f'{name}-{version}*{self.repo_tag}*'
|
||||||
|
|
||||||
packages: list = [file.name for file in self.tmp_path.glob(pattern)]
|
packages: list = [file.name for file in self.tmp_path.glob(pattern)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
package: str = max(packages)
|
return max(packages)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger = logging.getLogger(LoggingConfig.date)
|
logger = logging.getLogger(LoggingConfig.date)
|
||||||
logger.exception(f'{self.__class__.__name__}: '
|
logger.exception(f'{self.__class__.__name__}: '
|
||||||
f'{self.__class__.package_for_install.__name__}')
|
f'{self.__class__.find_package_for_install.__name__}')
|
||||||
self.errors.raise_error_message(f"Package '{name}' not found for install", exit_status=20)
|
self.errors.raise_error_message(f"Package '{name}' not found for install", exit_status=20)
|
||||||
|
|
||||||
return package
|
|
||||||
|
|
||||||
def build_the_script(self, path: Path, name: str) -> None:
|
def build_the_script(self, path: Path, name: str) -> None:
|
||||||
""" Run the .SlackBuild script. """
|
""" Run the .SlackBuild script. """
|
||||||
folder: str = f'{Path(path, name)}/'
|
folder: str = f'{Path(path, name)}/'
|
||||||
execute: str = f'{folder}./{name}.SlackBuild'
|
execute: str = f'{folder}./{name}.SlackBuild'
|
||||||
|
|
||||||
|
if self.option_for_jobs:
|
||||||
|
self.set_makeflags()
|
||||||
|
|
||||||
# Change to root privileges
|
# Change to root privileges
|
||||||
os.chown(folder, 0, 0)
|
os.chown(folder, 0, 0)
|
||||||
for file in os.listdir(folder):
|
for file in os.listdir(folder):
|
||||||
os.chown(f'{folder}{file}', 0, 0)
|
os.chown(f'{folder}{file}', 0, 0)
|
||||||
|
|
||||||
if self.option_for_jobs:
|
|
||||||
self.set_makeflags()
|
|
||||||
|
|
||||||
name: str = f'{name}.SlackBuild'
|
name: str = f'{name}.SlackBuild'
|
||||||
message: str = f'{self.red}Build{self.endc}'
|
message: str = f'{self.red}Build{self.endc}'
|
||||||
self.process_message: str = f"package '{name}' to build"
|
self.process_message: str = f"package '{name}' to build"
|
||||||
|
@ -308,7 +293,6 @@ class Slackbuilds(Configs):
|
||||||
os.environ['MAKEFLAGS'] = f'-j {cpu_count()}'
|
os.environ['MAKEFLAGS'] = f'-j {cpu_count()}'
|
||||||
|
|
||||||
def multi_process(self, command: str, filename: str, message: str) -> None:
|
def multi_process(self, command: str, filename: str, message: str) -> None:
|
||||||
""" Starting multiprocessing install/upgrade process. """
|
|
||||||
if self.silent_mode and not self.option_for_no_silent:
|
if self.silent_mode and not self.option_for_no_silent:
|
||||||
|
|
||||||
done: str = f' {self.byellow} Done{self.endc}'
|
done: str = f' {self.byellow} Done{self.endc}'
|
||||||
|
@ -342,8 +326,7 @@ class Slackbuilds(Configs):
|
||||||
else:
|
else:
|
||||||
self.utils.process(command, self.stderr, self.stdout)
|
self.utils.process(command, self.stderr, self.stdout)
|
||||||
|
|
||||||
def choose_dependencies(self, dependencies: list) -> list:
|
def choose_dependencies_for_build_or_install(self, dependencies: list) -> list:
|
||||||
""" Choose packages for install. """
|
|
||||||
height: int = 10
|
height: int = 10
|
||||||
width: int = 70
|
width: int = 70
|
||||||
list_height: int = 0
|
list_height: int = 0
|
||||||
|
|
Loading…
Reference in a new issue