Added --jobs option

This commit is contained in:
Dimitris Zlatanidis 2022-06-20 17:50:16 +03:00
parent d3cd9b8b01
commit 729f695b5c
5 changed files with 38 additions and 14 deletions

View file

@ -41,7 +41,7 @@ Usage
$ slpkg --help
Usage: slpkg [OPTIONS] [packages]
Usage: slpkg [OPTIONS] <packages>
Packaging tool that interacts with the SBo repository.
@ -54,6 +54,7 @@ Usage
clean-logs Purge logs of dependencies.
--yes Answer Yes to all questions.
--jobs Set it for multicore systems.
--resolve-off Turns off dependency resolving.
--reinstall Use this option if you want to upgrade.
@ -86,4 +87,4 @@ Copyright
- Copyright 2014-2022 © Dimitris Zlatanidis.
- Slackware® is a Registered Trademark of Patrick Volkerding.
- Linux is a Registered Trademark of Linus Torvalds.
- Linux is a Registered Trademark of Linus Torvalds.

View file

@ -1,7 +1,7 @@
.TH slpkg 1 "Orestiada, Greece" "slpkg 4.1.0" dslackw
.SH NAME
.P
slpkg - [OPTIONS] [packages]
slpkg - [OPTIONS] <packages>
.SH SYNAPSES
.P
slpkg [-h|-v] [update] [build] [install] [remove] [search] [clean-logs] --yes --resolve-off --reinstall
@ -12,16 +12,6 @@ Slpkg is a software package manager that installs, updates, and removes packages
Slpkg works in accordance with the standards of the organization SlackBuilds.org to build packages. Also uses the Slackware Linux instructions for installation, upgrading or removing packages.
.SH OPTIONS
.P
-h | --help
.RS
Show help informatio and exit.
.RE
.P
-v | --version
.RS
Print version and exit.
.RE
.P
update
.RS
Updates the package list and the database.
@ -57,6 +47,12 @@ Purge logs of dependencies.
Answer Yes to all questions.
.RE
.P
--jobs
.RS
Acceleration of SlackBuild scripts. When the --jobs flag is set, slpkg automatically detects the number of processors and enters it into the MAKEFLAGS variable. Some SlackBuilds fail when
MAKEFLAGS is declared or the number of processors (-j) is greater than one.
.RE
.P
--resolve-off
.RS
Turns off dependency resolving.
@ -66,6 +62,16 @@ Turns off dependency resolving.
.RS
Use this option if you want to upgrade all packages even if the same version is already installed. Do not skip installed packages.
.RE
.P
-h | --help
.RS
Show help informatio and exit.
.RE
.P
-v | --version
.RS
Print version and exit.
.RE
.SH CONFIGURATION FILES
.P
Configuration file in the /etc/slpkg/slpkg.json file.

View file

@ -8,7 +8,7 @@ from dataclasses import dataclass
from slpkg.checks import Check
from slpkg.search import Search
from slpkg.version import Version
from slpkg.cli_menu import usage
from slpkg.views.cli_menu import usage
from slpkg.slackbuild import Slackbuilds
from slpkg.remove_packages import RemovePackages
from slpkg.clean_logs import CleanLogsDependencies
@ -22,6 +22,7 @@ class Argparse:
def flags(self):
self.flags = []
yes = '--yes'
jobs = '--jobs'
resolve_off = '--resolve-off'
reinstall = '--reinstall'
@ -29,6 +30,10 @@ class Argparse:
self.args.remove(yes)
self.flags.append(yes)
if jobs in self.args:
self.args.remove(jobs)
self.flags.append(jobs)
if resolve_off in self.args:
self.args.remove(resolve_off)
self.flags.append(resolve_off)

View file

@ -4,6 +4,7 @@
import os
import shutil
import subprocess
import multiprocessing
from dataclasses import dataclass
from collections import OrderedDict
@ -159,10 +160,20 @@ class Slackbuilds:
folder = f'{path}/{name}/'
slackbuild = f'./{name}.SlackBuild'
execute = folder + slackbuild
if '--jobs' in self.flags:
self.makeflags()
stdout = subprocess.call(execute)
if stdout > 0:
raise SystemExit(stdout)
def makeflags(self):
''' Set number of processors. '''
cpus = multiprocessing.cpu_count()
os.environ['MAKEFLAGS'] = f'-j {cpus}'
print(os.environ['MAKEFLAGS'])
def download_sources(self, name: str, sources: str):
''' Download the sources. '''
wget = Wget()

View file

@ -16,6 +16,7 @@ def usage(status: int):
' search Search packages by name.',
' clean-logs Purge logs of dependencies.\n',
' --yes Answer Yes to all questions.',
' --jobs Set it for multicore systems.',
' --resolve-off Turns off dependency resolving.',
' --reinstall Use this option if you want to upgrade.\n',
' -h, --help Show this message and exit.',