mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Added checklist option
This commit is contained in:
parent
68a40299a2
commit
03f6b6d6f5
8 changed files with 80 additions and 41 deletions
11
README.rst
11
README.rst
|
@ -430,7 +430,7 @@ Command Line Tool Usage
|
||||||
options=[--dry-run, --install-new, binary packages from an older
|
options=[--dry-run, --install-new, binary packages from an older
|
||||||
--reinstall, --verbose] version to a newer one.
|
--reinstall, --verbose] version to a newer one.
|
||||||
-r, --removepkg, [options] [package...], Removes a previously installed
|
-r, --removepkg, [options] [package...], Removes a previously installed
|
||||||
--check-deps, --tag Slackware binary packages,
|
--check-deps, --tag, --checklist Slackware binary packages,
|
||||||
options=[-warn, -preserve, -copy, while writing a progress report
|
options=[-warn, -preserve, -copy, while writing a progress report
|
||||||
-keep] to the standard output.
|
-keep] to the standard output.
|
||||||
-d, --display, [package...] Display the installed packages
|
-d, --display, [package...] Display the installed packages
|
||||||
|
@ -1391,6 +1391,15 @@ Remove packages with by TAG:
|
||||||
|
|
||||||
Are you sure to remove 14 packages [y/N]?
|
Are you sure to remove 14 packages [y/N]?
|
||||||
|
|
||||||
|
Remove packages using dialog utility:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ slpkg -r _SBo --tag --checklist
|
||||||
|
|
||||||
|
.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/pythondialog.png
|
||||||
|
:target: https://github.com/dslackw/slpkg
|
||||||
|
|
||||||
|
|
||||||
Build and install packages that have added to the queue:
|
Build and install packages that have added to the queue:
|
||||||
|
|
||||||
|
|
12
man/slpkg.8
12
man/slpkg.8
|
@ -35,7 +35,7 @@ Usage: slpkg Commands:
|
||||||
[-q [build, install, build-install]]
|
[-q [build, install, build-install]]
|
||||||
[-g [print, edit=[editor]]]
|
[-g [print, edit=[editor]]]
|
||||||
[-l [repository], --index, --installed]
|
[-l [repository], --index, --installed]
|
||||||
[-c [repository], --upgrade, --skip=[...] --resolve-off]
|
[-c [repository], --upgrade, --skip=[...], --resolve-off]
|
||||||
[-s [repository] [package...], --resolve-off]
|
[-s [repository] [package...], --resolve-off]
|
||||||
[-t [repository] [package], --check-deps, --graph=[type]]
|
[-t [repository] [package], --check-deps, --graph=[type]]
|
||||||
[-p [repository] [package], --color=[]]
|
[-p [repository] [package], --color=[]]
|
||||||
|
@ -44,7 +44,7 @@ Usage: slpkg Commands:
|
||||||
[-f [package...]]
|
[-f [package...]]
|
||||||
[-i [options] [package...]]
|
[-i [options] [package...]]
|
||||||
[-u [options] [package...]]
|
[-u [options] [package...]]
|
||||||
[-r [options] [package...], --check-deps]
|
[-r [options] [package...], --check-deps, --tag, --checklist]
|
||||||
[-d [package...]]
|
[-d [package...]]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
@ -127,7 +127,7 @@ with the option "slpkg -s <repository> <packages>".
|
||||||
.PP
|
.PP
|
||||||
Additional options:
|
Additional options:
|
||||||
.PP
|
.PP
|
||||||
\fB--graph=[type]\fP : Drawing dependencies diagram. (example for type: ascii, image.x11, image.png etc.)
|
\fB--graph=[type]\fP : Drawing dependencies diagram. (example for type: ascii, image.x11, image.png etc. Require pygraphviz)
|
||||||
.PP
|
.PP
|
||||||
\fB--tree\fP : Switch to tree view.
|
\fB--tree\fP : Switch to tree view.
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ Additional options:
|
||||||
.PP
|
.PP
|
||||||
\fB--check-deps\fP : Check if installed packages used by other packages.
|
\fB--check-deps\fP : Check if installed packages used by other packages.
|
||||||
.PP
|
.PP
|
||||||
\fB--graph=[type]\fP : Drawing dependencies graph. (example for type: ascii, image.x11, image.png etc.)
|
\fB--graph=[type]\fP : Drawing dependencies graph. (example for type: ascii, image.x11, image.png etc. Require pygraphviz)
|
||||||
|
|
||||||
.SS -p, --desk, print packages description
|
.SS -p, --desk, print packages description
|
||||||
\fBslpkg\fP \fB-p\fP <\fIrepository\fP> <\fIname of package\fP>, \fB--color=[]\fP
|
\fBslpkg\fP \fB-p\fP <\fIrepository\fP> <\fIname of package\fP>, \fB--color=[]\fP
|
||||||
|
@ -264,7 +264,7 @@ and will skip any packages that do not already have a version installed.
|
||||||
More information please read "man upgradepkg".
|
More information please read "man upgradepkg".
|
||||||
|
|
||||||
.SS -r, --removepkg, remove previously installed Slackware binary packages
|
.SS -r, --removepkg, remove previously installed Slackware binary packages
|
||||||
\fBslpkg\fP \fB-r\fP \fB[-copy, -keep, -preserve, -warn]\fP <\fInames of packages\fP>, \fB--check-deps\fP, \fB--tag\fP
|
\fBslpkg\fP \fB-r\fP \fB[-copy, -keep, -preserve, -warn]\fP <\fInames of packages\fP>, \fB--check-deps\fP, \fB--tag\fP, \fB--checklist\fP
|
||||||
.PP
|
.PP
|
||||||
Removes a previously installed Slackware package, while writing a progress report to
|
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
|
the standard output. A package may be specified either by the full package name (as
|
||||||
|
@ -278,6 +278,8 @@ Additional options:
|
||||||
\fB--check-deps\fP : Check if installed packages used by other packages.
|
\fB--check-deps\fP : Check if installed packages used by other packages.
|
||||||
.pp
|
.pp
|
||||||
\fB--tag\fP : Remove packages with by TAG.
|
\fB--tag\fP : Remove packages with by TAG.
|
||||||
|
.PP
|
||||||
|
\fB--checklist\fP : Remove packages using dialog utility. (Require python2-pythondialog)
|
||||||
|
|
||||||
.SS -d, --display, display the installed packages contents and file list
|
.SS -d, --display, display the installed packages contents and file list
|
||||||
\fBslpkg\fP \fB-d\fP <\fInames of packages\fP>
|
\fBslpkg\fP \fB-d\fP <\fInames of packages\fP>
|
||||||
|
|
|
@ -18,3 +18,6 @@
|
||||||
# [OPTIONAL]
|
# [OPTIONAL]
|
||||||
# perl 5
|
# perl 5
|
||||||
# graph-easy >= 0.75 (drawing dependencies ascii diagram)
|
# graph-easy >= 0.75 (drawing dependencies ascii diagram)
|
||||||
|
#
|
||||||
|
# [OPTIONAL]
|
||||||
|
# python2-pythondialog >= 3.3.0 (Python interface to the UNIX dialog utility)
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -39,6 +39,7 @@ DOCS_REQUIREMENTS = []
|
||||||
TESTS_REQUIREMENTS = []
|
TESTS_REQUIREMENTS = []
|
||||||
OPTIONAL_REQUIREMENTS = [
|
OPTIONAL_REQUIREMENTS = [
|
||||||
"pygraphviz >= 1.3rc2",
|
"pygraphviz >= 1.3rc2",
|
||||||
|
"python2-pythondialog >= 3.3.0"
|
||||||
]
|
]
|
||||||
# Non-Python/non-PyPI optional dependencies:
|
# Non-Python/non-PyPI optional dependencies:
|
||||||
# ascii diagram: graph-easy (available from SBo repository)
|
# ascii diagram: graph-easy (available from SBo repository)
|
||||||
|
|
|
@ -87,7 +87,7 @@ Optional arguments:
|
||||||
only packages installed on the
|
only packages installed on the
|
||||||
system.
|
system.
|
||||||
-c, --check, [repository], --upgrade, Check, view and install updated
|
-c, --check, [repository], --upgrade, Check, view and install updated
|
||||||
--skip=[...] --resolve--off packages from repositories.
|
--skip=[...], --resolve--off packages from repositories.
|
||||||
-s, --sync, [repository] [package...], Sync packages. Install packages
|
-s, --sync, [repository] [package...], Sync packages. Install packages
|
||||||
--resolve-off directly from remote repositories
|
--resolve-off directly from remote repositories
|
||||||
with all dependencies.
|
with all dependencies.
|
||||||
|
@ -117,7 +117,7 @@ Optional arguments:
|
||||||
options=[--dry-run, --install-new, binary packages from an older
|
options=[--dry-run, --install-new, binary packages from an older
|
||||||
--reinstall, --verbose] version to a newer one.
|
--reinstall, --verbose] version to a newer one.
|
||||||
-r, --removepkg, [options] [package...], Removes a previously installed
|
-r, --removepkg, [options] [package...], Removes a previously installed
|
||||||
--check-deps, --tag Slackware binary packages,
|
--check-deps, --tag, --checklist Slackware binary packages,
|
||||||
options=[-warn, -preserve, -copy, while writing a progress report
|
options=[-warn, -preserve, -copy, while writing a progress report
|
||||||
-keep] to the standard output.
|
-keep] to the standard output.
|
||||||
-d, --display, [package...] Display the installed packages
|
-d, --display, [package...] Display the installed packages
|
||||||
|
@ -152,7 +152,7 @@ def usage(repo):
|
||||||
[-q [build, install, build-install]]
|
[-q [build, install, build-install]]
|
||||||
[-g [print, edit=[editor]]]
|
[-g [print, edit=[editor]]]
|
||||||
[-l [repository], --index, --installed]
|
[-l [repository], --index, --installed]
|
||||||
[-c [repository], --upgrade, --skip=[...] --resolve-off]
|
[-c [repository], --upgrade, --skip=[...], --resolve-off]
|
||||||
[-s [repository] [package...], --resolve-off]
|
[-s [repository] [package...], --resolve-off]
|
||||||
[-t [repository] [package], --check-deps, --graph=[type]]
|
[-t [repository] [package], --check-deps, --graph=[type]]
|
||||||
[-p [repository] [package], --color=[]]
|
[-p [repository] [package], --color=[]]
|
||||||
|
@ -161,7 +161,7 @@ def usage(repo):
|
||||||
[-f [package...]]
|
[-f [package...]]
|
||||||
[-i [options] [package...]]
|
[-i [options] [package...]]
|
||||||
[-u [options] [package...]]
|
[-u [options] [package...]]
|
||||||
[-r [options] [package...], --check-deps, --tag]
|
[-r [options] [package...], --check-deps, --tag, --checklist]
|
||||||
[-d [package...]]
|
[-d [package...]]
|
||||||
"""
|
"""
|
||||||
error_repo = ""
|
error_repo = ""
|
||||||
|
|
|
@ -23,13 +23,18 @@
|
||||||
|
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from dialog import Dialog
|
|
||||||
|
|
||||||
|
|
||||||
class CheckList(object):
|
class CheckList(object):
|
||||||
"""Create dialog checklist
|
"""Create dialog checklist
|
||||||
"""
|
"""
|
||||||
def __init__(self, data, text, title, backtitle):
|
def __init__(self, data, text, title, backtitle):
|
||||||
|
try:
|
||||||
|
from dialog import Dialog
|
||||||
|
except ImportError:
|
||||||
|
print("Require 'pythondialog': Install with '# slpkg -s sbo "
|
||||||
|
"python2-pythondialog'")
|
||||||
|
raise SystemExit()
|
||||||
self.d = Dialog(dialog="dialog", autowidgetsize=True)
|
self.d = Dialog(dialog="dialog", autowidgetsize=True)
|
||||||
self.data = data
|
self.data = data
|
||||||
self.text = text
|
self.text = text
|
||||||
|
@ -41,15 +46,16 @@ class CheckList(object):
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Run dialog checklist
|
"""Run dialog checklist
|
||||||
"""
|
"""
|
||||||
pkgs = []
|
try:
|
||||||
|
choice = []
|
||||||
for item in self.data:
|
for item in self.data:
|
||||||
pkgs.append((item, "", False))
|
choice.append((item, "", False))
|
||||||
|
code, self.tags = self.d.checklist(
|
||||||
code, self.tags = self.d.checklist(text=self.text,
|
text=self.text, height=20, width=65, list_height=13,
|
||||||
height=20, width=65, list_height=13,
|
choices=choice, title=self.title, backtitle=self.backtitle)
|
||||||
choices=pkgs,
|
except KeyboardInterrupt:
|
||||||
title=self.title,
|
print("")
|
||||||
backtitle=self.backtitle)
|
raise SystemExit()
|
||||||
if code == "ok":
|
if code == "ok":
|
||||||
self.ununicode_to_string()
|
self.ununicode_to_string()
|
||||||
return self.ununicode
|
return self.ununicode
|
||||||
|
|
|
@ -457,8 +457,8 @@ class ArgParse(object):
|
||||||
"""
|
"""
|
||||||
packages = self.args[1:]
|
packages = self.args[1:]
|
||||||
options = ["-r", "--removepkg"]
|
options = ["-r", "--removepkg"]
|
||||||
additional_options = ["--check-deps", "--tag"]
|
additional_options = ["--check-deps", "--tag", "--checklist"]
|
||||||
flag = extra = ""
|
flag, extra = "", []
|
||||||
flags = [
|
flags = [
|
||||||
"-warn",
|
"-warn",
|
||||||
"-preserve",
|
"-preserve",
|
||||||
|
@ -466,10 +466,11 @@ class ArgParse(object):
|
||||||
"-keep"
|
"-keep"
|
||||||
]
|
]
|
||||||
if len(self.args) > 1 and self.args[0] in options:
|
if len(self.args) > 1 and self.args[0] in options:
|
||||||
if self.args[-1] in additional_options:
|
for additional in additional_options:
|
||||||
index = additional_options.index(self.args[-1])
|
if additional in self.args:
|
||||||
extra = additional_options[index]
|
extra.append(additional)
|
||||||
packages = self.args[1:-1]
|
self.args.remove(additional)
|
||||||
|
packages = self.args[1:]
|
||||||
if self.args[1] in flags:
|
if self.args[1] in flags:
|
||||||
flag = self.args[1]
|
flag = self.args[1]
|
||||||
packages = self.args[2:]
|
packages = self.args[2:]
|
||||||
|
|
|
@ -34,6 +34,8 @@ from slpkg.messages import Msg
|
||||||
from slpkg.splitting import split_package
|
from slpkg.splitting import split_package
|
||||||
from slpkg.__metadata__ import MetaData as _meta_
|
from slpkg.__metadata__ import MetaData as _meta_
|
||||||
|
|
||||||
|
from slpkg.checklist import CheckList
|
||||||
|
|
||||||
|
|
||||||
class PackageManager(object):
|
class PackageManager(object):
|
||||||
"""Package manager class for install, upgrade,
|
"""Package manager class for install, upgrade,
|
||||||
|
@ -141,22 +143,19 @@ class PackageManager(object):
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
return remove_dep
|
return remove_dep
|
||||||
|
|
||||||
def _view_removed(self):
|
def _get_removed(self):
|
||||||
"""View packages before removed
|
"""Manage removed packages by extra options
|
||||||
"""
|
"""
|
||||||
removed = []
|
removed, packages = [], []
|
||||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||||
self.meta.color["CYAN"], ", ".join(self.binary),
|
self.meta.color["CYAN"], ", ".join(self.binary),
|
||||||
self.meta.color["ENDC"]))
|
self.meta.color["ENDC"]))
|
||||||
if self.extra == "--tag":
|
if "--tag" in self.extra:
|
||||||
for pkg in find_package("", self.meta.pkg_path):
|
for pkg in find_package("", self.meta.pkg_path):
|
||||||
for tag in self.binary:
|
for tag in self.binary:
|
||||||
if pkg.endswith(tag):
|
if pkg.endswith(tag):
|
||||||
print("[ {0}delete{1} ] --> {2}".format(
|
|
||||||
self.meta.color["RED"], self.meta.color["ENDC"],
|
|
||||||
pkg))
|
|
||||||
removed.append(split_package(pkg)[0])
|
removed.append(split_package(pkg)[0])
|
||||||
self._sizes(pkg)
|
packages.append(pkg)
|
||||||
if not removed:
|
if not removed:
|
||||||
self.msg.pkg_not_found("", tag, "Can't remove", "")
|
self.msg.pkg_not_found("", tag, "Can't remove", "")
|
||||||
else:
|
else:
|
||||||
|
@ -166,13 +165,31 @@ class PackageManager(object):
|
||||||
package = find_package("{0}{1}{2}".format(
|
package = find_package("{0}{1}{2}".format(
|
||||||
name, ver, self.meta.sp), self.meta.pkg_path)
|
name, ver, self.meta.sp), self.meta.pkg_path)
|
||||||
if pkg and name == pkg:
|
if pkg and name == pkg:
|
||||||
print("[ {0}delete{1} ] --> {2}".format(
|
|
||||||
self.meta.color["RED"], self.meta.color["ENDC"],
|
|
||||||
package[0]))
|
|
||||||
removed.append(pkg)
|
removed.append(pkg)
|
||||||
self._sizes(package[0])
|
packages.append(package[0])
|
||||||
else:
|
else:
|
||||||
self.msg.pkg_not_found("", pkg, "Can't remove", "")
|
self.msg.pkg_not_found("", pkg, "Can't remove", "")
|
||||||
|
return removed, packages
|
||||||
|
|
||||||
|
def _view_removed(self):
|
||||||
|
"""View packages before removed
|
||||||
|
"""
|
||||||
|
removed, packages = self._get_removed()
|
||||||
|
if packages and "--checklist" in self.extra:
|
||||||
|
removed = []
|
||||||
|
pkgs = CheckList(packages,
|
||||||
|
"Hit 'spacebar' to choose packages to remove",
|
||||||
|
"Remove",
|
||||||
|
"{0} {1}".format(self.meta.__all__,
|
||||||
|
self.meta.__version__)).run()
|
||||||
|
for rmv in pkgs:
|
||||||
|
removed.append(split_package(rmv)[0])
|
||||||
|
self.meta.default_answer = "y"
|
||||||
|
else:
|
||||||
|
for rmv, pkg in zip(removed, packages):
|
||||||
|
print("[ {0}delete{1} ] --> {2}".format(
|
||||||
|
self.meta.color["RED"], self.meta.color["ENDC"], pkg))
|
||||||
|
self._sizes(pkg)
|
||||||
self._calc_sizes()
|
self._calc_sizes()
|
||||||
self._remove_summary()
|
self._remove_summary()
|
||||||
return removed
|
return removed
|
||||||
|
@ -271,7 +288,7 @@ class PackageManager(object):
|
||||||
def _check_if_used(self, removes):
|
def _check_if_used(self, removes):
|
||||||
"""Check package if dependencies for another package
|
"""Check package if dependencies for another package
|
||||||
before removed"""
|
before removed"""
|
||||||
if self.extra == "--check-deps":
|
if "--check-deps" in self.extra:
|
||||||
print("")
|
print("")
|
||||||
view = False
|
view = False
|
||||||
package, dependency = [], []
|
package, dependency = [], []
|
||||||
|
|
Loading…
Reference in a new issue