summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-09-30 12:44:43 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-09-30 12:44:43 +0000
commitf654134675754c19f1b69f78c042c44da5aa0880 (patch)
tree5567a4339129ff7de2ee25628b696c951df2ff47
parent94c7dfa6b90082b90c8efd88e2fa178ef28ab47b (diff)
downloadabuild-f654134675754c19f1b69f78c042c44da5aa0880.tar.gz
abuild-f654134675754c19f1b69f78c042c44da5aa0880.tar.bz2
abuild-f654134675754c19f1b69f78c042c44da5aa0880.tar.xz
abuild-f654134675754c19f1b69f78c042c44da5aa0880.zip
ap: implement build-list and rebuild-list
build-list will list which aports that has missing packages rebuild-list will list which aports that has outdated packages, i.e. when APKBUILD is newer than the apk
-rwxr-xr-xap.in51
1 files changed, 51 insertions, 0 deletions
diff --git a/ap.in b/ap.in
index 4c9d510..e5ce0e7 100755
--- a/ap.in
+++ b/ap.in
@@ -5,6 +5,19 @@ require("lfs")
local db
+local function build_is_outdated(pkg)
+ local apk_attr = lfs.attributes(aports.get_apk_file_path(pkg))
+ local apkbuild_attr = lfs.attributes(pkg.dir.."/APKBUILD")
+ if apk_attr == nil then
+ return true
+ end
+ return os.difftime(apk_attr.modification, apkbuild_attr.modification) < 0
+end
+
+local function build_is_missing(pkg)
+ return lfs.attributes(aports.get_apk_file_path(pkg)) == nil
+end
+
-- subcommands -----------------------
subcmd = {}
subcmd.revdep = {
@@ -83,6 +96,40 @@ subcmd.sources = {
end
}
+subcmd["rebuild-list"] = {
+ desc = "List packages that can/should be rebuilt",
+ usage = "",
+ run = function()
+ local outdated = {}
+ db:foreach(function(k)
+ db:foreach_pkg(k, function(_, p)
+ if build_is_outdated(p) then
+ table.insert(outdated, p.pkgname)
+ end
+ end)
+ end)
+ -- print build dirs in build sort order
+ subcmd.builddirs.run(outdated)
+ end
+}
+
+subcmd["build-list"] = {
+ desc = "List packages that is not built",
+ usage = "",
+ run = function()
+ local missing = {}
+ db:foreach(function(k)
+ db:foreach_pkg(k, function(_, p)
+ if build_is_missing(p) then
+ table.insert(missing, p.pkgname)
+ end
+ end)
+ end)
+ -- print build dirs in build sort order
+ subcmd.builddirs.run(missing)
+ end
+}
+
function print_usage()
io.write("usage: ap -d <DIR> SUBCOMMAND [options]\n\nSubcommands are:\n")
local k,v
@@ -130,7 +177,11 @@ end
if subcmd[cmd] and type(subcmd[cmd].run) == "function" then
db = aports.new(repodirs)
+ loadtime = os.clock()
subcmd[cmd].run(opts)
+ runtime = os.clock() - loadtime
+-- io.stderr:write("db load time = "..tostring(loadtime).."\n")
+-- io.stderr:write("cmd run time = "..tostring(runtime).."\n")
else
io.stderr:write(cmd..": invalid subcommand\n")
end