54 lines
1.4 KiB
Lua
54 lines
1.4 KiB
Lua
local ostree = require "ostree";
|
|
local flatpak = require "flatpak";
|
|
|
|
local actions = {};
|
|
function actions.list(options)
|
|
local repo = ostree.from_http(options.repo);
|
|
local index = repo:read_summary_index();
|
|
local summary = repo:read_subsummary(index.refs.x86_64.checksum);
|
|
|
|
for ref in summary.refs do
|
|
print(ref);
|
|
end
|
|
end
|
|
function actions.search(options, term)
|
|
local repo = ostree.from_http(options.repo);
|
|
local index = repo:read_summary_index();
|
|
local summary = repo:read_subsummary(index.refs.x86_64.checksum);
|
|
|
|
for ref in summary.refs do
|
|
if ref:lower():match(term:lower(), 1, true) then
|
|
print(ref);
|
|
end
|
|
end
|
|
end
|
|
function actions.info(options, name)
|
|
local repo = ostree.from_http(options.repo);
|
|
print(name);
|
|
local meta = flatpak.parse_package(repo, name);
|
|
pprint(meta);
|
|
|
|
print("Name: " .. meta.name);
|
|
print("Branch: " .. meta.branch);
|
|
print("Architecture: " .. meta.arch);
|
|
print("Version: " .. (meta.version or "(not specified)"));
|
|
print("License: " .. (meta.license or "(not specified)"));
|
|
print("Summary: " .. (meta.summary or "(not specified)"));
|
|
|
|
print("Dependencies:");
|
|
if meta.deps.debug then
|
|
print("\tDebug package: " .. meta.deps.debug.name);
|
|
end
|
|
if meta.deps.locale then
|
|
print("\tLocale package: " .. meta.deps.locale.name);
|
|
end
|
|
for i = 1, #meta.deps do
|
|
local dep = meta.deps[i];
|
|
print("\t" .. dep.name .. (dep.required and "" or " (optional)"));
|
|
end
|
|
end
|
|
|
|
return function (options, action, ...)
|
|
actions[action](options, ...);
|
|
end
|