diff --git a/README.rst b/README.rst index 65f4320e..fc02e07f 100644 --- a/README.rst +++ b/README.rst @@ -251,7 +251,7 @@ Command Line Tool Usage -q, --list, [package...] --add, --remove add, remove SBo packages in queue -q, --build, --install, --build-install build, install packages from queue -g, --config, --config=[editor] configuration file management - -l, [repository], --index list of repositories packages + -l, [repository], --index, --installed list of repositories packages -c, [repository] --upgrade check for updated packages -s, [repository] [package...] download, build & install packages -t, [repository] [package] package tracking dependencies @@ -572,6 +572,7 @@ Read fies, download, build or install: Choose an option: _ + Auto tool to build package: .. code-block:: bash diff --git a/man/slpkg.8 b/man/slpkg.8 index de25dffa..4087dcce 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -169,7 +169,7 @@ Build or install or build and install packages are queued. Print configuration file or edit with editor. .SS -l , list of installed packages -\fBslpkg\fP \fB-l\fP <\fIrepository\fP>, \fI--index\fP +\fBslpkg\fP \fB-l\fP <\fIrepository\fP>, \fI--index\fP, \fI--installed\fP .PP List of packages per repository. Support command 'grep' like '# slpkg -l sbo | grep "python"'. diff --git a/slpkg/arguments.py b/slpkg/arguments.py index 3ddb3bb7..8f936d08 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -54,7 +54,7 @@ def options(): "from queue", " -g, --config, --config=[editor] configuration file " "management", - " -l, [repository], --index list of repositories " + " -l, [repository], --index, --installed list of repositories " "packages", " -c, [repository] --upgrade check for updated " "packages", @@ -100,7 +100,7 @@ def usage(repo): " [-q --list, [...] --add, --remove]", " [-q --build, --install, --build-install]", " [-g --config, --config=[editor]]", - " [-l [repository], --index]", + " [-l [repository], --index, --installed]", " [-c [repository] --upgrade]", " [-s [repository] [package...]", " [-t [repository] [package]", diff --git a/slpkg/main.py b/slpkg/main.py index 29712923..5fafc08d 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -137,14 +137,17 @@ def main(): elif (len(args) == 2 and args[0] == 'repo-info' and args[1] not in RepoList().all_repos): usage(args[1]) - if len(args) == 3 and args[0] == '-a': BuildPackage(args[1], args[2:], _m.path).build() - elif (len(args) == 3 and args[0] == '-l' and args[2] == '--index' and - args[1] in _m.repositories): - PackageManager(None).list(args[1], True) + elif (len(args) == 3 and args[0] == '-l' and args[1] in _m.repositories): + if args[2] == '--index': + PackageManager(None).list(args[1], True, False) + elif args[2] == '--installed': + PackageManager(None).list(args[1], False, True) + else: + usage(args[1]) elif len(args) == 2 and args[0] == '-l' and args[1] in _m.repositories: - PackageManager(None).list(args[1], False) + PackageManager(None).list(args[1], False, False) elif len(args) == 3 and args[0] == '-c' and args[2] == '--upgrade': if args[1] in _m.repositories and args[1] not in ['slack', 'sbo']: Case('').binary_upgrade(args[1]) diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py index 9950ed04..121780d2 100644 --- a/slpkg/pkg/manager.py +++ b/slpkg/pkg/manager.py @@ -264,7 +264,7 @@ class PackageManager(object): bol = eol = "\n" Msg().pkg_not_found(bol, pkg, message, eol) - def list(self, repo, INDEX): + def list(self, repo, INDEX, installed): ''' List with the installed packages ''' @@ -290,9 +290,9 @@ class PackageManager(object): if line.startswith("PACKAGE NAME: "): pkg_list.append(line[15:].strip()) for pkg in sorted(pkg_list): - pkg = self._list_color_tag(pkg) if INDEX: index += 1 + pkg = self._list_color_tag(pkg) print("{0}{1}:{2} {3}".format(_m.color['GREY'], index, _m.color['ENDC'], pkg)) if index == page: @@ -304,8 +304,12 @@ class PackageManager(object): break print("") # new line after page page += row + elif installed: + if self._list_of_installed(pkg): + print('{0}{1}{2}'.format(_m.color['GREEN'], pkg, + _m.color['ENDC'])) else: - print pkg + print(pkg) print("") # new line at end except KeyboardInterrupt: print("") # new line at exit @@ -322,3 +326,13 @@ class PackageManager(object): pkg = '{0}{1}{2}'.format(_m.color['GREEN'], pkg, _m.color['ENDC']) return pkg + + def _list_of_installed(self, pkg): + ''' + Return installed packages + ''' + find = pkg + '-' + if pkg.endswith('.txz') or pkg.endswith('.tgz'): + find = pkg[:-4] + if find_package(find, _m.pkg_path): + return pkg