Added remove packages with by TAG

This commit is contained in:
Dimitris Zlatanidis 2015-08-18 08:03:29 +03:00
parent c1fd4c48a0
commit dcb95cad73
4 changed files with 32 additions and 18 deletions

View file

@ -264,7 +264,7 @@ and will skip any packages that do not already have a version installed.
More information please read "man upgradepkg".
.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
\fBslpkg\fP \fB-r\fP \fB[-copy, -keep, -preserve, -warn]\fP <\fInames of packages\fP>, \fB--check-deps\fP, \fB--tag\fP
.PP
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
@ -276,6 +276,8 @@ More information please read "man removepkg".
Additional options:
.PP
\fB--check-deps\fP : Check if installed packages used by other packages.
.pp
\fB--tag\fP : Remove packages with by tag.
.SS -d, --display, display the installed packages contents and file list
\fBslpkg\fP \fB-d\fP <\fInames of packages\fP>

View file

@ -117,7 +117,7 @@ Optional arguments:
options=[--dry-run, --install-new, binary packages from an older
--reinstall, --verbose] version to a newer one.
-r, --removepkg, [options] [package...], Removes a previously installed
--check-deps Slackware binary packages,
--check-deps, --tag Slackware binary packages,
options=[-warn, -preserve, -copy, while writing a progress report
-keep] to the standard output.
-d, --display, [package...] Display the installed packages
@ -161,7 +161,7 @@ def usage(repo):
[-f [package...]]
[-i [options] [package...]]
[-u [options] [package...]]
[-r [options] [package...], --check-deps]
[-r [options] [package...], --check-deps, --tag]
[-d [package...]]
"""
error_repo = ""

View file

@ -456,7 +456,7 @@ class ArgParse(object):
"""
packages = self.args[1:]
options = ["-r", "--removepkg"]
additional_options = ["--check-deps"]
additional_options = ["--check-deps", "--tag"]
flag = extra = ""
flags = [
"-warn",
@ -465,8 +465,9 @@ class ArgParse(object):
"-keep"
]
if len(self.args) > 1 and self.args[0] in options:
if self.args[-1] == additional_options[0]:
extra = additional_options[0]
if self.args[-1] in additional_options:
index = additional_options.index(self.args[-1])
extra = additional_options[index]
packages = self.args[1:-1]
if self.args[1] in flags:
flag = self.args[1]

View file

@ -145,12 +145,23 @@ class PackageManager(object):
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
self.meta.color["CYAN"], ", ".join(self.binary),
self.meta.color["ENDC"]))
if self.extra == "--tag":
for pkg in find_package("", self.meta.pkg_path):
for tag in self.binary:
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])
if not removed:
Msg().pkg_not_found("", tag, "Can't remove", "")
else:
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)
if name == pkg:
package = find_package("{0}{1}{2}".format(
name, ver, self.meta.sp), self.meta.pkg_path)
if pkg and name == pkg:
print("[ {0}delete{1} ] --> {2}".format(
self.meta.color["RED"], self.meta.color["ENDC"],
package[0]))