#!/usr/bin/lua require("aports") -- subcommands ----------------------- subcmd = {} subcmd.revdep = { desc = "Print reverse dependencies", usage = "PKG...", run = function(opts) local i local apkdb, rev = aports.init_apkdb(repodirs) for i = 2, #opts do local pkg = opts[i] local _,p for _,p in pairs(rev[pkg] or {}) do print(p.pkgname) end end end } subcmd.list = { desc = "Print all packages built from aports tree", usage = "", run = function() local apkdb = aports.init_apkdb(repodirs) local k,v for k,v in pairs(apkdb) do print(k) end end } subcmd.recursdeps = { desc = "Recursively print all make dependencies for given packages", usage = "PKG...", run = function (opts) local db, rev = aports.init_apkdb(repodirs) for i = 2, #opts do aports.recurs_until(db, opts[i], function(pn) print(pn) end) end end } subcmd.builddirs = { desc = "Print the build dirs for given packages in build order", usage = "PKG...", run = function(opts) local i, p, _ local visited = {} local db, rev = aports.init_apkdb(repodirs) local to_print = {} for i = 2, #opts do for _,p in pairs(db[opts[i]]) do to_print[p.dir] = true end end for i = 2, #opts do aports.recurs_until(db, opts[i], function(pn) local j,p for j, p in pairs(db[pn]) do if to_print[p.dir] then print(p.dir) to_print[p.dir] = nil end end end) end end } function print_usage() io.write("usage: ap -d