import os import osproc import strutils import re import cgi import parseopt # -------- # get variable value from configuration shell file # -------- proc confVar(variable: string, confFile = "/etc/slitaz/tazpanel.conf"): string = var tmpFile = JoinPath(getTempDir(), "tazpanel.tmp") writeFile(tmpFile, "#!/bin/sh\n. " & confFile & "\necho -n $" & variable & "\n") result = execCmdEx("sh " & tmpFile).output.strip removeFile(tmpFile) return # ======== # List installed packages. Generate table body only # ======== proc list = var installed = confVar("INSTALLED") images = confVar("IMAGES") blockedF = JoinPath(confVar("LOCALSTATE"), "blocked-packages.list") blocked = "" if existsFile(blockedF): blocked = readfile(blockedF) # get installed pkgs list setCurrentDir(installed) var installed_ls = execCmdEx("ls -1") for pkg in installed_ls.output.splitLines: if pkg != "": var version, description, web = "" var receipt = readfile(JoinPath(installed, pkg, "receipt")) for line in receipt.splitLines: if line =~ re"\s*VERSION\s*\=\s*\042([^\042]+)\042\s*": version = matches[0] elif line =~ re"\s*SHORT_DESC\s*\=\s*\042([^\042]+)\042\s*": description = matches[0] elif line =~ re"\s*WEB_SITE\s*\=\s*\042([^\042]+)\042\s*": web = matches[0] # if version need to be calculated (slow) # if version =~ re".*\$.*": version = confVar("VERSION", JoinPath(installed, pkg, "receipt")) # colorize blocked pkgs var colorpkg = pkg for blk in blocked.splitLines: if blk == pkg: colorpkg = "" & pkg & "" echo( "