mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-17 06:11:35 +01:00
update find installed packages
This commit is contained in:
parent
907752ce85
commit
6b14f89596
2 changed files with 28 additions and 13 deletions
|
@ -86,6 +86,8 @@ def main():
|
|||
type=str, nargs="+", metavar=("sbo, slack", "<upgrade>"))
|
||||
parser.add_argument("-s", help="download, build & install packages",
|
||||
type=str, nargs="+", metavar=("sbo, slack","<package>"))
|
||||
parser.add_argument("-f", help="find installed packages",
|
||||
type=str, metavar=(""))
|
||||
parser.add_argument("-t", help="packages tracking dependencies from SBo",
|
||||
type=str, metavar=(""))
|
||||
parser.add_argument("-n", help="view packages from SBo repository",
|
||||
|
@ -98,8 +100,6 @@ def main():
|
|||
type=str, nargs="+", metavar=(""))
|
||||
parser.add_argument("-r", help="remove binary packages",
|
||||
type=str, nargs="+", metavar=(""))
|
||||
parser.add_argument("-f", help="view installed packages",
|
||||
type=str, nargs="+", metavar=(""))
|
||||
parser.add_argument("-d", help="display the contents of the packages",
|
||||
type=str, nargs="+", metavar=(""))
|
||||
args = parser.parse_args()
|
||||
|
|
|
@ -170,17 +170,32 @@ def pkg_find(binary):
|
|||
'''
|
||||
Find installed Slackware packages
|
||||
'''
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
colors.CYAN, ', '.join(binary), colors.ENDC))
|
||||
for pkg in binary:
|
||||
if find_package(pkg + sp, pkg_path):
|
||||
print(colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
|
||||
find_package(pkg + sp, pkg_path)))
|
||||
else:
|
||||
message = "Can't find"
|
||||
pkg_not_found("", pkg, message, "")
|
||||
print # new line at end
|
||||
|
||||
matching, size = 0, 0
|
||||
print("\nInstalled packages with name matching [ {0}{1}{2} ]\n".format(
|
||||
colors.CYAN, binary, colors.ENDC))
|
||||
for match in sorted(os.listdir(pkg_path)):
|
||||
if binary in match:
|
||||
matching += 1
|
||||
print colors.GREEN + "[ installed ] -" + colors.ENDC, match
|
||||
f = open(pkg_path + match, "r")
|
||||
data = f.read()
|
||||
f.close()
|
||||
for line in data.splitlines():
|
||||
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
|
||||
if "M" in line[26:]:
|
||||
size += float(line[26:-1]) * 1024
|
||||
else:
|
||||
size += float(line[26:-1])
|
||||
if matching == 0:
|
||||
print("No package was found to match\n")
|
||||
else:
|
||||
print("\n{0}Found {1} matcing packages{2}".format(colors.GREY, matching, colors.ENDC))
|
||||
unit = "Kb"
|
||||
if size > 1024:
|
||||
unit = "Mb"
|
||||
size = (size / 1024)
|
||||
print("{0}Total size of installed packages {1} {2}{3}\n".format(
|
||||
colors.GREY, round(size, 2), unit, colors.ENDC))
|
||||
def pkg_display(binary):
|
||||
'''
|
||||
Print the Slackware packages contents
|
||||
|
|
Loading…
Reference in a new issue