require ("luamods/command")
require("config/software_conf")


pkgnamestbl = {}
pkgvstbl = {}
pkgdesctbl = {}
rtr = ""

rtr = command.ex(software_conf.opkg_installed_pack)

if (rtr == nil) then rtr = "" end
packages = {}
for line in rtr:gmatch("(.-\n)") do
    name,version = line:match("(.-)%s+(.-)\n")
    if (name ~= nil) and (version ~= nil) then
        package = {}
        package.name = name
        package.version = version
        table.insert(packages, package)
    end
end

print("Content-type: application/octet-stream")
print("Content-Disposition: attachment; filename=\"all_pkgs.csv\"")
print("")

for num,package in ipairs(packages) do
    print(package.name..","..package.version)
end
