From dcb95cad733598c2ec0399f6934ff280f7ce7369 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 18 Aug 2015 08:03:29 +0300 Subject: [PATCH] Added remove packages with by TAG --- man/slpkg.8 | 4 +++- slpkg/arguments.py | 4 ++-- slpkg/main.py | 7 ++++--- slpkg/pkg/manager.py | 35 +++++++++++++++++++++++------------ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/man/slpkg.8 b/man/slpkg.8 index 4e4ef260..4ea9a270 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -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> diff --git a/slpkg/arguments.py b/slpkg/arguments.py index 15e626ec..ce1008c9 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -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 = "" diff --git a/slpkg/main.py b/slpkg/main.py index 31fef71f..66e17519 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -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] diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py index 11ccd574..144c7f21 100644 --- a/slpkg/pkg/manager.py +++ b/slpkg/pkg/manager.py @@ -145,18 +145,29 @@ class PackageManager(object): print("\nPackages with name matching [ {0}{1}{2} ]\n".format( self.meta.color["CYAN"], ", ".join(self.binary), self.meta.color["ENDC"])) - 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: - print("[ {0}delete{1} ] --> {2}".format( - self.meta.color["RED"], self.meta.color["ENDC"], - package[0])) - removed.append(pkg) - else: - Msg().pkg_not_found("", pkg, "Can't remove", "") + 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 pkg and name == pkg: + print("[ {0}delete{1} ] --> {2}".format( + self.meta.color["RED"], self.meta.color["ENDC"], + package[0])) + removed.append(pkg) + else: + Msg().pkg_not_found("", pkg, "Can't remove", "") return removed def _view_deps(self, path, package):