Merge branch 'develop'

This commit is contained in:
Dimitris Zlatanidis 2020-01-20 20:29:48 +01:00
commit 5eeed7f5b1
56 changed files with 1275 additions and 671 deletions

21
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,21 @@
image: "python:3.7"
before_script:
- python --version
- pip install -r requirements.txt
stages:
- Static Analysis
- Test
flake8:
stage: Static Analysis
script:
- flake8 --max-line-length=120 bild/*.py
unit_test:
stage: Test
script:
- export PYTHONPATH="$PYTHONPATH:."
- python -c "import sys;print(sys.path)"
- pytest

View file

@ -1,7 +0,0 @@
language: python
python:
- "2.7"
# command to install dependencies
install: "pip install -r requirements.txt"
# command to run tests
script: nosetests

View file

@ -1,6 +1,12 @@
3.7.5 - 15/01/2020
Fixed:
- Bugfix: merge files with slack repository between current and slack versions
Updated:
- code to improve for Python 3
3.7.4 - 20/12/2019
Fixed:
-Bugfix: UnicodeDecodeError: 'utf-8' codec can't decode byte
- Bugfix: UnicodeDecodeError: 'utf-8' codec can't decode byte
3.7.3 - 11/12/2019
FIxed:

View file

@ -5,7 +5,7 @@
First you need to run '`slpkg update`' to synchronize the lists of packages, also every time you add
a new repository. To add or remove repositories must edit the file '`/etc/slpkg/repositories.conf`'
or run '`slpkg repo-enable`' (python2-pythondialog required). Add custom repositories with the
or run '`slpkg repo-enable`' (python3-pythondialog required). Add custom repositories with the
command '`slpkg add-repo <repository name> <URL>`' and after run '`slpkg update`' to update package
list. View list of repositories with the command `slpkg repo-list` or get repository information
with the command '`slpkg repo-info <repository>`'.
@ -74,7 +74,7 @@ remove packages from your system events. Notable mention you must give in the co
after editing configuration file '`/etc/slpkg/slpkg.conf`' (default is disable) or add additional
option '`--deps`'. Also you can check if the packages they are used as dependency with additional
option '`--check-deps`'. Option '`--tag`' allow to remove packages with by TAG. Optional you can use
the dialog utility with the additional option '`--checklist`' (require python2-pythondialog). Rmove
the dialog utility with the additional option '`--checklist`' (require python3-pythondialog). Rmove
third-party packages with the option '`--third-party`'.
The command '`slpkg -d <packages>`' is useful to print the entire contents of a package.
@ -85,7 +85,7 @@ Some examples you will see below.
##### Slpkg Examples
Enable or disable default repositories, edit '`/etc/slpkg/repositories.conf`' file or with the command.
(require pythondialog, install with '`slpkg -s sbo python2-pythondialog`'):
(require pythondialog, install with '`slpkg -s sbo python3-pythondialog`'):
```
$ slpkg repo-enable

View file

@ -1,4 +1,4 @@
# slpkg 3.7.4
# slpkg 3.7.5
Slpkg is a powerful software package manager that installs, updates, and removes packages on
[Slackware](http://www.slackware.com/) based systems. It automatically computes dependencies and

View file

@ -49,11 +49,11 @@ class Clean:
def start(self):
for f in self.files:
if os.path.isfile(f):
print("Remove file --> {0}".format(f))
print(f"Remove file --> {f}")
os.remove(f)
for d in self.dirs:
if os.path.exists(d):
print("Remove directory --> {0}".format(d))
print(f"Remove directory --> {d}")
shutil.rmtree(d)

View file

@ -188,7 +188,7 @@ Additional options:
.PP
\fB--skip=[packages...]\fP : Skip packages from upgrade separate by comma like "# slpkg -c sbo --skip=jdk,pep8,pip" (See REGEX).
.PP
\fB--checklist\fP : Enable dialog utility and checklist option. (Require python2-pythondialog)
\fB--checklist\fP : Enable dialog utility and checklist option. (Require python3-pythondialog)
.SS -s, --sync, synchronize packages, download, build and install package with all dependencies
\fBslpkg\fP \fB-s\fP <\fIrepository\fP> <\fInames of packages\fP>, \fB--resolve-off\fP, \fB--case-ins\fP, \fB--patches\fP

743
man/slpkg.html Normal file
View file

@ -0,0 +1,743 @@
<!-- Creator : groff version 1.22.3 -->
<!-- CreationDate: Sat Dec 28 15:39:55 2019 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="generator" content="groff -Thtml, see www.gnu.org">
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="Content-Style" content="text/css">
<style type="text/css">
p { margin-top: 0; margin-bottom: 0; vertical-align: top }
pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
table { margin-top: 0; margin-bottom: 0; vertical-align: top }
h1 { text-align: center }
</style>
<title>Slpkg</title>
</head>
<body>
<h1 align="center">Slpkg</h1>
<a href="#NAME">NAME</a><br>
<a href="#SYNOPSIS">SYNOPSIS</a><br>
<a href="#DESCRIPTION">DESCRIPTION</a><br>
<a href="#GLOBAL OPTIONS">GLOBAL OPTIONS</a><br>
<a href="#COMMANDS">COMMANDS</a><br>
<a href="#OPTIONS">OPTIONS</a><br>
<a href="#HELP OPTION">HELP OPTION</a><br>
<a href="#DEFAULT REPOSITORIES">DEFAULT REPOSITORIES</a><br>
<a href="#COLORS">COLORS</a><br>
<a href="#REGEX">REGEX</a><br>
<a href="#PASS VARIABLES TO THE SCRIPT">PASS VARIABLES TO THE SCRIPT</a><br>
<a href="#FILES">FILES</a><br>
<a href="#AUTHOR">AUTHOR</a><br>
<a href="#HOMEPAGE">HOMEPAGE</a><br>
<a href="#COPYRIGHT">COPYRIGHT</a><br>
<a href="#SEE ALSO">SEE ALSO</a><br>
<hr>
<h2>NAME
<a name="NAME"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">Slpkg is a
user-friendly package manager for Slackware
installations</p>
<h2>SYNOPSIS
<a name="SYNOPSIS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">slpkg
[COMMANDS|OPTIONS] {repository|package...}</p>
<h2>DESCRIPTION
<a name="DESCRIPTION"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">Slpkg is a
powerful software package manager that installs, updates,
and removes packages on Slackware based systems. It
automatically computes dependencies and figures out what
things should occur to install packages. Slpkg makes it
easier to maintain groups of machines without having to
manually update.</p>
<h2>GLOBAL OPTIONS
<a name="GLOBAL OPTIONS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em"><b>&minus;v</b>,
<b>&minus;&minus;version</b></p>
<p style="margin-left:11%; margin-top: 1em">Print the
version of program and exit.</p>
<h2>COMMANDS
<a name="COMMANDS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">The following
commands are available.</p>
<p style="margin-left:11%; margin-top: 1em"><b>update,
create and update packages list <br>
slpkg update</b>,
<b>--repositories=[repositories...]</b></p>
<p style="margin-left:11%; margin-top: 1em">Used to
re-synchronize the package lists and create some important
files. This command must run every new repository is added
or new updates is available.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--repositories=[repositories...]</b>
: Update at specifically repositories separate by comma.</p>
<p style="margin-left:11%; margin-top: 1em"><b>upgrade,
recreate packages list <br>
slpkg upgrade</b>,
<b>--repositories=[repositories...]</b></p>
<p style="margin-left:11%; margin-top: 1em">It is sometimes
useful to create all of the base file from the beginning so
this command delete all the package lists and recreated.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--repositories=[repositories...]</b>
: Update at specifically repositories separate by comma.</p>
<p style="margin-left:11%; margin-top: 1em"><b>repo-add,
add custom repository <br>
slpkg repo-add</b> &lt;<i>repository name</i>&gt;
&lt;<i>URL</i>&gt;</p>
<p style="margin-left:11%; margin-top: 1em">Add custom
binary repository. The repositories will be added to this
command should contain at least the files
&quot;PACKAGES.TXT&quot; and &quot;CHECKSUMS.md5&quot; and
optional file &quot;ChangeLog.txt&quot; used to control
changes.</p>
<p style="margin-left:11%; margin-top: 1em"><b>repo-remove,
remove custom repository <br>
slpkg repo-remove</b> &lt;<i>repository</i>&gt;</p>
<p style="margin-left:11%; margin-top: 1em">Remove custom
repository by name.</p>
<p style="margin-left:11%; margin-top: 1em"><b>repo-enable,
enable or disable repositories <br>
slpkg repo-enable</b></p>
<p style="margin-left:11%; margin-top: 1em">Enable or
disable repositories via dialog utility (require
python3-pythondialog)</p>
<p style="margin-left:11%; margin-top: 1em"><b>repo-list,
repositories list <br>
slpkg repo-list</b></p>
<p style="margin-left:11%; margin-top: 1em">Lists all
enabled or disabled repositories.</p>
<p style="margin-left:11%; margin-top: 1em"><b>repo-info,
repository information <br>
slpkg repo-info</b> &lt;<i>repository</i>&gt;</p>
<p style="margin-left:11%; margin-top: 1em">View repository
information.</p>
<p style="margin-left:11%; margin-top: 1em"><b>update
slpkg, update slpkg itself <br>
slpkg update slpkg</b></p>
<p style="margin-left:11%; margin-top: 1em">You can check
for new versions and update slpkg itself.</p>
<p style="margin-left:11%; margin-top: 1em"><b>health,
health check installed packages <br>
slpkg health</b>, <b>--silent</b></p>
<p style="margin-left:11%; margin-top: 1em">Check file list
from packages of files installed.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--silent</b>
: Print only errors.</p>
<p style="margin-left:11%; margin-top: 1em"><b>deps-status,
print dependencies status <br>
slpkg deps-status --graph=[type]</b></p>
<p style="margin-left:11%; margin-top: 1em">Print
dependencies status used by packages. Prerequisite packages
have been installed with the option &quot;# slpkg -s
&lt;repository&gt; &lt;packages&gt;&quot;.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--graph=[type]</b>
: Drawing dependencies diagram. (example for type: ascii,
image.x11, image.png etc. Require pygraphviz)</p>
<p style="margin-left:11%; margin-top: 1em"><b>--tree</b> :
Switch to tree view.</p>
<p style="margin-left:11%; margin-top: 1em"><b>new-config,
manage .new configuration files <br>
slpkg new-config</b></p>
<p style="margin-left:11%; margin-top: 1em">This command
searches for .new configuration files in /etc/ path and ask
the user what todo with those files.</p>
<p style="margin-left:11%; margin-top: 1em"><b>clean-tmp,
clean the tmp/ directory <br>
slpkg clean-tmp</b></p>
<p style="margin-left:11%; margin-top: 1em">Clean the
/tmp/slpkg/ directory from downloaded packages and
sources.</p>
<h2>OPTIONS
<a name="OPTIONS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">The following
arguments are available.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-a,
--autobuild, auto build packages <br>
slpkg -a</b> &lt;<i>script.tar.gz</i>&gt;
&lt;<i>sources</i>&gt;</p>
<p style="margin-left:11%; margin-top: 1em">If you already
have download the script and source with this argument you
can build Slackware package from source quickly and easy.
Slpkg will grab checksum from the .info file to make control
if he does not agree with the versions you will get the
wrong message. If you want switch off checksum from the
configuration file.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-b,
--blacklist, add, remove, view packages in blacklist <br>
slpkg -b</b> &lt;<i>name of packages</i>&gt; <b>--add</b>,
<b>--remove</b>, <b>list</b></p>
<p style="margin-left:11%; margin-top: 1em">Add, remove or
listed packages from blacklist file. The settings here
affect all repositories. Remove all packages from blacklist
use argument like &quot;# slpkg -b --remove&quot;. Use
asterisk &quot;*&quot; to match pagkages like &quot;# slpkg
-b py* --add&quot;, this add all installed packages with
starts string &quot;py&quot; or &quot;# slpkg -b
multi:*multilib* --add&quot;, this add all multilib packages
from repository &quot;multi&quot;.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-q, --queue,
add, remove, view packages in queue <br>
slpkg -q</b> &lt;<i>names of packages</i>&gt; <b>--add</b>,
<b>--remove <br>
slpkg -q list</b>, <b>build</b>, <b>install</b>,
<b>build-install</b></p>
<p style="margin-left:11%; margin-top: 1em">Add, remove and
listed sbo packages from queue. This argument is very useful
if you want to build and install multiple packages together.
Note the correct order if there are dependencies. If you
want to remove all the packages from the list run &quot;#
slpkg -q --remove&quot;. (these arguments only working for
the sbo repository) Build or install or build and install
packages are queued.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-g,
--config, configuration file management <br>
slpkg -g print</b>, <b>edit</b>, <b>reset</b></p>
<p style="margin-left:11%; margin-top: 1em">Print, reset or
edit configuration file.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-l, --list,
list of installed packages <br>
slpkg -l</b> &lt;<i>repository</i>&gt;, <b>--index</b>,
<b>--installed</b>, <b>--name</b></p>
<p style="margin-left:11%; margin-top: 1em">Print a list of
all available packages from repository, index or print only
packages installed on the system. Support command
&quot;grep&quot; like &quot;# slpkg -l sbo | grep
python&quot;.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--index</b>
: Count packages per page.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--installed</b>
: Highlight installed packages.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--name</b> :
Print package name only.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-c, --check,
check if your packages is up to date <br>
slpkg -c</b> &lt;<i>repository</i>&gt; <b>--upgrade
--rebuild --skip=[packages...]</b>, <b>--resolve-off</b>,
<b>--checklist</b></p>
<p style="margin-left:11%; margin-top: 1em">Check your
packages if up to date. Slackware patches repository works
independently of the others i.e not need before updating the
list of packages by choosing &quot;# slpkg update&quot;,
works directly with the official repository and so always
you can have updated your system.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>-c</b> :
Check ChangeLog.txt files for changes.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--upgrade</b>
: Check and install packages for upgrade.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--rebuild</b>
: Rebuild packages from sbo repository.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--resolve-off</b>
: Switch off automatic resolve dependencies.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--skip=[packages...]</b>
: Skip packages from upgrade separate by comma like &quot;#
slpkg -c sbo --skip=jdk,pep8,pip&quot; (See REGEX).</p>
<p style="margin-left:11%; margin-top: 1em"><b>--checklist</b>
: Enable dialog utility and checklist option. (Require
python3-pythondialog)</p>
<p style="margin-left:11%; margin-top: 1em"><b>-s, --sync,
synchronize packages, download, build and install package
with all dependencies <br>
slpkg -s</b> &lt;<i>repository</i>&gt; &lt;<i>names of
packages</i>&gt;, <b>--resolve-off</b>, <b>--case-ins</b>,
<b>--patches</b></p>
<p style="margin-left:11%; margin-top: 1em">Installs or
upgrade packages from the repositories with automatically
resolving all dependencies of the package.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--rebuild</b>
: Rebuild packages from sbo repository.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--reinstall</b>
: Reinstall binary packages from repositories.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--resolve-off</b>
: Switch off automatic resolve dependencies.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--download-only</b>
: Download packages without install.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--directory-prefix=[path/to/dir/]</b>
: Download packages in specific directory.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--case-ins</b>
: Search package name in repository with case
insensitive.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--patches</b>
: Switch to patches&nbsp;directory, only for slack
repository.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-t,
--tracking, tracking dependencies <br>
slpkg -t</b> &lt;<i>repository</i>&gt; &lt;<i>name of
package</i>&gt;, <b>--check-deps</b>, <b>--graph=[type]
--case-ins</b></p>
<p style="margin-left:11%; margin-top: 1em">Tracking all
dependencies of that package. The sequence shown is that you
must follow to correctly install package. Also you can check
if the installed package has all the required
dependencies.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--check-deps</b>
: Check if installed packages used by other packages.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--graph=[type]</b>
: Drawing dependencies graph. (example for type: ascii,
image.x11, image.png etc. Require pygraphviz)</p>
<p style="margin-left:11%; margin-top: 1em"><b>--case-ins</b>
: Search package name in repository with case
insensitive.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-p, --desc,
print packages description <br>
slpkg -p</b> &lt;<i>repository</i>&gt; &lt;<i>name of
package</i>&gt;, <b>--color=[]</b></p>
<p style="margin-left:11%; margin-top: 1em">Print package
description from remote repository with color. Available
colors: red, green, yellow, cyan, grey</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--color=[]</b>
: Change color print.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-F, --FIND,
find packages from repositories <br>
slpkg -F</b> &lt;<i>names of packages</i>&gt;,
<i>--case-ins</i></p>
<p style="margin-left:11%; margin-top: 1em">Find packages
from all repositories are enabled. Useful command to find
all available packages per repository.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--case-ins</b>
: Search package name in repository with case
insensitive.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-f, --find,
find installed packages <br>
slpkg -f</b> &lt;<i>names of packages</i>&gt;,
<b>--case-ins</b>, <b>--third-party</b></p>
<p style="margin-left:11%; margin-top: 1em">Find installed
packages with view total file size. Example you can view all
installed sbo packages like &quot;# slpkg -f _SBo&quot;.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--case-ins</b>
: Search package name with case insensitive.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--third-party</b>
: View all the third-party packages.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-n,
--network, view SBo packages <br>
slpkg -n</b> &lt;<i>name of package</i>&gt;,
&lt;<i>[pattern], --checklist</i>&gt;, <b>--case-ins</b></p>
<p style="margin-left:11%; margin-top: 1em">View complete
slackbuilds.org site in your terminal. Read file, download,
build or install etc. Use &quot;--checklist&quot; additional
option to load all repository, example: &quot;# slpkg -n
--checklist&quot;.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--checklist</b>
: Enable dialog utility and checklist option. (Require
python3-pythondialog)</p>
<p style="margin-left:11%; margin-top: 1em"><b>--case-ins</b>
: Search package name in repository with case
insensitive.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-i,
--installpkg, install Slackware binary packages <br>
slpkg -i [--warn, --md5sum, --root /otherroot, --infobox,
--menu, --terse, --ask, --priority ADD|REC|OPT|SKP,
--tagfile /somedir/tagfile]</b>
&lt;<i>packages.t?z</i>&gt;</p>
<p style="margin-left:11%; margin-top: 1em">Installs single
binary packages designed for use with the Slackware Linux
distribution into your system. More information please read
&quot;man installpkg&quot;.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-u,
--upgradepkg, install-upgrade Slackware binary packages with
new <br>
slpkg -u [--dry-run, --install-new, --reinstall,
--verbose]</b> &lt;<i>packages.t?z</i>&gt;</p>
<p style="margin-left:11%; margin-top: 1em">Normally
upgrade only upgrades packages that are already installed on
the system, and will skip any packages that do not already
have a version installed. More information please read
&quot;man upgradepkg&quot;.</p>
<p style="margin-left:11%; margin-top: 1em"><b>-r,
--removepkg, remove previously installed Slackware binary
packages <br>
slpkg -r [-copy, -keep, -preserve, -warn]</b> &lt;<i>names
of packages</i>&gt;, <b>--deps</b>, <b>--check-deps</b>,
<b>--tag</b>, <b>--checklist</b>, <b>--third-party</b></p>
<p style="margin-left:11%; margin-top: 1em">Removes a
previously installed Slackware package, while writing a
progress report to the standard output. A package may be
specified either by the full package name (as you&rsquo;d
see listed in /var/log/packages/), or by the base package
name. If installed packages with command &quot;# slpkg -s
&lt;repo&gt; &lt;packages&gt;&quot; then write a file in
/var/log/slpkg/dep/ with all dependencies and it allows you
can remove them all together. More information please read
&quot;man removepkg&quot;.</p>
<p style="margin-left:11%; margin-top: 1em">Additional
options:</p>
<p style="margin-left:11%; margin-top: 1em"><b>--deps</b> :
Remove packages with dependencies.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--check-deps</b>
: Check if installed packages used by other packages.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--tag</b> :
Remove packages with by TAG.</p>
<p style="margin-left:11%; margin-top: 1em"><b>--checklist</b>
: Enable dialog utility and checklist option. (Require
python3-pythondialog)</p>
<p style="margin-left:11%; margin-top: 1em"><b>--third-party</b>
: Remove all the third-party packages. (Be sure update the
package lists before)</p>
<p style="margin-left:11%; margin-top: 1em"><b>-d,
--display, display the installed packages contents and file
list <br>
slpkg -d</b> &lt;<i>names of packages</i>&gt;</p>
<p style="margin-left:11%; margin-top: 1em">Display the
installed Slackware packages contents and file list with all
descriptions.</p>
<h2>HELP OPTION
<a name="HELP OPTION"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">Specifying the
help option displays help for slpkg itself, or a command.
<br>
For example: <b><br>
slpkg &minus;&minus;help</b> - display help for slpkg</p>
<h2>DEFAULT REPOSITORIES
<a name="DEFAULT REPOSITORIES"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">slackware.com =
&quot;slack&quot; <br>
SlackBuilds.org = &quot;sbo&quot; <br>
Alien&rsquo;s = &quot;alien&quot; <br>
slacky.eu = &quot;slacky&quot; <br>
rworkman&rsquo;s = &quot;rlw&quot; <br>
Conraid&rsquo;s = &quot;conrad&quot; <br>
slackonly.com = &quot;slonly&quot; <br>
Alien&rsquo;s ktown = &quot;ktown{latest}&quot; <br>
Alien&rsquo;s multilib = &quot;multi&quot; <br>
Slacke E17 and E18 = &quot;slacke{18}&quot; <br>
SalixOS = &quot;salix&quot; <br>
Slackel.gr = &quot;slackel&quot; <br>
Alien&rsquo;s restricted = &quot;rested&quot; <br>
MATE Desktop Environment = &quot;msb{1.18}&quot; <br>
Cinnamon Desktop Environment = &quot;csb&quot; <br>
Connochaetos slack-n-free = &quot;connos&quot; <br>
Microlinux mles = &quot;mles&quot;</p>
<p style="margin-left:11%; margin-top: 1em">Default enable
repository is &quot;slack&quot; and &quot;sbo&quot;. <br>
Add or remove default repository in configuration file
&quot;/etc/slpkg/repositories.conf&quot;. <br>
Read REPOSITORIES file for particularities.</p>
<h2>COLORS
<a name="COLORS"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">red, green,
yellow, cyan, grey</p>
<h2>REGEX
<a name="REGEX"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">For options
&quot;--skip=&quot; and blacklist file.</p>
<p style="margin-left:11%; margin-top: 1em">All packages
starts with: &quot;string*&quot; <br>
All packages ends with: &quot;*string&quot; <br>
All packages include: &quot;*string*&quot;</p>
<h2>PASS VARIABLES TO THE SCRIPT
<a name="PASS VARIABLES TO THE SCRIPT"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">If you want to
pass variables to the script exported as: <br>
Usage: &lt;NAME_VARIABLE=value&gt;</p>
<p style="margin-left:11%; margin-top: 1em">Example: <br>
&quot;# export FFMPEG_X264=yes FFMPEG_LAME=yes&quot;</p>
<h2>FILES
<a name="FILES"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/slpkg.conf
<br>
General configuration of slpkg</p>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/repositories.conf
<br>
Configuration file for repositories</p>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/blacklist
<br>
List of packages to skip</p>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/slackware-mirrors
<br>
List of Slackware Mirrors</p>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/default-repositories
<br>
List of default repositories</p>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/custom-repositories
<br>
List of custom repositories</p>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/rlworkman.deps
<br>
Rworkman&rsquo;s repository dependencies</p>
<p style="margin-left:11%; margin-top: 1em">/etc/slpkg/pkg_security
<br>
List of packages for security reasons</p>
<p style="margin-left:11%; margin-top: 1em">/var/log/slpkg
<br>
ChangeLog.txt repositories files <br>
SlackBuilds logs and dependencies files</p>
<p style="margin-left:11%; margin-top: 1em">/var/lib/slpkg
<br>
PACKAGES.TXT files <br>
SLACKBUILDS.TXT files <br>
CHECKSUMS.md5 files <br>
FILELIST.TXT files</p>
<p style="margin-left:11%; margin-top: 1em">/tmp/slpkg <br>
Slpkg temporary downloaded files and build packages</p>
<h2>AUTHOR
<a name="AUTHOR"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">Dimitris
Zlatanidis &lt;d.zlatanidis@gmail.com&gt;</p>
<h2>HOMEPAGE
<a name="HOMEPAGE"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">https://dslackw.gitlab.io/slpkg/</p>
<h2>COPYRIGHT
<a name="COPYRIGHT"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">Copyright
&copy; 2014-2019 Dimitris Zlatanidis</p>
<h2>SEE ALSO
<a name="SEE ALSO"></a>
</h2>
<p style="margin-left:11%; margin-top: 1em">installpkg(8),
upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8),
explodepkg(8), makepkg(8).</p>
<hr>
</body>
</html>

4
pytest.ini Normal file
View file

@ -0,0 +1,4 @@
[pytest]
python_files = test_*
python_classes = *Tests
python_functions = test_*

View file

@ -12,3 +12,5 @@
# python3-pythondialog >= 3.5.0 (Python interface to the UNIX dialog utility)
urllib3 >= 1.25.7
flake8 >= 3.5.0
pytest >= 5.3.2

View file

@ -35,7 +35,9 @@ except ImportError:
from distutils.core import setup
docs_requires = []
tests_requires = []
tests_requires = [
"pytest>=5.3.2"
]
install_requires = [
"urllib3>=1.25.7"
]

View file

@ -40,7 +40,7 @@ def update_repositories(repositories, conf_path):
"""
Upadate with user custom repositories
"""
repo_file = "{0}custom-repositories".format(conf_path)
repo_file = f"{conf_path}custom-repositories"
if os.path.isfile(repo_file):
f = open(repo_file, "r")
repositories_list = f.read()
@ -78,7 +78,7 @@ class MetaData:
__all__ = "slpkg"
__author__ = "dslackw"
__version_info__ = (3, 7, 4)
__version_info__ = (3, 7, 5)
__version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com"
@ -90,11 +90,11 @@ class MetaData:
slack_rel = "stable"
# Configuration path
conf_path = "/etc/{0}/".format(__all__)
conf_path = f"/etc/{__all__}/"
# tmp paths
tmp = "/tmp/"
tmp_path = "{0}{1}/".format(tmp, __all__)
tmp_path = f"{tmp}{__all__}/"
# Default configuration values
_conf_slpkg = {
@ -138,8 +138,8 @@ class MetaData:
# read value from configuration file
repositories = []
for files in ["slpkg.conf", "repositories.conf"]:
if os.path.isfile("%s%s" % (conf_path, files)):
f = open("%s%s" % (conf_path, files), "r")
if os.path.isfile(f"{conf_path}{files}"):
f = open(f"{conf_path}{files}", "r")
conf = f.read()
f.close()
for line in conf.splitlines():
@ -217,8 +217,8 @@ class MetaData:
"ENDC": ""
}
CHECKSUMS_link = ("https://gitlab.com/{0}/{1}/raw/"
"master/CHECKSUMS.md5".format(__author__, __all__))
CHECKSUMS_link = (f"https://gitlab.com/{__author__}/{__all__}/raw/"
"master/CHECKSUMS.md5")
# file spacer
sp = "-"

View file

@ -30,8 +30,7 @@ from slpkg.slack.slack_version import slack_ver
def header():
"""help header message"""
print("\nslpkg - version {0} | Slackware release: {1} - {2}\n".format(
_meta_.__version__, _meta_.slack_rel, slack_ver()))
print(f"\nslpkg - version {_meta_.__version__} | Slackware release: {_meta_.slack_rel} - {slack_ver()}\n")
def options():
@ -220,11 +219,11 @@ def usage(repo):
all_repos = RepoList().all_repos.keys()
del RepoList().all_repos
if repo in all_repos:
error_repo = ("slpkg: Error: Repository '{0}' is not activated"
"\n".format(repo))
error_repo = (f"slpkg: Error: Repository '{repo}' is not activated"
"\n")
else:
error_repo = ("slpkg: Error: Repository '{0}' does not exist"
"\n".format(repo))
error_repo = (f"slpkg: Error: Repository '{repo}' does not exist"
"\n")
print("\n" + error_repo)
raise SystemExit(1)
print(usage.__doc__)

View file

@ -22,8 +22,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from slpkg.messages import Msg
from slpkg.__metadata__ import MetaData as _meta_
@ -35,7 +33,10 @@ class Auto:
"""
def __init__(self, packages):
self.packages = packages
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.commands = {
"i": "installpkg",
@ -54,10 +55,7 @@ class Auto:
print("| Choose a Slackware command:")
self.msg.template(78)
for com in sorted(self.commands):
print("| {0}{1}{2}) {3}{4}{5}".format(
self.meta.color["RED"], com, self.meta.color["ENDC"],
self.meta.color["GREEN"], self.commands[com],
self.meta.color["ENDC"]))
print(f"| {self.red}{com}{self.endc}) {self.green}{self.commands[com]}{self.endc}")
self.msg.template(78)
try:
self.choice = input(" > ")
@ -65,9 +63,7 @@ class Auto:
print()
raise SystemExit()
if self.choice in self.commands.keys():
print(" \x1b[1A{0}{1}{2}\n\n".format(
self.meta.color["CYAN"], self.commands[self.choice],
self.meta.color["ENDC"]), end="")
print(f" \x1b[1A{self.cyan}{self.commands[self.choice]}{self.endc}", end="\n\n")
print(end="", flush=True)
self.execute()

View file

@ -165,8 +165,7 @@ class Requires:
else:
return ""
else:
PACKAGES_TXT = Utils().read_file("{0}{1}_repo/PACKAGES.TXT".format(
_meta_.lib_path, self.repo))
PACKAGES_TXT = Utils().read_file(f"{_meta_.lib_path}{self.repo}_repo/PACKAGES.TXT")
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"):
pkg_name = split_package(line[14:].strip())[0]

View file

@ -60,6 +60,11 @@ class BinaryInstall:
self.repo = repo
self.flag = flag
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.grey = _meta_.color["GREY"]
self.yellow = _meta_.color['YELLOW']
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.version = self.meta.slack_rel
self.tmp_path = self.meta.slpkg_tmp_packages
@ -124,22 +129,16 @@ class BinaryInstall:
if self.matching and [""] != self.packages:
print("\nMatching summary")
print("=" * 79)
print("Total {0} matching packages\n".format(sum(sums)))
print(f"Total {sum(sums)} matching packages\n")
raise SystemExit(1)
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2}.".format(self.meta.color["GREY"],
sum(sums),
self.msg.pkg(sum(sums))))
print("{0} {1} will be installed, {2} will be upgraded and "
"{3} will be reinstalled.".format(sums[2],
self.msg.pkg(sums[2]),
sums[1], sums[0]))
print("Need to get {0} {1} of archives.".format(size[0],
unit[0]))
print("After this process, {0} {1} of additional disk "
"space will be used.{2}".format(size[1], unit[1],
self.meta.color["ENDC"]))
print(f"{self.grey}Total {sum(sums)} {self.msg.pkg(sum(sums))}.")
print(f"{sums[2]} {self.msg.pkg(sums[2])} will be installed, {sums[1]} will be upgraded and "
f"{sums[0]} will be reinstalled.")
print(f"Need to get {size[0]} {unit[0]} of archives.")
print(f"After this process, {size[1]} {unit[1]} of additional disk "
f"space will be used.{self.endc}")
print()
self.if_all_installed()
if self.msg.answer() in ["y", "Y"]:
@ -221,20 +220,17 @@ class BinaryInstall:
installs, upgraded = [], []
for inst in (self.dep_install + self.install):
package = (self.tmp_path + inst).split()
pkg_ver = "{0}-{1}".format(split_package(inst)[0],
split_package(inst)[1])
pkg_ver = f"{split_package(inst)[0]}-{split_package(inst)[1]}"
self.checksums(inst)
if GetFromInstalled(split_package(inst)[0]).name():
print("[ {0}upgrading{1} ] --> {2}".format(
self.meta.color["YELLOW"], self.meta.color["ENDC"], inst))
print(f"[ {self.yellow}upgrading{self.endc} ] --> {inst}")
upgraded.append(pkg_ver)
if "--reinstall" in self.flag:
PackageManager(package).upgrade("--reinstall")
else:
PackageManager(package).upgrade("--install-new")
else:
print("[ {0}installing{1} ] --> {2}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
print(f"[ {self.green}installing{self.endc} ] --> {inst}")
installs.append(pkg_ver)
PackageManager(package).upgrade("--install-new")
return [installs, upgraded]
@ -249,8 +245,7 @@ class BinaryInstall:
ins_ver = "0"
if parse_version(rep_ver) < parse_version(ins_ver):
self.msg.template(78)
print("| Package {0} don't downgrade, "
"setting by user".format(name))
print(f"| Package {name} don't downgrade, setting by user")
self.msg.template(78)
return True
@ -302,26 +297,18 @@ class BinaryInstall:
COLOR = self.meta.color["RED"]
uni_sum += 1
ver = GetFromInstalled(pkg_repo[0]).version()
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
COLOR, pkg_repo[0] + ver, self.meta.color["ENDC"],
" " * (23-len(pkg_repo[0] + ver)), pkg_repo[1],
" " * (18-len(pkg_repo[1])), pkg_repo[2],
" " * (8-len(pkg_repo[2])), pkg_repo[3],
" " * (7-len(pkg_repo[3])), repo,
comp, " K").rstrip())
print(f" {COLOR}{pkg_repo[0] + ver}{self.endc}"
f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}"
f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}"
f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}"
f"{' ' * (7-len(pkg_repo[3]))}{repo}{comp:>11}{' K'}")
return [pkg_sum, upg_sum, uni_sum]
def top_view(self):
"""Print packages status bar
"""
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"New Version", " " * 8,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
"Size"))
print(f"| Package{' ' * 17}New Version{' ' * 8}Arch{' ' * 4}Build{' ' * 2}Repos{' ' * 10}Size")
self.msg.template(78)
def store(self, packages):
@ -338,7 +325,7 @@ class BinaryInstall:
if (pk and pkg == split_package(pk)[0] and
pk not in install and
split_package(pk)[0] not in self.blacklist):
dwn.append("{0}{1}/{2}".format(self.mirror, loc, pk))
dwn.append(f"{self.mirror}{loc}/{pk}")
install.append(pk)
comp_sum.append(comp)
uncomp_sum.append(uncomp)
@ -349,7 +336,7 @@ class BinaryInstall:
name = split_package(pk)[0]
if (pk and pkg in name and name not in self.blacklist):
self.matching = True
dwn.append("{0}{1}/{2}".format(self.mirror, loc, pk))
dwn.append(f"{self.mirror}{loc}/{pk}")
install.append(pk)
comp_sum.append(comp)
uncomp_sum.append(uncomp)

View file

@ -41,22 +41,21 @@ class RepoInit:
def fetch(self):
if self.repo in self.meta.default_repositories:
exec("self._init_{0}()".format(self.repo))
exec(f"self._init_{self.repo}()")
else:
exec("self._init_custom()")
self.lib = self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(
self.repo)
self.lib = self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT"
PACKAGES_TXT = Utils().read_file(self.lib)
return PACKAGES_TXT, self.mirror
def _init_custom(self):
self.mirror = "{0}".format(Repo().custom_repository()[self.repo])
self.mirror = f"{Repo.custom_repository()[self.repo]}"
def _init_slack(self):
self.mirror = mirrors(name="", location="")
def _init_rlw(self):
self.mirror = "{0}{1}/".format(self.def_repo_dict["rlw"], slack_ver())
self.mirror = f"{self.def_repo_dict}{slack_ver()}/"
def _init_alien(self):
ver = slack_ver()
@ -65,30 +64,28 @@ class RepoInit:
arch = "x86_64"
if self.meta.slack_rel == "current":
ver = self.meta.slack_rel
self.mirror = "{0}{1}/{2}/".format(self.def_repo_dict["alien"],
ver, arch)
self.mirror = f"{self.def_repo_dict['alien']}{ver}/{arch}/"
def _init_slacky(self):
arch = ""
if self.meta.arch == "x86_64":
arch = "64"
self.mirror = "{0}slackware{1}-{2}/".format(
self.def_repo_dict["slacky"], arch, slack_ver())
self.mirror = f"{self.def_repo_dict}slackware{arch}-{slack_ver()}/"
def _init_conrad(self):
self.mirror = self.def_repo_dict["conrad"]
def _init_slonly(self):
ver = slack_ver()
arch = "{0}-x86".format(ver)
arch = f"{ver}-x86"
if self.meta.arch == "x86_64":
arch = "{0}-x86_64".format(ver)
arch = f"{ver}-x86_64"
if self.meta.slack_rel == "current":
if self.meta.arch == "x86_64":
arch = "{0}-x86_64".format(self.meta.slack_rel)
arch = f"{self.meta.slack_rel}-x86_64"
else:
arch = "{0}-x86".format(self.meta.slack_rel)
self.mirror = "{0}{1}/".format(self.def_repo_dict["slonly"], arch)
arch = f"{self.meat.slack_rel}-x86"
self.mirror = f"{self.def_repo_dict['slonly']}{arch}/"
def _init_ktown(self):
self.mirror = self.def_repo_dict["ktown"]
@ -103,23 +100,20 @@ class RepoInit:
arch = ""
if self.meta.arch == "x86_64":
arch = "64"
self.mirror = "{0}slacke{1}/slackware{2}-{3}/".format(
self.def_repo_dict["slacke"], self.meta.slacke_sub_repo[1:-1],
arch, slack_ver())
self.mirror = (f"{self.def_repo_dict['slacke']}"
f"slacke{self.meta.slacke_sub_repo[1:-1]}/slackware{arch}-{slack_ver()}/")
def _init_salix(self):
arch = "i486"
if self.meta.arch == "x86_64":
arch = "x86_64"
self.mirror = "{0}{1}/{2}/".format(self.def_repo_dict["salix"],
arch, slack_ver())
self.mirror = f"{self.def_repo_dict['salix']}{arch}/{slack_ver()}/"
def _init_slackl(self):
arch = "i486"
if self.meta.arch == "x86_64":
arch = "x86_64"
self.mirror = "{0}{1}/current/".format(self.def_repo_dict["slackl"],
arch)
self.mirror = f"{self.def_repo_dict['slackl']}{arch}/current/"
def _init_rested(self):
self.mirror = self.def_repo_dict["rested"]
@ -128,28 +122,22 @@ class RepoInit:
arch = "x86"
if self.meta.arch == "x86_64":
arch = "x86_64"
self.mirror = "{0}{1}/{2}/{3}/".format(
self.def_repo_dict["msb"], slack_ver(),
self.meta.msb_sub_repo[1:-1], arch)
self.mirror = f"{self.def_repo_dict['msb']}{slack_ver()}/{self.meta.msb_sub_repo[1:-1]}/{arch}/"
def _init_csb(self):
arch = "x86"
if self.meta.arch == "x86_64":
arch = "x86_64"
self.mirror = "{0}{1}/{2}".format(
self.def_repo_dict["csb"], slack_ver(), arch)
self.mirror = f"{self.def_repo_dict['csb']}{slack_ver()}/{arch}"
def _init_connos(self):
arch = ""
if self.meta.arch == "x86_64":
arch = "64"
self.mirror = "{0}slack-n-free{1}-{2}/".format(
self.def_repo_dict["connos"], arch, slack_ver())
self.mirror = f"{self.def_repo_dict['connos']}slack-n-free{arch}-{slack_ver()}/"
def _init_mles(self):
arch = "32"
if self.meta.arch == "x86_64":
arch = "64"
self.mirror = "{0}{1}-{2}-{3}bit/".format(
self.def_repo_dict["mles"],
self.meta.mles_sub_repo[1:-1], slack_ver(), arch)
self.mirror = f"{self.def_repo_dict['mles']}{self.meta.mles_sub_repo[1:-1]}-{slack_ver()}-{arch}bit/"

View file

@ -33,8 +33,7 @@ def search_pkg(name, repo):
"""Search if package exists in PACKAGES.TXT file
and return the name.
"""
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
names = Utils().package_name(PACKAGES_TXT)
blacklist = BlackList().packages(pkgs=names, repo=repo)
for line in PACKAGES_TXT.splitlines():

View file

@ -33,8 +33,10 @@ class BlackList:
"""Blacklist class to add, remove or listed packages
in blacklist file."""
def __init__(self):
self.meta = _meta_
self.quit = False
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.blackfile = "/etc/slpkg/blacklist"
self.black_conf = ""
if os.path.isfile(self.blackfile):
@ -56,8 +58,7 @@ class BlackList:
print("\nPackages in the blacklist:\n")
for black in self.get_black():
if black:
print("{0}{1}{2}".format(self.meta.color["GREEN"], black,
self.meta.color["ENDC"]))
print(f"{self.green}{black}{self.endc}")
self.quit = True
if self.quit:
print() # new line at exit
@ -71,8 +72,7 @@ class BlackList:
with open(self.blackfile, "a") as black_conf:
for pkg in pkgs:
if pkg not in blacklist:
print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"]))
print(f"{self.green}{pkg}{self.endc}")
black_conf.write(pkg + "\n")
self.quit = True
black_conf.close()
@ -88,8 +88,7 @@ class BlackList:
if line not in pkgs:
remove.write(line + "\n")
else:
print("{0}{1}{2}".format(self.meta.color["RED"], line,
self.meta.color["ENDC"]))
print(f"{self.red}{line}{self.endc}")
self.quit = True
remove.close()
if self.quit:

View file

@ -34,6 +34,9 @@ class Updates:
def __init__(self, repo):
self.repo = repo
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.grey = _meta_.color["GREY"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.check = 2
self.st = ""
@ -111,15 +114,14 @@ class Updates:
self.count_repo += 1
if self.check == 1:
self.count_news += 1
self.st = "{0}News in ChangeLog.txt{1}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"])
self.st = f"{self.green}News in ChangeLog.txt{self.endc}"
elif self.check == 0:
self.st = "No changes in ChangeLog.txt"
def print_status(self, repo):
"""Print status
"""
print(" {0}{1}{2}".format(repo, " " * (19 - len(repo)), self.st))
print(f" {repo}{' ' * (19 - len(repo))}{self.st}")
def summary(self):
"""Print summary
@ -131,6 +133,4 @@ class Updates:
cmd = "Repository is updated."
if self.count_news > 0:
cmd = "Run the command 'slpkg update'."
print("{0}From {1} repositories need {2} updating. {3}{4}\n".format(
self.meta.color["GREY"], self.count_repo, self.count_news, cmd,
self.meta.color["ENDC"]))
print(f"{self.grey}From {self.count_repo} repositories need {self.count_news} updating. {cmd}{self.endc}", end="\n")

View file

@ -36,6 +36,10 @@ class Config:
def __init__(self):
self.config_file = "/etc/slpkg/slpkg.conf"
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
self.endc = _meta_.color["ENDC"]
def view(self):
"""View slpkg config file
@ -70,25 +74,20 @@ class Config:
read_conf = Utils().read_file(self.config_file)
for line in read_conf.splitlines():
if not line.startswith("#") and line.split("=")[0] in conf_args:
print("{0}".format(line))
print(line)
else:
print("{0}{1}{2}".format(self.meta.color["CYAN"], line,
self.meta.color["ENDC"]))
print() # new line at end
print(f"{self.cyan}{line}{self.endc}", end="\n")
def edit(self):
"""Edit configuration file
"""
subprocess.call("{0} {1}".format(self.meta.editor,
self.config_file), shell=True)
subprocess.call(f"{self.meta.editor} {self.config_file}", shell=True)
def reset(self):
"""Reset slpkg.conf file with default values
"""
shutil.copy2(self.config_file + ".orig", self.config_file)
if filecmp.cmp(self.config_file + ".orig", self.config_file):
print("{0}The reset was done{1}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"]))
print(f"{self.green}The reset was done{self.endc}")
else:
print("{0}Reset failed{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"]))
print(f"{self.red}Reset failed{self.endc}")

View file

@ -38,20 +38,17 @@ class PkgDesc:
self.paint = paint
self.meta = _meta_
self.msg = Msg()
self.COLOR = ""
self.lib = ""
color_text = {
self.color = {
"red": self.meta.color["RED"],
"green": self.meta.color["GREEN"],
"yellow": self.meta.color["YELLOW"],
"cyan": self.meta.color["CYAN"],
"grey": self.meta.color["GREY"],
"": ""
}
self.COLOR = color_text[self.paint]
}[self.paint]
if self.repo in self.meta.repositories and self.repo != "sbo":
self.lib = self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(
self.repo)
self.lib = f"{self.meta.lib_path}{self.repo}_repo/PACKAGES.TXT"
def view(self):
"""Print package description by repository
@ -69,8 +66,7 @@ class PkgDesc:
if count == 11:
break
if description:
print("{0}{1}{2}".format(self.COLOR, description,
self.meta.color["ENDC"]))
print(f"{self.color}{description}{self.meta.color['ENDC']}")
else:
self.msg.pkg_not_found("", self.name, "No matching", "\n")
raise SystemExit(1)

View file

@ -42,6 +42,9 @@ class Download:
self.repo = repo
self.file_name = ""
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.dir_prefix = ""
self.downder = self.meta.downder
@ -61,24 +64,13 @@ class Download:
self._make_tarfile(self.file_name, source_dir)
self._check_certificate()
print("\n[{0}/{1}][ {2}Download{3} ] --> {4}\n".format(
dwn_count, len(self.url), self.meta.color["GREEN"],
self.meta.color["ENDC"],
self.file_name))
print(f"\n[{dwn_count}/{len(self.url)}][ {self.green}Download{self.endc} ] --> {self.file_name}\n")
if self.downder in ["wget"]:
subprocess.call("{0} {1} {2}{3} {4}".format(
self.downder, self.downder_options,
self.dir_prefix, self.path, dwn),
shell=True)
subprocess.call(f"{self.downder} {self.downder_options} {self.dir_prefix}{self.path} {dwn}", shell=True)
if self.downder in ["aria2c"]:
subprocess.call("{0} {1} {2}{3} {4}".format(
self.downder, self.downder_options,
self.dir_prefix, self.path[:-1], dwn),
shell=True)
subprocess.call(f"{self.downder} {self.downder_options} {self.dir_prefix}{self.path[:-1]} {dwn}", shell=True)
elif self.downder in ["curl", "http"]:
subprocess.call("{0} {1} {2}{3} {4}".format(
self.downder, self.downder_options,
self.path, self.file_name, dwn), shell=True)
subprocess.call(f"{self.downder} {self.downder_options} {self.path}{self.file_name} {dwn}", shell=True)
self._check_if_downloaded()
dwn_count += 1
@ -102,9 +94,7 @@ class Download:
if not os.path.isfile(self.path + self.file_name):
print()
self.msg.template(78)
print("| Download '{0}' file [ {1}FAILED{2} ]".format(
self.file_name, self.meta.color["RED"],
self.meta.color["ENDC"]))
print(f"| Download '{self.file_name}' file [ {self.red}FAILED{self.endc} ]")
self.msg.template(78)
print()
if not self.msg.answer() in ["y", "Y"]:
@ -118,8 +108,7 @@ class Download:
certificate = (' --no-check-certificate --header="Cookie: '
'oraclelicense=accept-securebackup-cookie"')
self.msg.template(78)
print("| '{0}' need to go ahead downloading".format(
certificate[:23].strip()))
print(f"| '{certificate[:23].strip()}' need to go ahead downloading")
self.msg.template(78)
print()
self.downder_options += certificate

View file

@ -26,6 +26,12 @@ import os
import subprocess
# class ImportErrorGraphEasy(Exception):
# def __init__(self, GraphEasyImportError):
# Exception.__init__(self, "graph-easy required")
# self.GraphEasyImportError = GraphEasyImportError
class Graph:
"""Drawing dependencies diagram
"""
@ -46,13 +52,10 @@ class Graph:
try:
import pygraphviz as pgv
except ImportError:
graph_easy, comma = "", ""
if (self.image == "ascii" and
not os.path.isfile("/usr/bin/graph-easy")):
comma = ","
graph_easy = " graph-easy"
print("Require 'pygraphviz{0}{1}': Install with 'slpkg -s sbo "
"pygraphviz{1}'".format(comma, graph_easy))
if self.image == "ascii" and not os.path.isfile("/usr/bin/graph-easy"):
print("Require 'grap_easy': Install with 'slpkg -s sbo graph-easy'")
else:
print("Require 'pygraphviz: Install with 'slpkg -s sbo pygraphviz'")
raise SystemExit()
if self.image != "ascii":
self.check_file()
@ -60,24 +63,23 @@ class Graph:
G = pgv.AGraph(deps_dict)
G.layout(prog="fdp")
if self.image == "ascii":
G.write("{0}.dot".format(self.image))
G.write(f"{self.image}.dot")
self.graph_easy()
G.draw(self.image)
except IOError:
raise SystemExit()
if os.path.isfile(self.image):
print("Graph image file '{0}' created".format(self.image))
print(f"Graph image file '{self.image}' created")
raise SystemExit()
def check_file(self):
"""Check for file format and type
"""
try:
image_type = ".{0}".format(self.image.split(".")[1])
image_type = f".{self.image.split('.')[1]}"
if image_type not in self.file_format:
print("Format: '{0}' not recognized. Use one of "
"them:\n{1}".format(self.image.split(".")[1],
", ".join(self.file_format)))
print(f"Format: '{self.image.split('.')[1]}' not recognized. Use one of "
f"them:\n{', '.join(self.file_format)}")
raise SystemExit()
except IndexError:
print("slpkg: Error: Image file suffix missing")
@ -91,12 +93,12 @@ class Graph:
"graph-easy'")
self.remove_dot()
raise SystemExit()
subprocess.call("graph-easy {0}.dot".format(self.image), shell=True)
subprocess.call(f"graph-easy {self.image}.dot", shell=True)
self.remove_dot()
raise SystemExit()
def remove_dot(self):
"""Remove .dot files
"""
if os.path.isfile("{0}.dot".format(self.image)):
os.remove("{0}.dot".format(self.image))
if os.path.isfile(f"{self.image}.dot"):
os.remove(f"{self.image}.dot")

View file

@ -39,11 +39,11 @@ def pkg_checksum(binary, repo):
elif repo == "slpkg":
CHECKSUMS_md5 = URL(_meta_.CHECKSUMS_link).reading()
else:
lib = "{0}{1}_repo/CHECKSUMS.md5".format(_meta_.lib_path, repo)
lib = f"{_meta_.lib_path}{repo}_repo/CHECKSUMS.md5"
f = open(lib, "r")
CHECKSUMS_md5 = f.read()
f.close()
for line in CHECKSUMS_md5.splitlines():
if line.endswith("/{0}".format(binary)):
if line.endswith(f"/{binary}"):
md5 = line.split()[0]
return md5

View file

@ -36,6 +36,10 @@ class PackageHealth:
def __init__(self, mode):
self.mode = mode
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.yellow = _meta_.color["YELLOW"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.pkg_path = _meta_.pkg_path
self.installed = []
@ -56,9 +60,7 @@ class PackageHealth:
"/incoming/" not in line):
if not os.path.isfile(r"/" + line):
self.cn += 1
print("Not installed: {0}/{1}{2} --> {3}".format(
self.meta.color["RED"], line, self.meta.color["ENDC"],
pkg))
print(f"Not installed: {self.red}/{line}{self.endc} --> {pkg}")
elif not self.mode:
print(line)
except IOError:
@ -76,7 +78,7 @@ class PackageHealth:
with open(self.pkg_path + pkg, "r") as fopen:
for line in fopen:
if "\0" in line:
print("Null: {0}").format(line)
print(f"Null: {line}")
break
self.cf += 1 # count all files
self.lf += 1 # count each package files
@ -90,18 +92,14 @@ class PackageHealth:
print()
per = int(round((float(self.cf) / (self.cf + self.cn)) * 100))
if per > 90:
color = self.meta.color["GREEN"]
color = self.green
elif per < 90 and per > 60:
color = self.meta.color["YELLOW"]
color = self.yellow
elif per < 60:
color = self.meta.color["RED"]
health = "{0}{1}%{2}".format(color, str(per), self.meta.color["ENDC"])
color = self.red
health = f"{color}{str(per)}%{self.endc}"
self.msg.template(78)
print("| {0}{1}{2}{3}{4}".format(
"Total files", " " * 7, "Not installed", " " * 40, "Health"))
print(f"| Total files{' ' * 7}Not installed{' ' * 40}Health")
self.msg.template(78)
print("| {0}{1}{2}{3}{4:>4}".format(
self.cf, " " * (18-len(str(self.cf))),
self.cn, " " * (55-len(str(self.cn))),
health))
print(f"| {self.cf}{' ' * (18-len(str(self.cf)))}{self.cn}{' ' * (55-len(str(self.cn)))}{health:>4}")
self.msg.template(78)

View file

@ -73,7 +73,7 @@ class Initialization:
"""
repo = Repo().custom_repository()[name]
log = self.log_path + name + "/"
lib = self.lib_path + "{0}_repo/".format(name)
lib = self.lib_path + f"{name}_repo/"
repo_name = log[:-1].split("/")[-1]
lib_file = "PACKAGES.TXT"
# lst_file = ""
@ -83,10 +83,10 @@ class Initialization:
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = "{0}{1}".format(repo, lib_file)
PACKAGES_TXT = f"{name}{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}".format(repo, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -161,10 +161,10 @@ class Initialization:
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
SLACKBUILDS_TXT = "{0}{1}/{2}".format(repo, slack_ver(), lib_file)
SLACKBUILDS_TXT = f"{repo}{slack_ver()}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = ""
ChangeLog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file)
ChangeLog_txt = f"{repo}{slack_ver()}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, SLACKBUILDS_TXT, repo_name)
@ -187,10 +187,10 @@ class Initialization:
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = "{0}{1}/{2}".format(repo, slack_ver(), lib_file)
PACKAGES_TXT = f"{repo}{slack_ver()}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}/{2}".format(repo, slack_ver(), md5_file)
ChangeLog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file)
CHECKSUMS_MD5 = f"{repo}{slack_ver()}/{md5_file}"
ChangeLog_txt = f"{repo}{slack_ver()}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -221,10 +221,10 @@ class Initialization:
ar = arch
if self.meta.slack_rel == "current":
ver = self.meta.slack_rel
PACKAGES_TXT = "{0}/{1}/{2}/{3}".format(repo, ver, ar, lib_file)
PACKAGES_TXT = f"{repo}/{ver}/{ar}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}/{1}/{2}/{3}".format(repo, ver, ar, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}/{ver}/{ar}/{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -252,14 +252,11 @@ class Initialization:
os.mkdir(lib)
if arch == "x86_64":
ar = "64"
PACKAGES_TXT = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
lib_file)
PACKAGES_TXT = f"{repo}slackware{ar}-{slack_ver()}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
md5_file)
CHECKSUMS_MD5 = f"{repo}slackware{ar}-{slack_ver()}/{md5_file}"
ChangeLog_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
log_file)
ChangeLog_txt = f"{repo}slackware{ar}-{slack_ver()}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -283,10 +280,10 @@ class Initialization:
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = "{0}{1}".format(repo, lib_file)
PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}".format(repo, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -299,7 +296,7 @@ class Initialization:
"""Creating slackers local library
"""
ver = slack_ver()
ar = "{0}-x86".format(ver)
ar = f"{ver}-x86"
arch = self.meta.arch
repo = self.def_repos_dict["slonly"]
log = self.log_path + "slonly/"
@ -314,15 +311,15 @@ class Initialization:
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "{0}-x86_64".format(ver)
ar = f"{ver}-x86_64"
if self.meta.slack_rel == "current":
ar = "{0}-x86".format(self.meta.slack_rel)
ar = f"{self.meta.slack_rel}-x86"
if self.meta.slack_rel == "current" and arch == "x86_64":
ar = "{0}-x86_64".format(self.meta.slack_rel)
PACKAGES_TXT = "{0}{1}/{2}".format(repo, ar, lib_file)
ar = f"{self.meta.slack_rel}-x86_64"
PACKAGES_TXT = f"{repo}{ar}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}/{2}".format(repo, ar, md5_file)
ChangeLog_txt = "{0}{1}/{2}".format(repo, ar, log_file)
CHECKSUMS_MD5 = f"{repo}{ar}/{md5_file}"
ChangeLog_txt = f"{repo}{ar}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -346,10 +343,10 @@ class Initialization:
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = "{0}{1}".format(repo, lib_file)
PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}".format(repo, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -376,10 +373,10 @@ class Initialization:
os.mkdir(lib)
if self.meta.slack_rel == "current":
ver = self.meta.slack_rel
PACKAGES_TXT = "{0}{1}/{2}".format(repo, ver, lib_file)
PACKAGES_TXT = f"{repo}{ver}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}/{2}".format(repo, ver, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}{ver}/{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -408,13 +405,10 @@ class Initialization:
if arch == "x86_64":
ar = "64"
version = self.meta.slacke_sub_repo[1:-1]
PACKAGES_TXT = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, version, ar, slack_ver(), lib_file)
PACKAGES_TXT = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, version, ar, slack_ver(), md5_file)
ChangeLog_txt = "{0}slacke{1}/slackware{2}-{3}/{4}".format(
repo, version, ar, slack_ver(), log_file)
CHECKSUMS_MD5 = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{md5_file}"
ChangeLog_txt = f"{repo}slacke{version}/slackware{ar}-{slack_ver()}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -442,10 +436,10 @@ class Initialization:
os.mkdir(lib)
if arch == "x86_64":
ar = "x86_64"
PACKAGES_TXT = "{0}{1}/{2}/{3}".format(repo, ar, slack_ver(), lib_file)
PACKAGES_TXT = f"{repo}{ar}/{slack_ver()}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}/{2}/{3}".format(repo, ar, slack_ver(), md5_file)
ChangeLog_txt = "{0}{1}/{2}/{3}".format(repo, ar, slack_ver(), log_file)
CHECKSUMS_MD5 = f"{repo}{ar}/{slack_ver()}/{md5_file}"
ChangeLog_txt = f"{repo}{ar}/{slack_ver()}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -473,10 +467,10 @@ class Initialization:
os.mkdir(lib)
if arch == "x86_64":
ar = "x86_64"
PACKAGES_TXT = "{0}{1}/current/{2}".format(repo, ar, lib_file)
PACKAGES_TXT = f"{repo}{ar}/current/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}/current/{2}".format(repo, ar, md5_file)
ChangeLog_txt = "{0}{1}/current/{2}".format(repo, ar, log_file)
CHECKSUMS_MD5 = f"{repo}{ar}/current/{md5_file}"
ChangeLog_txt = f"{repo}{ar}/current/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -500,10 +494,10 @@ class Initialization:
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
PACKAGES_TXT = "{0}{1}".format(repo, lib_file)
PACKAGES_TXT = f"{repo}{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}".format(repo, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -535,12 +529,10 @@ class Initialization:
version = self.meta.msb_sub_repo[1:-1]
if self.meta.slack_rel == "current":
ver_slack = self.meta.slack_rel
PACKAGES_TXT = "{0}{1}/{2}/{3}/{4}".format(
repo, ver_slack, version, ar, lib_file)
PACKAGES_TXT = f"{repo}{ver_slack}/{version}/{ar}/{md5_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}/{2}/{3}/{4}".format(
repo, ver_slack, version, ar, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}{ver_slack}/{version}/{ar}/{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -571,12 +563,10 @@ class Initialization:
ar = "x86_64"
if self.meta.slack_rel == "current":
ver_slack = self.meta.slack_rel
PACKAGES_TXT = "{0}{1}/{2}/{3}".format(
repo, ver_slack, ar, lib_file)
PACKAGES_TXT = f"{repo}{ver_slack}/{ar}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}/{2}/{3}".format(
repo, ver_slack, ar, md5_file)
ChangeLog_txt = "{0}{1}".format(repo, log_file)
CHECKSUMS_MD5 = f"{repo}{ver_slack}/{ar}/{md5_file}"
ChangeLog_txt = f"{repo}{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -605,14 +595,10 @@ class Initialization:
os.mkdir(lib)
if arch == "x86_64":
ar = "64"
PACKAGES_TXT = "{0}{1}{2}-{3}/{4}".format(repo, nickname, ar,
slack_ver(), lib_file)
PACKAGES_TXT = f"{repo}{nickname}{ar}-{slack_ver()}/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}{2}-{3}/{4}".format(repo, nickname, ar,
slack_ver(), md5_file)
ChangeLog_txt = "{0}{1}{2}-{3}/{4}".format(repo, nickname, ar,
slack_ver(), log_file)
CHECKSUMS_MD5 = f"{repo}{nickname}{ar}-{slack_ver()}/{md5_file}"
ChangeLog_txt = f"{repo}{nickname}{ar}-{slack_ver()}/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -641,13 +627,10 @@ class Initialization:
if arch == "x86_64":
ar = "64"
version = self.meta.mles_sub_repo[1:-1]
PACKAGES_TXT = "{0}{1}-{2}-{3}bit/{4}".format(
repo, version, slack_ver(), ar, lib_file)
PACKAGES_TXT = f"{repo}{version}-{slack_ver()}-{ar}bit/{lib_file}"
FILELIST_TXT = ""
CHECKSUMS_MD5 = "{0}{1}-{2}-{3}bit/{4}".format(
repo, version, slack_ver(), ar, md5_file)
ChangeLog_txt = "{0}{1}-{2}-{3}bit/{4}".format(
repo, version, slack_ver(), ar, log_file)
CHECKSUMS_MD5 = f"{repo}{version}-{slack_ver()}-{ar}bit/{md5_file}"
ChangeLog_txt = f"{repo}{version}-{slack_ver()}-{ar}bit/{log_file}"
if self.check:
return self.checks_logs(log, ChangeLog_txt)
self.down(lib, PACKAGES_TXT, repo_name)
@ -705,9 +688,10 @@ class Initialization:
code = "utf-8"
with open(path + outfile, 'w', encoding=code) as out_f:
for f in infiles:
if os.path.isfile("{0}{1}".format(path, f)):
if os.path.isfile(f"{path}{f}"):
# checking the encoding before read the file
code = Utils.check_encoding(path, f)
utils = Utils()
code = utils.check_encoding(path, f)
with open(path + f, "r", encoding=code) as in_f:
for line in in_f:
out_f.write(line)
@ -737,14 +721,12 @@ class Initialization:
if only:
repositories = only
for repo in repositories:
changelogs = "{0}{1}{2}".format(self.log_path, repo,
"/ChangeLog.txt")
changelogs = f"{self.log_path}{repo}/ChangeLog.txt"
if os.path.isfile(changelogs):
os.remove(changelogs)
if os.path.isdir(self.lib_path + "{0}_repo/".format(repo)):
for f in (os.listdir(self.lib_path + "{0}_repo/".format(
repo))):
files = "{0}{1}_repo/{2}".format(self.lib_path, repo, f)
if os.path.isdir(self.lib_path + f"{repo}_repo/"):
for f in (os.listdir(self.lib_path + f"{repo}_repo/")):
files = f"{self.lib_path}{repo}_repo/{f}"
if os.path.isfile(files):
os.remove(files)
elif os.path.isdir(files):
@ -757,10 +739,12 @@ class Update:
def __init__(self):
self.initialization = globals()['Initialization'](False)
self.meta = _meta_
self.done = "{0}Done{1}\n".format(self.meta.color["GREY"],
self.meta.color["ENDC"])
self.error = "{0}Error{1}\n".format(self.meta.color["RED"],
self.meta.color["ENDC"])
self.grey = _meta_.color["GREY"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
self.endc = _meta_.color["ENDC"]
self.done = f"{self.grey}Done{self.endc}\n"
self.error = f"{self.red}Error{self.endc}\n"
def repository(self, only):
"""Update repositories lists
@ -773,11 +757,7 @@ class Update:
for repo in enabled:
if check_for_local_repos(repo) is True:
continue
print("{0}Check repository [{1}{2}{3}] ... "
"{4}".format(self.meta.color["GREY"],
self.meta.color["CYAN"], repo,
self.meta.color["GREY"],
self.meta.color["ENDC"]), end="", flush=True)
print(f"{self.grey}Check repository [{self.cyan}{repo}{self.grey}] ... {self.endc}", end="", flush=True)
if repo in default:
update = getattr(self.initialization, repo)
update()
@ -800,8 +780,8 @@ def check_exists_repositories(repo):
if check_for_local_repos(repo) is True:
pkg_list = "PACKAGES.TXT"
return ""
if not os.path.isfile("{0}{1}{2}".format(
_meta_.lib_path, repo, "_repo/{0}".format(pkg_list))):
if not os.path.isfile(f"{_meta_.lib_path}{repo}_repo/{pkg_list}"):
# .format(_meta_.lib_path, repo, "_repo/{0}".format(pkg_list))):
return repo
return ""

View file

@ -37,14 +37,12 @@ def library(repo):
pkg_list, packages = [], ""
if repo == "sbo":
if (os.path.isfile(
_meta_.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(repo))):
packages = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))
_meta_.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")):
packages = Utils().read_file(_meta_.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")
else:
if (os.path.isfile(
_meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(repo))):
packages = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")):
packages = Utils().read_file(_meta_.lib_path + f"{repo}_repo/PACKAGES.TXT")
for line in packages.splitlines():
if repo == "sbo":
if line.startswith("SLACKBUILD NAME: "):

View file

@ -677,8 +677,7 @@ class ArgParse:
self.args.remove(arg)
break
if tag and tag not in colors:
print("\nslpkg: Error: Available colors {0}\n".format(
colors))
print(f"\nslpkg: Error: Available colors {colors}\n")
raise SystemExit()
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in self.meta.repositories and tag in colors):
@ -779,7 +778,7 @@ class ArgParse:
from dialog import Dialog
except ImportError:
print("Require 'pythondialog': Install with 'slpkg -s sbo "
"python2-pythondialog'")
"python3-pythondialog'")
raise SystemExit()

View file

@ -32,32 +32,34 @@ class Msg:
"""
def __init__(self):
self.meta = _meta_
self.grey = _meta_.color["GREY"]
self.red = _meta_.color["RED"]
self.cyan = _meta_.color["CYAN"]
self.endc = _meta_.color["ENDC"]
def pkg_not_found(self, bol, pkg, message, eol):
"""Print message when package not found
"""
print("{0}No such package {1}: {2}{3}".format(bol, pkg, message, eol))
print(f"{bol}No such package {pkg}: {message}{eol}")
def pkg_found(self, prgnam):
"""Print message when package found
"""
print("| Package {0} is already installed".format(prgnam))
print(f"| Package {prgnam} is already installed")
def pkg_installed(self, pkg):
"""Print message when package installed
"""
print("| Package {0} installed".format(pkg))
print(f"| Package {pkg} installed")
def build_FAILED(self, prgnam):
"""Print error message if build failed
"""
self.template(78)
print("| Some error on the package {0} [ {1}FAILED{2} ]".format(
prgnam, self.meta.color["RED"], self.meta.color["ENDC"]))
print(f"| Some error on the package {prgnam} [ {self.red}FAILED{self.endc} ]")
self.template(78)
print("| See the log file in '{0}/var/log/slpkg/sbo/build_logs{1}' "
"directory or read the README file".format(
self.meta.color["CYAN"], self.meta.color["ENDC"]))
print(f"| See the log file in '{self.cyan}/var/log/slpkg/sbo/build_logs{self.endc}' "
f"directory or read the README file")
self.template(78)
print() # new line at end
@ -69,29 +71,22 @@ class Msg:
def checking(self):
"""Message checking
"""
print("{0}Checking...{1} ".format(self.meta.color["GREY"],
self.meta.color["ENDC"]), end="",
flush=True)
print(f"{self.grey}Checking...{self.endc} ", end="", flush=True)
def reading(self):
"""Message reading
"""
print("{0}Reading package lists...{1} ".format(
self.meta.color["GREY"], self.meta.color["ENDC"]), end="",
flush=True)
print(f"{self.grey}Reading package lists...{self.endc} ", end="", flush=True)
def resolving(self):
"""Message resolving
"""
print("{0}Resolving dependencies...{1} ".format(
self.meta.color["GREY"], self.meta.color["ENDC"]), end="",
flush=True)
print(f"{self.grey}Resolving dependencies...{self.endc} ", end="", flush=True)
def done(self):
"""Message done
"""
print("\b{0}Done{1}\n".format(self.meta.color["GREY"],
self.meta.color["ENDC"]), end="")
print(f"\b{self.grey}Done{self.endc}\n", end="")
def pkg(self, count):
"""Print singular plural
@ -135,12 +130,11 @@ class Msg:
"""
print()
self.template(78)
print("| {0}{1}*** WARNING ***{2}").format(
" " * 27, self.meta.color["RED"], self.meta.color["ENDC"])
print(f"| {' ' * 27}{self.red}*** WARNING ***{self.endc}")
self.template(78)
print("| Before proceed with the package '{0}' will you must read\n"
"| the README file. You can use the command "
"'slpkg -n {1}'").format(pkg, pkg)
print(f"| Before proceed with the package '{pkg}' will you must read\n"
f"| the README file. You can use the command "
f"'slpkg -n {pkg}'")
self.template(78)
print()
@ -149,23 +143,19 @@ class Msg:
and upgraded
"""
self.template(78)
print("| Total {0} {1} installed and {2} {3} upgraded".format(
len(install), self.pkg(len(install)),
len(upgrade), self.pkg(len(upgrade))))
print(f"| Total {len(install)} {self.pkg(len(install))} installed and "
f"{len(upgrade)} {self.pkg(len(upgrade))} upgraded")
self.template(78)
for installed, upgraded in itertools.zip_longest(install, upgrade):
if upgraded:
print("| Package {0} upgraded successfully".format(upgraded))
print(f"| Package {upgraded} upgraded successfully")
if installed:
print("| Package {0} installed successfully".format(installed))
print(f"| Package {installed} installed successfully")
self.template(78)
print()
def matching(self, packages):
"""Message for matching packages
"""
print("\nNot found package with the name [ {0}{1}{2} ]. "
"Matching packages:\nNOTE: Not dependenc"
"ies are resolved\n".format(self.meta.color["CYAN"],
"".join(packages),
self.meta.color["ENDC"]))
print(f"\nNot found package with the name [ {self.cyan}{''.join(packages)}{self.endc} ]. "
f"Matching packages:\nNOTE: Not dependencies are resolved\n")

View file

@ -51,11 +51,10 @@ class NewConfig:
"""
self.find_new()
for n in self.news:
print("{0}".format(n))
print(f"{n}")
print()
self.msg.template(78)
print("| Installed {0} new configuration files:".format(
len(self.news)))
print(f"| Installed {len(self.news)} new configuration files:")
self.msg.template(78)
self.choices()
@ -76,16 +75,12 @@ class NewConfig:
def choices(self):
"""Menu options for new configuration files
"""
print("| {0}K{1}{2}eep the old and .new files, no changes".format(
self.red, self.endc, self.br))
print("| {0}O{1}{2}verwrite all old configuration files with new "
"ones".format(self.red, self.endc, self.br))
print(f"| {self.red}K{self.endc}{self.br}eep the old and .new files, no changes")
print(f"| {self.red}O{self.endc}{self.br}verwrite all old configuration files with new ones")
print("| The old files will be saved with suffix .old")
print("| {0}R{1}{2}emove all .new files".format(
self.red, self.endc, self.br))
print("| {0}P{1}{2}rompt K, O, R, D, M option for each single "
"file".format(self.red, self.endc, self.br))
print("| {0}Q{1}{2}uit from menu".format(self.red, self.endc, self.br))
print(f"| {self.red}R{self.endc}{self.br}emove all .new files")
print(f"| {self.red}P{self.endc}{self.br}rompt K, O, R, D, M option for each single file")
print(f"| {self.red}Q{self.endc}{self.br}uit from menu")
self.msg.template(78)
try:
choose = input("\nWhat would you like to do [K/O/R/P/Q]? ")
@ -141,7 +136,7 @@ class NewConfig:
"""Choose what do to file by file
"""
print()
prompt_ask = input("{0} [K/O/R/D/M/Q]? ".format(n))
prompt_ask = input(f"{n} [K/O/R/D/M/Q]? ")
print()
if prompt_ask in ("K", "k"):
self.keep()
@ -163,7 +158,7 @@ class NewConfig:
if os.path.isfile(n):
os.remove(n)
if not os.path.isfile(n):
print("File '{0}' removed".format(n))
print(f"File '{n}' removed")
def _overwrite(self, n):
"""Overwrite old file with new and keep file with suffix .old
@ -195,15 +190,15 @@ class NewConfig:
c += 1
if s1 != s2:
break
print("@@ -{0},{1} +{2},{3} @@\n".format(ln, c, ln, c))
print(f"@@ -{ln},{c} +{ln},{c} @@\n")
for line in lines[-3:]:
print("{0}".format(line))
print(f"{line}")
if a is None:
a = ""
print("{0}{1}{2}{3}".format(self.red, "-", self.endc, a))
print(f"{self.red}-{self.endc}{a}")
if b is None:
b = ""
print("{0}{1}{2}{3}".format(self.green, "+", self.endc, b))
print(f"{self.green}+{self.endc}{b}")
lines = []
c = 0
else:

View file

@ -52,7 +52,7 @@ class BuildPackage:
self.msg = Msg()
self._SOURCES = self.meta.SBo_SOURCES
self.prgnam = self.script[:-7]
self.log_file = "build_{0}_log".format(self.prgnam)
self.log_file = f"build_{self.prgnam}_log"
self.sbo_logs = self.meta.log_path + "sbo/"
self.build_logs = self.sbo_logs + "build_logs/"
self.start_log_time = time.strftime("%H:%M:%S")
@ -94,27 +94,21 @@ class BuildPackage:
shutil.copy2(src, self.path + self.prgnam)
os.chdir(self.path + self.prgnam)
# change permissions
subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam),
shell=True)
subprocess.call(f"chmod +x {self.prgnam}.SlackBuild", shell=True)
pass_var = self._pass_variable()
if self.meta.sbo_build_log in ["on", "ON"]:
if os.path.isfile(self.build_logs + self.log_file):
os.remove(self.build_logs + self.log_file)
# start log write
log_head(self.build_logs, self.log_file, self.start_log_time)
subprocess.Popen("{0} ./{1}.SlackBuild 2>&1 | tee -a "
"{2}{3}".format(" ".join(pass_var),
self.prgnam, self.build_logs,
self.log_file), shell=True,
stdout=sys.stdout).communicate()
subprocess.Popen(f"{' '.join(pass_var)} ./{self.prgnam}.SlackBuild 2>&1 | tee -a "
f"{self.build_logs}{self.log_file}", shell=True, stdout=sys.stdout).communicate()
sum_time = build_time(self.start_time)
# write end in log file
log_end(self.build_logs, self.log_file, sum_time)
print("Total build time for the package {0} : {1}\n".format(
self.prgnam, sum_time))
print(f"Total build time for the package {self.prgnam} : {sum_time}\n")
else:
subprocess.call("{0} ./{1}.SlackBuild".format(
" ".join(pass_var), self.prgnam), shell=True)
subprocess.call(f"{' '.join(pass_ver)} ./{self.prgnam}.SlackBuild", shell=True)
os.chdir(self.path)
except KeyboardInterrupt: # (OSError, IOError):
self.msg.pkg_not_found("\n", self.prgnam, "Wrong file", "\n")
@ -141,7 +135,7 @@ class BuildPackage:
"""
if self.meta.makeflags in ["on", "ON"]:
cpus = multiprocessing.cpu_count()
os.environ["MAKEFLAGS"] = "-j{0}".format(cpus)
os.environ["MAKEFLAGS"] = f"-j{cpus}"
def _pass_variable(self):
"""Return enviroment variables
@ -150,7 +144,7 @@ class BuildPackage:
for var in os.environ.keys():
expVAR = var.split("_")
if expVAR[0] == self.prgnam.upper() and expVAR[1] != "PATH":
pass_var.append("{0}={1}".format(expVAR[1], os.environ[var]))
pass_var.append(f"{expVAR[1]}={os.environ[var]}")
return pass_var
def _delete_sbo_tar_gz(self):
@ -188,7 +182,7 @@ def log_end(path, log_file, sum_time):
log.seek(2)
log.write("#" * 79 + "\n\n")
log.write("Time : " + time.strftime("%H:%M:%S") + "\n")
log.write("Total build time : {0}\n".format(sum_time))
log.write(f"Total build time : {sum_time}\n")
log.write(" " * 38 + "E N D\n\n")
log.write("#" * 79 + "\n\n")
log.close()
@ -204,11 +198,9 @@ def build_time(start_time):
elif diff_time > 59.99 and diff_time <= 3599.99:
sum_time = round(diff_time / 60, 2)
sum_time_list = re.findall(r"\d+", str(sum_time))
sum_time = ("{0} Min {1} Sec".format(sum_time_list[0],
sum_time_list[1]))
sum_time = (f"{sum_time_list[0]} Min {sum_time_list[1]} Sec")
elif diff_time > 3599.99:
sum_time = round(diff_time / 3600, 2)
sum_time_list = re.findall(r"\d+", str(sum_time))
sum_time = ("{0} Hours {1} Min".format(sum_time_list[0],
sum_time_list[1]))
sum_time = (f"{sum_time_list[0]} Hours {sum_time_list[1]} Min")
return sum_time

View file

@ -45,6 +45,12 @@ class PackageManager:
def __init__(self, binary):
self.binary = binary
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.yellow = _meta_.color["YELLOW"]
self.cyan = _meta_.color["CYAN"]
self.grey = _meta_.color["GREY"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.skip = []
self.size = 0
@ -56,8 +62,7 @@ class PackageManager:
"""
for pkg in self.binary:
try:
subprocess.call("installpkg {0} {1}".format(flag, pkg),
shell=True)
subprocess.call(f"installpkg {flag} {pkg}", shell=True)
check = pkg[:-4].split("/")[-1]
if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n")
@ -72,8 +77,7 @@ class PackageManager:
"""
for pkg in self.binary:
try:
subprocess.call("upgradepkg {0} {1}".format(flag, pkg),
shell=True)
subprocess.call(f"upgradepkg {flag} {pkg}", shell=True)
check = pkg[:-4].split("/")[-1]
if os.path.isfile(self.meta.pkg_path + check):
print("Completed!\n")
@ -183,8 +187,7 @@ class PackageManager:
for pkg in self.binary:
name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version()
package = find_package("{0}{1}{2}".format(
name, ver, self.meta.sp), self.meta.pkg_path)
package = find_package(f"{name}{ver}{self.meta.sp}", self.meta.pkg_path)
if pkg and name == pkg:
removed.append(pkg)
packages.append(package[0])
@ -197,14 +200,12 @@ class PackageManager:
"""View packages before removed
"""
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
self.cyan, ", ".join(self.binary), self.endc))
removed, packages = self._get_removed()
if packages and "--checklist" in self.extra:
removed = []
text = "Press 'spacebar' to unchoose packages from the remove"
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
backtitle = f"{self.meta.__all__} {self.meta.__version__}"
status = True
pkgs = DialogUtil(packages, text, " Remove ", backtitle,
status).checklist()
@ -215,16 +216,14 @@ class PackageManager:
else:
for rmv, pkg in zip(removed, packages):
self._sizes(pkg)
print("[ {0}delete{1} ] --> [ {2} ] - {3}".format(
self.meta.color["RED"], self.meta.color["ENDC"],
self.file_size, pkg))
print(f"[ {self.red}delete{self.endc} ] --> [ {self.file_size} ] - {pkg}")
self._calc_sizes()
self._remove_summary()
if "--third-party" in self.extra:
print("\n")
self.msg.template(78)
print(("| {0}{1}*** WARNING ***{2}").format(
" " * 27, self.meta.color["RED"], self.meta.color["ENDC"]))
" " * 27, self.red, self.endc))
print("| Before you use third-party option, be sure you have"
" updated the packages \n| lists. Run the command"
" 'slpkg update' and 'slpkg -c slack --upgrade'")
@ -248,8 +247,7 @@ class PackageManager:
print("\nRemoved summary")
print("=" * 79)
print("{0}Size of removed packages {1} {2}.{3}".format(
self.meta.color["GREY"], round(self.size, 2), self.unit,
self.meta.color["ENDC"]))
self.grey, round(self.size, 2), self.unit, self.endc))
def _view_deps(self, path, package):
"""View dependencies before remove
@ -267,8 +265,7 @@ class PackageManager:
if "--checklist" in self.extra:
deps, dependencies = [], []
text = "Found dependencies for the package {0}".format(package)
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
backtitle = f"{self.meta.__all__} {self.meta.__version__}"
status = True
deps = DialogUtil(packages, text, " Remove ", backtitle,
status).checklist()
@ -278,19 +275,16 @@ class PackageManager:
else:
print() # new line at start
self.msg.template(78)
print("| Found dependencies for the package {0}:".format(
package))
print(f"| Found dependencies for the package {package}:")
self.msg.template(78)
for pkg in packages:
find = find_package(pkg + self.meta.sp, self.meta.pkg_path)
self._sizes(find[0])
print("| {0}{1}{2}".format(self.meta.color["RED"], pkg,
self.meta.color["ENDC"]))
print(f"| {self.red}{pkg}{self.endc}")
self.msg.template(78)
self._calc_sizes()
print("| {0}Size of removed dependencies {1} {2}{3}".format(
self.meta.color["GREY"], round(self.size, 2), self.unit,
self.meta.color["ENDC"]))
self.grey, round(self.size, 2), self.unit, self.endc))
self.msg.template(78)
return dependencies
@ -298,8 +292,7 @@ class PackageManager:
"""removepkg Slackware command
"""
try:
subprocess.call("removepkg {0} {1}".format(self.flag, package),
shell=True)
subprocess.call(f"removepkg {self.flag} {package}", shell=True)
if os.path.isfile(self.dep_path + package):
os.remove(self.dep_path + package) # remove log
except subprocess.CalledProcessError as er:
@ -354,17 +347,14 @@ class PackageManager:
deps = Utils().read_file(self.dep_path + pkg)
for rmv in removes:
if GetFromInstalled(rmv).name() and rmv in deps.split():
pkg_dep.append(
"{0} is dependency of the package --> {1}".format(
rmv, pkg))
pkg_dep.append(f"{rmv} is dependency of the package --> {pkg}")
package.append(pkg)
dependency.append(rmv)
if package:
if "--checklist" in self.extra:
text = ("Press 'spacebar' to choose packages for the"
" remove exception")
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
backtitle = f"{self.meta.__all__} {self.meta.__version__}"
status = False
choose = DialogUtil(pkg_dep, text, " !!! WARNING !!! ",
backtitle, status).checklist()
@ -373,15 +363,11 @@ class PackageManager:
else:
self.msg.template(78)
print("| {0}{1}{2}".format(
self.meta.color["RED"], " " * 30 + "!!! WARNING !!!",
self.meta.color["ENDC"]))
self.red, " " * 30 + "!!! WARNING !!!", self.endc))
self.msg.template(78)
for p, d in zip(package, dependency):
print("| {0}{1}{2} is dependency of the package --> "
"{3}{4}{5}".format(self.meta.color["YELLOW"], d,
self.meta.color["ENDC"],
self.meta.color["GREEN"], p,
self.meta.color["ENDC"]))
print(f"| {self.yellow}{d}{self.endc} is dependency of the package --> "
f"{self.green}{p}{self.endc}")
self.msg.template(78)
self._skip_remove()
@ -393,13 +379,13 @@ class PackageManager:
msg_pkg = "package"
if len(removes) > 1:
msg_pkg = "packages"
print("| Total {0} {1} removed".format(len(removes), msg_pkg))
print(f"| Total {len(removes)} {msg_pkg} removed")
self.msg.template(78)
for pkg in removes:
if not GetFromInstalled(pkg).name():
print("| Package {0} removed".format(pkg))
print(f"| Package {pkg} removed")
else:
print("| Package {0} not found".format(pkg))
print(f"| Package {pkg} not found")
self.msg.template(78)
print() # new line at end
@ -410,8 +396,7 @@ class PackageManager:
pkg_cache, match_cache = "", ""
slack_packages, slack_names = slackware_repository()
print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
self.cyan, ", ".join(self.binary), self.endc))
for pkg in self.binary:
for match in find_package("", self.meta.pkg_path):
pkg_cache = pkg
@ -434,9 +419,7 @@ class PackageManager:
for pkgs in packages:
matching += 1
self._sizes(pkgs)
print("[ {0}installed{1} ] [ {2} ] - {3}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"],
self.file_size, pkgs))
print(f"[ {self.green}installed{self.endc} ] [ {self.file_size} ] - {pkgs}")
if matching == 0:
message = "Can't find"
self.msg.pkg_not_found("", ", ".join(self.binary), message, "\n")
@ -446,10 +429,9 @@ class PackageManager:
print("\nFound summary")
print("=" * 79)
print("{0}Total found {1} matching packages.{2}".format(
self.meta.color["GREY"], matching, self.meta.color["ENDC"]))
self.grey, matching, self.endc))
print("{0}Size of installed packages {1} {2}.{3}\n".format(
self.meta.color["GREY"], round(self.size, 2), self.unit,
self.meta.color["ENDC"]))
self.grey, round(self.size, 2), self.unit, self.endc))
def _sizes(self, package):
"""Package size summary
@ -472,8 +454,7 @@ class PackageManager:
for pkg in self.binary:
name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version()
find = find_package("{0}{1}{2}".format(name, ver, self.meta.sp),
self.meta.pkg_path)
find = find_package(f"{name}{ver}{self.meta.sp}", self.meta.pkg_path)
if find:
package = Utils().read_file(
self.meta.pkg_path + "".join(find))
@ -501,28 +482,16 @@ class PackageManager:
print()
for pkg in sorted(pkg_list):
pkg = self._splitting_packages(pkg, repo, name)
if installed:
if repo == "sbo":
if installed and repo:
if pkg in all_installed_names:
pkg = ("{0}{1}{2}".format(self.meta.color["GREEN"],
pkg,
self.meta.color["ENDC"]))
else:
if pkg in all_installed_names:
pkg = ("{0}{1}{2}".format(self.meta.color["GREEN"],
pkg,
self.meta.color["ENDC"]))
pkg = f"{self.green}{pkg}{self.endc}"
if INDEX:
index += 1
pkg = self.list_color_tag(pkg)
print("{0}{1}:{2} {3}".format(
self.meta.color["GREY"], index,
self.meta.color["ENDC"], pkg))
print(f"{self.grey}{index}:{self.endc} {pkg}")
if index == page:
read = input("\nPress {0}Enter{1} to "
"continue... ".format(
self.meta.color["CYAN"],
self.meta.color["ENDC"]))
read = input(f"\nPress {self.cyan}Enter{self.endc} to continue... ")
if read in ["Q", "q"]:
break
print() # new line after page
@ -567,14 +536,11 @@ class PackageManager:
packages = ""
if repo == "sbo":
if (os.path.isfile(
self.meta.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
repo))):
packages = Utils().read_file(self.meta.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))
self.meta.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")):
packages = Utils().read_file(self.meta.lib_path + f"{repo}_repo/SLACKBUILDS.TXT")
else:
if (os.path.isfile(
self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(
repo))):
self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):
packages = Utils().read_file(self.meta.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
return packages
@ -587,8 +553,7 @@ class PackageManager:
if pkg.endswith(".txz") or pkg.endswith(".tgz"):
find = pkg[:-4]
if find_package(find, self.meta.pkg_path):
pkg = "{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"])
pkg = f"{self.green}{pkg}{self.endc}"
return pkg
def list_of_installed(self, repo, name):

View file

@ -45,11 +45,9 @@ class FindFromRepos:
def find(self, pkg, flag):
"""Start to find packages and print
"""
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
self.cyan, ", ".join(pkg), self.endc))
print(f"\nPackages with name matching [ {self.cyan}{', '.join(pkg)}{self.endc} ]\n")
Msg().template(78)
print("| {0} {1}{2}{3}".format("Repository", "Package", " " * 54,
"Size"))
print(f"| Repository Package {' ' * 54}Size")
Msg().template(78)
for repo in _meta_.repositories:
PACKAGES_TXT = PackageManager(pkg).list_lib(repo)
@ -69,16 +67,12 @@ class FindFromRepos:
self.cache = repo
self.count_pkg += 1
ver = self.sbo_version(repo, find)
print(" {0}{1}{2}{3}{4} {5}{6:>11}".format(
self.cyan, repo, self.endc,
" " * (12 - len(repo)),
find + ver, " " * (53 - len(find + ver)),
size))
print(f" {self.cyan}{repo}{self.endc}{' ' * (12 - len(repo))}{find + ver} "
f"{' ' * (53 -len(find + ver))}{size:>11}")
print("\nFound summary")
print("=" * 79)
print("{0}Total found {1} packages in {2} repositories."
"{3}\n".format(self.grey, self.count_pkg,
self.count_repo, self.endc))
print(f"{self.grey}Total found {self.count_pkg} packages in "
f"{self.count_repo} repositories.{self.endc}\n")
def sbo_version(self, repo, find):
"""

View file

@ -36,6 +36,9 @@ class RepoEnable:
"""
def __init__(self):
self.meta = _meta_
self.red = _meta_.color["RED"]
self.grey = _meta_.color["GREY"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.tag = "[REPOSITORIES]"
self.tag_line = False
@ -101,8 +104,7 @@ Keys: SPACE select or deselect the highlighted repositories,
"""Update repositories.conf file with enabled or disabled
repositories
"""
with open("{0}{1}".format(self.meta.conf_path,
self.repositories_conf), "w") as new_conf:
with open(f"{self.meta.conf_path}{self.repositories_conf}", "w") as new_conf:
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
@ -130,15 +132,12 @@ Keys: SPACE select or deselect the highlighted repositories,
"""
total_enabled = ", ".join(self.selected)
if len(total_enabled) < 1:
total_enabled = ("{0}Are you crazy? This is a package "
"manager for packages :p{1}".format(
self.meta.color["RED"],
self.meta.color["ENDC"]))
total_enabled = (f"{self.red}Are you crazy? This is a package "
f"manager for packages :p{self.endc}")
self.msg.template(78)
print("| Enabled repositories:")
self.msg.template(78)
print("| {0}".format(total_enabled))
print(f"| {total_enabled}")
self.msg.template(78)
print("{0}Total {1}/{2} repositories enabled.{3}\n".format(
self.meta.color["GREY"], len(self.selected),
len(self.enabled + self.disabled), self.meta.color["ENDC"]))
print(f"{self.grey}Total {len(self.selected)}/{len(self.enabled + self.disabled)} "
f"repositories enabled.{self.endc}\n")

View file

@ -35,6 +35,9 @@ class RepoInfo:
"""Repository information
"""
def __init__(self):
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.form = {
"Last updated:": "",
"Number of packages:": "",
@ -55,17 +58,14 @@ class RepoInfo:
"""
View repository information
"""
status = "{0}disabled{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"])
status = f"{self.red}disabled{self.endc}"
self.form["Status:"] = status
self.form["Default:"] = "no"
if repo in self.meta.default_repositories:
self.form["Default:"] = "yes"
if (repo in self.meta.repositories and
os.path.isfile(self.meta.lib_path + "{0}_repo/PACKAGES."
"TXT".format(repo))):
status = "{0}enabled{1}".format(self.meta.color["GREEN"],
self.meta.color["ENDC"])
os.path.isfile(self.meta.lib_path + f"{repo}_repo/PACKAGES.TXT")):
status = f"{self.green}enabled{self.endc}"
if repo != "sbo":
data = self.repository_data(repo)
size = units(data[1], data[2])

View file

@ -68,6 +68,5 @@ class AutoBuild:
raise SystemExit()
for src in self.sources:
if not os.path.isfile(self.path + src):
print("\nslpkg: Error: Source file '{0}' not found\n".format(
src))
print(f"\nslpkg: Error: Source file '{src}' not found\n")
raise SystemExit()

View file

@ -40,11 +40,9 @@ class BuildNumber:
def get(self):
num = "NO_BUILD"
if self.sbo_url:
SlackBuild = URL("{0}{1}.SlackBuild".format(
self.sbo_url, self.pkg)).reading()
SlackBuild = URL(f"{self.sbo_url}{self.pkg}.SlackBuild").reading()
else:
SlackBuild = Utils().read_file("{0}{1}/{2}.SlackBuild".format(
self.meta.build_path, self.pkg, self.pkg))
SlackBuild = Utils().read_file(f"{self.meta.build_path}{self.pkg}/{self.pkg}.SlackBuild")
for line in SlackBuild.splitlines():
line = line.lstrip()
if line.startswith("BUILD="):

View file

@ -47,8 +47,8 @@ def sbo_upgrade(skip, flag):
name = split_package(pkg)[0]
ver = split_package(pkg)[1]
if (name in data and name not in skip and name not in blacklist):
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
package = ("{0}-{1}".format(name, ver))
sbo_package = f"{name}-{SBoGrep(name).version()}"
package = f"{name}-{ver}"
if parse_version(sbo_package) > parse_version(package):
upgrade_names.append(name)
Msg().done()

View file

@ -36,11 +36,11 @@ class SBoGrep:
self.line_name = "SLACKBUILD NAME: "
self.line_files = "SLACKBUILD FILES: "
self.line_down = "SLACKBUILD DOWNLOAD: "
self.line_down_64 = "SLACKBUILD DOWNLOAD_{0}: ".format(arch64)
self.line_down_64 = f"SLACKBUILD DOWNLOAD_{arch64}: "
self.line_req = "SLACKBUILD REQUIRES: "
self.line_ver = "SLACKBUILD VERSION: "
self.line_md5 = "SLACKBUILD MD5SUM: "
self.line_md5_64 = "SLACKBUILD MD5SUM_{0}: ".format(arch64)
self.line_md5_64 = f"SLACKBUILD MD5SUM_{arch64}: "
self.line_des = "SLACKBUILD SHORT DESCRIPTION: "
self.sbo_txt = self.meta.lib_path + "sbo_repo/SLACKBUILDS.TXT"
self.answer = ["y", "Y"]

View file

@ -94,7 +94,7 @@ class SBoNetwork:
from slackbuilds.org
"""
if self.sbo_url and self.name not in self.blacklist:
self.prgnam = ("{0}-{1}".format(self.name, self.sbo_version))
self.prgnam = f"{self.name}-{self.sbo_version}"
self.view_sbo()
while True:
self.read_choice()
@ -147,10 +147,10 @@ class SBoNetwork:
commands = {
"r": "README",
"R": "README",
"s": "{0}.SlackBuild".format(self.name),
"S": "{0}.SlackBuild".format(self.name),
"f": "{0}.info".format(self.name),
"F": "{0}.info".format(self.name),
"s": f"{self.name}.SlackBuild",
"S": f"{self.name}.SlackBuild",
"f": f"{self.name}.info",
"F": f"{self.name}.info",
"o": "doinst.sh",
"O": "doinst.sh",
"d": "download",
@ -171,8 +171,7 @@ class SBoNetwork:
}
try:
message = " Choose an option > "
self.choice = input("{0}{1}{2}".format(self.grey, message,
self.endc))
self.choice = input(f"{self.grey}{message}{self.endc}")
except EOFError:
print()
raise SystemExit()
@ -263,49 +262,27 @@ class SBoNetwork:
fix_sp = ""
print() # new line at start
self.msg.template(78)
print("| {0}{1}SlackBuilds Repository{2}".format(" " * 28, self.grey,
self.endc))
print(f"| {' ' * 28}{self.grey}SlackBuilds Repository{self.endc}")
self.msg.template(78)
print("| {0} > {1} > {2}{3}{4}".format(slack_ver(),
sbo_url.split("/")[-3].title(),
self.cyan, self.name,
self.endc))
print(f"| {slack_ver()} > {sbo_url.split('/')[-3].title()} > {self.cyan}{self.name}{self.endc}")
self.msg.template(78)
print("| {0}Package url{1}: {2}".format(self.green, self.endc,
sbo_url))
print(f"| {self.green}Package url{self.endc}: {sbo_url}")
self.msg.template(78)
print("| {0}Description: {1}{2}".format(self.green,
self.endc, self.sbo_desc))
print("| {0}SlackBuild: {1}{2}".format(self.green, self.endc,
self.sbo_dwn.split("/")[-1]))
print("| {0}Sources: {1}{2}".format(
self.green, self.endc,
(", ".join([src.split("/")[-1] for src in self.source_dwn]))))
print("| {0}Requirements: {1}{2}".format(self.yellow,
self.endc,
", ".join(self.sbo_req)))
print(f"| {self.green}Description: {self.endc}{self.sbo_desc}")
print(f"| {self.green}SlackBuild: {self.endc}{self.sbo_dwn.split('/')[-1]}")
print(f"| {self.green}Sources: {self.endc}{', '.join([src.split('/')[-1] for src in self.source_dwn])}")
print(f"| {self.yellow}Requirements: {self.endc}{', '.join(self.sbo_req)}")
self.msg.template(78)
print("| {0}R{1}{2}EADME View the README file".format(
self.red, self.endc, br2))
print("| {0}S{1}{2}lackBuild View the .SlackBuild "
"file".format(self.red, self.endc, br2))
print("| In{0}{1}f{2}{3}o{4} View the .info "
"file".format(br1, self.red, self.endc, br2, fix_sp))
print(f"| {self.red}R{self.endc}{br2}EADME View the README file")
print(f"| {self.red}S{self.endc}{br2}lackBuild View the .SlackBuild file")
print(f"| In{br1}{self.red}f{self.endc}{br2}o{fix_sp} View the .info file")
if "doinst.sh" in self.sbo_files.split():
print("| D{0}{1}o{2}{3}inst.sh{4} View the doinst.sh "
"file".format(br1, self.red, self.endc, br2, fix_sp))
print("| {0}D{1}{2}ownload Download this package".format(
self.red, self.endc, br2))
print("| {0}B{1}{2}uild Download and build".format(
self.red, self.endc, br2))
print("| {0}I{1}{2}nstall Download/Build/Install".format(
self.red, self.endc, br2))
print("| {0}C{1}{2}lear Clear screen".format(self.red,
self.endc,
br2))
print("| {0}Q{1}{2}uit Quit".format(self.red,
self.endc, br2))
print(f"| D{br1}{self.red}o{self.endc}{br2}inst.sh{fix_sp} View the doinst.sh file")
print(f"| {self.red}D{self.endc}{br2}ownload Download this package")
print(f"| {self.red}B{self.endc}{br2}uild Download and build")
print(f"| {self.red}I{self.endc}{br2}nstall Download/Build/Install")
print(f"| {self.red}C{self.endc}{br2}lear Clear screen")
print(f"| {self.red}Q{self.endc}{br2}uit Quit")
self.msg.template(78)
def with_checklist(self):
@ -321,7 +298,7 @@ class SBoNetwork:
if data:
text = "Press 'spacebar' to choose SlackBuild for view"
title = " SlackBuilds.org "
backtitle = "{0} {1}".format(_meta_.__all__, _meta_.__version__)
backtitle = f"{_meta_.__all__} {_meta_.__version__}"
status = False
pkg = DialogUtil(data, text, title, backtitle, status).checklist()
if pkg and len(pkg) > 1:
@ -367,8 +344,7 @@ class SBoNetwork:
if self.FAULT:
print()
self.msg.template(78)
print("| Package {0} {1} {2} {3}".format(self.prgnam, self.red,
self.FAULT, self.endc))
print(f"| Package {self.prgnam} {self.red} {self.FAULT} {self.endc}")
self.msg.template(78)
else:
sources = []
@ -391,6 +367,5 @@ class SBoNetwork:
"""Install SBo package found in /tmp directory.
"""
binary = slack_package(self.prgnam)
print("[ {0}Installing{1} ] --> {2}".format(self.green, self.endc,
self.name))
print(f"[ {self.green}Installing{self.endc} ] --> {self.name}")
PackageManager(binary).upgrade(flag="--install-new")

View file

@ -50,6 +50,9 @@ class QueuePkgs:
"#\n"
]
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.quit = False
self.queue = self.meta.lib_path + "queue/"
self.queue_list = self.queue + "queue_list"
@ -82,8 +85,7 @@ class QueuePkgs:
print("\nPackages in the queue:\n")
for pkg in self.packages():
if pkg:
print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"]))
print(f"{self.green}{pkg}{self.endc}")
self.quit = True
if self.quit:
print() # new line at exit
@ -98,13 +100,11 @@ class QueuePkgs:
for pkg in pkgs:
find = sbo_search_pkg(pkg)
if pkg not in queue_list and find is not None:
print("{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
self.meta.color["ENDC"]))
print(f"{self.green}{pkg}{self.endc}")
queue.write(pkg + "\n")
self.quit = True
else:
print("{0}{1}{2}".format(self.meta.color["RED"], pkg,
self.meta.color["ENDC"]))
print(f"{self.red}{pkg}{self.endc}")
self.quit = True
queue.close()
if self.quit:
@ -119,8 +119,7 @@ class QueuePkgs:
if line not in pkgs:
queue.write(line + "\n")
else:
print("{0}{1}{2}".format(self.meta.color["RED"], line,
self.meta.color["ENDC"]))
print(f"{self.red}{line}{self.endc}")
self.quit = True
queue.close()
if self.quit:
@ -161,13 +160,13 @@ class QueuePkgs:
print() # new line at start
for pkg in packages:
ver = SBoGrep(pkg).version()
prgnam = "{0}-{1}".format(pkg, ver)
prgnam = f"{pkg}-{ver}"
if find_package(prgnam, self.meta.output):
binary = slack_package(prgnam)
PackageManager(binary).upgrade(flag="--install-new")
else:
print("\nPackage {0} not found in the {1} for "
"installation\n".format(prgnam, self.meta.output))
print(f"\nPackage {prgnam} not found in the {self.meta.output} for "
f"installation\n")
else:
print("\nPackages not found in the queue for installation\n")
raise SystemExit(1)

View file

@ -34,7 +34,7 @@ def sbo_search_pkg(name):
return url
"""
repo = Repo().default_repository()["sbo"]
sbo_url = "{0}{1}/".format(repo, slack_ver())
sbo_url = f"{repo}{slack_ver()}/"
SLACKBUILDS_TXT = Utils().read_file(
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT")
for line in SLACKBUILDS_TXT.splitlines():

View file

@ -57,6 +57,10 @@ class SBoInstall:
pkg_security(self.slackbuilds)
self.flag = flag
self.meta = _meta_
self.green = _meta_.color["GREEN"]
self.yellow = _meta_.color["YELLOW"]
self.grey = _meta_.color["GREY"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.arch = SBoArch().get()
self.build_folder = self.meta.build_path
@ -145,19 +149,15 @@ class SBoInstall:
if self.match and [""] != self.slackbuilds:
print("\nMatching summary")
print("=" * 79)
print("Total {0} matching packages\n".format(count_total))
print(f"Total {count_total} matching packages\n")
raise SystemExit(1)
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2}.".format(
self.meta.color["GREY"], count_total,
self.msg.pkg(count_total)))
print("{0} {1} will be installed, {2} already installed and "
"{3} {4}".format(self.count_uni,
self.msg.pkg(self.count_uni),
self.count_ins, self.count_upg,
self.msg.pkg(self.count_upg)))
print("will be upgraded.{0}\n".format(self.meta.color["ENDC"]))
print(f"{self.grey}Total {count_total} {self.msg.pkg(count_total)}.")
print(f"{self.count_uni} {self.msg.pkg(self.count_uni)} will be installed, "
f"{self.count_ins} already installed and "
f"{self.count_upg} {self.msg.pkg(self.count_upg)}")
print(f"will be upgraded.{self.endc}\n")
self.continue_to_install()
else:
self.msg.not_found(self.is_upgrade)
@ -178,9 +178,10 @@ class SBoInstall:
def update_deps(self):
"""Update dependencies dictionary with all package
"""
utils = Utils()
onelist, dependencies = [], []
onelist = Utils().dimensional_list(self.deps)
dependencies = Utils().remove_dbs(onelist)
onelist = utils.dimensional_list(self.deps)
dependencies = utils.remove_dbs(onelist)
for dep in dependencies:
deps = Requires(self.flag).sbo(dep)
self.deps_dict[dep] = self.one_for_all(deps)
@ -227,7 +228,7 @@ class SBoInstall:
sbo_versions, sources = [], []
for sbo in slackbuilds:
status(0.02)
sbo_ver = "{0}-{1}".format(sbo, SBoGrep(sbo).version())
sbo_ver = f"{sbo}-{SBoGrep(sbo).version()}"
sbo_versions.append(sbo_ver)
sources.append(SBoGrep(sbo).source())
return [sbo_versions, sources]
@ -250,13 +251,12 @@ class SBoInstall:
"""View top template
"""
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"New version", " " * 8,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
"Size"))
print(f"| Packages{' ' * 16}"
f"New version{' ' * 8}"
f"Arch{' ' * 4}"
f"Build{' ' * 2}"
f"Repos{' ' * 10}"
f"Size")
self.msg.template(78)
def view_packages(self, *args):
@ -267,12 +267,11 @@ class SBoInstall:
args[3] arch
"""
ver = GetFromInstalled(args[1]).version()
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
args[0], args[1] + ver, self.meta.color["ENDC"],
" " * (23-len(args[1] + ver)), args[2],
" " * (18-len(args[2])), args[3],
" " * (15-len(args[3])), "",
"", "SBo", "", "").rstrip())
print(f" {args[0]}{args[1] + ver}{self.endc}"
f"{' ' * (24-len(args[1] + ver))}{args[2]}"
f"{' ' * (18-len(args[2]))} {args[3]}"
f"{' ' * (15-len(args[3]))}{''}"
f"{''}SBo{''}{'':>11}{''}")
def tag(self, sbo):
"""Tag with color green if package already installed,
@ -337,9 +336,7 @@ class SBoInstall:
self.msg.template(78)
elif self.unst[0] in src_link or self.unst[1] in src_link:
self.msg.template(78)
print("| Package {0} {1}{2}{3}".format(
prgnam, self.meta.color["RED"], "".join(src_link),
self.meta.color["ENDC"]))
print(f"| Package {prgnam} {self.red}{''.join(src_link)}{self.endc}")
self.msg.template(78)
else:
sbo_url = sbo_search_pkg(pkg)
@ -358,14 +355,10 @@ class SBoInstall:
binary = slack_package(prgnam)
if os.path.isfile("".join(binary)):
if GetFromInstalled(pkg).name() == pkg:
print("[ {0}Upgrading{1} ] --> {2}".format(
self.meta.color["YELLOW"],
self.meta.color["ENDC"], prgnam))
print(f"[ {self.yellow}Upgrading{self.endc} ] --> {prgnam}")
upgraded.append(prgnam)
else:
print("[ {0}Installing{1} ] --> {2}".format(
self.meta.color["GREEN"],
self.meta.color["ENDC"], prgnam))
print(f"[ {self.green}Installing{self.endc} ] --> {prgnam}")
installs.append(prgnam)
if ("--rebuild" in self.flag and
GetFromInstalled(pkg).name() == pkg):
@ -384,8 +377,8 @@ class SBoInstall:
ins_ver = "0"
if parse_version(sbo_ver) < parse_version(ins_ver):
self.msg.template(78)
print("| Package {0} don't downgrade, "
"setting by user".format(name))
print(f"| Package {name} don't downgrade, "
f"setting by user")
self.msg.template(78)
return True
@ -393,9 +386,8 @@ class SBoInstall:
"""Alternative repository for sbo sources"""
sources = []
name = "-".join(prgnam.split("-")[:-1])
category = "{0}/{1}/".format(sbo_link.split("/")[-2], name)
category = f"{sbo_link.split('/')[-2]}/{name}/"
for link in src_link:
source = link.split("/")[-1]
sources.append("{0}{1}{2}".format(self.meta.sbosrcarch_link,
category, source))
sources.append(f"{self.meta.sbosrcarch_link}{category}{source}")
return sources

View file

@ -25,6 +25,7 @@
def units(comp_sum, uncomp_sum):
"""Calculate package size
"""
print(comp_sum, uncomp_sum)
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
comp_unit = uncomp_unit = "Mb"
@ -40,4 +41,5 @@ def units(comp_sum, uncomp_sum):
if uncompressed < 1:
uncompressed = sum(map(int, uncomp_sum))
uncomp_unit = "Kb"
print(comp_unit, uncomp_unit, compressed, uncompressed)
return [comp_unit, uncomp_unit], [compressed, uncompressed]

View file

@ -38,17 +38,17 @@ def mirrors(name, location):
repo = Repo().slack()
if _meta_.arch == "x86_64":
if rel == "stable":
http = repo + "slackware64-{0}/{1}{2}".format(ver, location, name)
http = f"{repo}slackware64-{ver}/{location}{name}"
else:
http = repo + "slackware64-{0}/{1}{2}".format(rel, location, name)
http = f"{repo}slackware64-{rel}/{location}{name}"
elif _meta_.arch.startswith("arm"):
if rel == "stable":
http = repo + "slackwarearm-{0}/{1}{2}".format(ver, location, name)
http = f"{repo}slackwarearm-{ver}/{location}{name}"
else:
http = repo + "slackwarearm-{0}/{1}{2}".format(rel, location, name)
http = f"{repo}slackwarearm-{rel}/{location}{name}"
else:
if rel == "stable":
http = repo + "slackware-{0}/{1}{2}".format(ver, location, name)
http = f"{repo}slackware-{ver}/{location}{name}"
else:
http = repo + "slackware-{0}/{1}{2}".format(rel, location, name)
http = f"{repo}slackware-{rel}/{location}{name}"
return http

View file

@ -58,6 +58,11 @@ class Patches:
self.skip = skip
self.flag = flag
self.meta = _meta_
self.grey = _meta_.color["GREY"]
self.yellow = _meta_.color["YELLOW"]
self.green = _meta_.color["GREEN"]
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.msg = Msg()
self.version = self.meta.slack_rel
self.patch_path = self.meta.slpkg_tmp_patches
@ -89,29 +94,20 @@ class Patches:
self.dialog_checklist()
print("\nThese packages need upgrading:\n")
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"New Version", " " * 8,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
"Size"))
print(f"| Package{' ' * 17}New Version{' ' * 8}Arch"
f"{' ' * 4}Build{' ' * 2}Repo{' ' * 11}Size")
self.msg.template(78)
print("Upgrading:")
self.views()
unit, size = units(self.comp_sum, self.uncomp_sum)
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2} will be upgraded and {3} will be "
"installed.".format(self.meta.color["GREY"],
self.count_upg,
self.msg.pkg(len(self.upgrade_all)),
self.count_added))
print("Need to get {0} {1} of archives.".format(size[0],
unit[0]))
print("After this process, {0} {1} of additional disk space "
"will be used.{2}".format(size[1], unit[1],
self.meta.color["ENDC"]))
print(f"{self.grey}Total {self.count_upg}"
f"{self.msg.pkg(len(self.upgrade_all))} will be upgraded and"
f" {self.count_added} will be installed.")
print(f"Need to get {size[0]} {unit[0]} of archives.")
print(f"After this process, {size[1]} {unit[1]} of additional disk space "
f"will be used.{self.endc}")
print()
if self.msg.answer() in ["y", "Y"]:
Download(self.patch_path, self.dwn_links,
@ -132,8 +128,8 @@ class Patches:
slack_arch = ""
if self.meta.arch == "x86_64":
slack_arch = "64"
print("\nSlackware{0} '{1}' v{2} distribution is up to "
"date!\n".format(slack_arch, self.version, slack_ver()))
print(f"\nSlackware{slack_arch} '{self.version}' v{slack_ver()}"
f"distribution is up to date!\n")
def store(self):
"""
@ -147,8 +143,7 @@ class Patches:
if (not os.path.isfile(self.meta.pkg_path + name[:-4]) and
repo_pkg_name not in black and
repo_pkg_name not in self.skip):
self.dwn_links.append("{0}{1}/{2}".format(mirrors("", ""),
loc, name))
self.dwn_links.append(f"{mirrors('', '')}{loc}/{name}")
self.comp_sum.append(comp)
self.uncomp_sum.append(uncomp)
self.upgrade_all.append(name)
@ -167,8 +162,7 @@ class Patches:
data.append(upg[:-4])
text = "Press 'spacebar' to unchoose packages from upgrade"
title = " Upgrade "
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
backtitle = f"{self.meta.__all__} {self.meta.__version__}"
status = True
pkgs = DialogUtil(data, text, title, backtitle,
status).checklist()
@ -198,13 +192,11 @@ class Patches:
if pkg_repo[0] == pkg_inst:
color = self.meta.color["YELLOW"]
ver = GetFromInstalled(pkg_repo[0]).version()
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format(
color, pkg_repo[0] + ver, self.meta.color["ENDC"],
" " * (23-len(pkg_repo[0] + ver)), pkg_repo[1],
" " * (18-len(pkg_repo[1])), pkg_repo[2],
" " * (8-len(pkg_repo[2])), pkg_repo[3],
" " * (7-len(pkg_repo[3])), "Slack",
size, " K").rstrip())
print(f" {color}{pkg_repo[0] + ver}{self.endc}"
f"{' ' * (23-len(pkg_repo[0] + ver))} {pkg_repo[1]}"
f"{' ' * (18-len(pkg_repo[1]))} {pkg_repo[2]}"
f"{' ' * (8-len(pkg_repo[2]))}{pkg_repo[3]}"
f"{' ' * (7-len(pkg_repo[3]))}Slack{size:>12} K")
def upgrade(self):
"""
@ -213,20 +205,15 @@ class Patches:
for pkg in self.upgrade_all:
check_md5(pkg_checksum(pkg, "slack_patches"),
self.patch_path + pkg)
pkg_ver = "{0}-{1}".format(split_package(pkg)[0],
split_package(pkg)[1])
pkg_ver = f"{split_package(pkg)[0]}-{split_package(pkg)[1]}"
if find_package(split_package(pkg)[0] + self.meta.sp,
self.meta.pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format(
self.meta.color["YELLOW"], self.meta.color["ENDC"],
pkg[:-4]))
print(f"[ {self.yellow}upgrading{self.endc} ] --> {pkg[:-4]}")
PackageManager((self.patch_path + pkg).split()).upgrade(
"--install-new")
self.upgraded.append(pkg_ver)
else:
print("[ {0}installing{1} ] --> {2}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"],
pkg[:-4]))
print(f"[ {self.green}installing{self.endc} ] --> {pkg[:-4]}")
PackageManager((self.patch_path + pkg).split()).upgrade(
"--install-new")
self.installed.append(pkg_ver)
@ -243,9 +230,8 @@ class Patches:
else:
print()
self.msg.template(78)
print("| {0}*** HIGHLY recommended reinstall boot loader "
"***{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"]))
print(f"| {self.red}*** HIGHLY recommended reinstall "
f"boot loader ***{self.endc}")
print("| L=lilo / E=elilo / G=grub")
self.msg.template(78)
try:
@ -269,8 +255,6 @@ class Patches:
"""This replace slackpkg ChangeLog.txt file with new
from Slackware official mirrors after update distribution.
"""
print(mirrors("ChangeLog.txt", ""))
NEW_ChangeLog_txt = URL(mirrors("ChangeLog.txt", "")).reading()
if os.path.isfile(self.meta.slackpkg_lib_path + "ChangeLog.txt.old"):
os.remove(self.meta.slackpkg_lib_path + "ChangeLog.txt.old")
@ -285,8 +269,7 @@ class Patches:
"""Update packages list and ChangeLog.txt file after
upgrade distribution
"""
print("{0}Update the package lists ?{1}".format(
self.meta.color["GREEN"], self.meta.color["ENDC"]))
print(f"{self.green}Update the package lists ?{self.endc}")
print("=" * 79)
if self.msg.answer() in ["y", "Y"]:
Update().repository(["slack"])

View file

@ -34,7 +34,6 @@ def status(sec):
if _meta_.prg_bar in ["on", "ON"]:
syms = ["|", "/", "-", "\\"]
for sym in syms:
print("\b{0}{1}{2}".format(_meta_.color["GREY"], sym,
_meta_.color["ENDC"]), end="")
print(f"\b{_meta_.color['GREY']}{sym}{_meta_.color['ENDC']}", end="")
print(end="", flush=True)
time.sleep(float(sec))

View file

@ -81,20 +81,16 @@ class TrackingDeps:
pkg_len = len(self.name) + 24
print() # new line at start
self.msg.template(pkg_len)
print("| Package {0}{1}{2} dependencies :".format(
self.cyan, self.name, self.endc))
print(f"| Package {self.cyan}{self.name}{self.endc} dependencies :")
self.msg.template(pkg_len)
print("\\")
print(" +---{0}[ Tree of dependencies ]{1}".format(self.yellow,
self.endc))
print(f" +---{self.yellow}[ Tree of dependencies ]{self.endc}")
index = 0
for pkg in self.dependencies:
if "--check-deps" in self.flag:
used = self.check_used(pkg)
self.deps_used(pkg, used)
used = "{0} {1}{2}{3}".format(
"is dependence on -->", self.cyan,
", ".join(used), self.endc)
used = f"is dependence on --> {self.cyan}{', '.join(used)}{self.endc}"
else:
used = ""
index += 1
@ -103,14 +99,10 @@ class TrackingDeps:
if self.meta.use_colors in ["off", "OFF"]:
installed = "* "
print(" |")
print(" {0}{1}: {2}{3}{4} {5}{6}".format(
"+--", index, self.green, pkg,
self.endc, installed, used))
print(f" +--{index}: {self.green}{pkg}{self.endc} {installed}{used}")
else:
print(" |")
print(" {0}{1}: {2}{3}{4} {5}".format(
"+--", index, self.red, pkg,
self.endc, installed))
print(f" +--{index}: {self.red}{pkg}{self.endc} {installed}")
if self.meta.use_colors in ["off", "OFF"]:
print("\n * = Installed\n")
else:
@ -132,7 +124,7 @@ class TrackingDeps:
self.dependencies_list = Requires(self.flag).sbo(self.name)
else:
PACKAGES_TXT = Utils().read_file(
self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo))
self.meta.lib_path + f"{self.repo}_repo/PACKAGES.TXT")
self.names = Utils().package_name(PACKAGES_TXT)
self.bin_case_insensitive()
self.find_pkg = search_pkg(self.name, self.repo)

View file

@ -31,19 +31,19 @@ from slpkg.pkg.installed import GetFromInstalled
def choose_upg(packages):
"""Create checklist to choose packages for upgrade
"""Creating checklist to choose packages for upgrade
"""
selected_packages, data = [], []
if packages:
for pkg in packages:
name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version()
binary = "{0}{1}".format(name, ver)
binary = f"{name}{ver}"
installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
data.append(installed)
text = "Press 'spacebar' to unchoose packages from upgrade"
title = " Upgrade "
backtitle = "{0} {1}".format(_meta_.__all__, _meta_.__version__)
backtitle = f"{_meta_.__all__} {_meta_.__version__}"
status = True
pkgs = DialogUtil(data, text, title, backtitle,
status).checklist()

View file

@ -33,6 +33,8 @@ class URL:
def __init__(self, link):
self.link = link
self.meta = _meta_
self.red = _meta_.color["RED"]
self.endc = _meta_.color["ENDC"]
self.http = urllib3.PoolManager()
def reading(self):
@ -42,7 +44,5 @@ class URL:
f = self.http.request('GET', self.link)
return f.data.decode("utf-8", "ignore")
except urllib3.exceptions.NewConnectionError:
print("\n{0}Can't read the file '{1}'{2}".format(
self.meta.color["RED"], self.link.split("/")[-1],
self.meta.color["ENDC"]))
print(f"\n{self.red}Can't read the file '{self.link.split('/')[-1]}'{self.endc}")
return " "

View file

@ -23,6 +23,7 @@
import os
from collections import OrderedDict
from slpkg.splitting import split_package
@ -50,18 +51,16 @@ class Utils:
def remove_dbs(self, double):
"""Remove double item from list
"""
one = []
for dup in double:
if dup not in one:
one.append(dup)
return one
return list(OrderedDict.fromkeys(double))
def read_file(self, registry):
"""Returns reading file
"""
with open(registry, "r") as file_txt:
code = self.check_encoding('', registry)
if not code:
code = "utf-8"
with open(registry, "r", encoding=code) as file_txt:
read_file = file_txt.read()
file_txt.close()
return read_file
def package_name(self, PACKAGES_TXT):
@ -102,8 +101,7 @@ class Utils:
else:
return file_name
@staticmethod
def check_encoding(path, f):
def check_encoding(self, path, f):
"""Checking the file encoding default is utf-8
"""
try:

11
tests/test_md5sum.py Normal file
View file

@ -0,0 +1,11 @@
from slpkg.md5sum import md5
def test_md5_superuser():
result = md5('slpkg/superuser.py')
assert result == "e6cebdf37fbc1b8e9d3c5e3e53b300c1"
def test_md5_security():
result = md5('slpkg/security.py')
assert result == "d395d2fcf1c7b1a91ef6ce3dc8eb047b"

5
tests/test_units.py Normal file
View file

@ -0,0 +1,5 @@
from slpkg.sizes import units
def test_units():
assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']])

17
tests/test_utils.py Normal file
View file

@ -0,0 +1,17 @@
from slpkg.utils import Utils
def test_units():
assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']])
def test_dimensional_list():
lists = [[1, 2, 3, 4, 5]]
utils = Utils()
assert [1, 2, 3, 4, 5] == utils.dimensional_list(lists)
def test_remove_dbs():
lists = [1, 2, 3, 3, 4, 5, 2, 1]
utils = Utils()
assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)