summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-06-20 23:39:52 +0200
committerAki <please@ignore.pl>2023-06-20 23:41:02 +0200
commit3150e436b8fd67d1742e7cbc025b6a4357724f43 (patch)
tree1f596629887b95bc80318a09c338340ed0ac8976
downloaddepstage-3150e436b8fd67d1742e7cbc025b6a4357724f43.zip
depstage-3150e436b8fd67d1742e7cbc025b6a4357724f43.tar.gz
depstage-3150e436b8fd67d1742e7cbc025b6a4357724f43.tar.bz2
Sketched the script intent mostly
-rw-r--r--depstage.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/depstage.lua b/depstage.lua
new file mode 100644
index 0000000..ef223a7
--- /dev/null
+++ b/depstage.lua
@@ -0,0 +1,32 @@
+#!/usr/bin/env lua
+local lapp = require "pl.lapp"
+local dir = require "pl.dir"
+local path = require "pl.path"
+local pretty = require "pl.pretty"
+local lpeg = require "lpeg"
+local args = lapp [[
+Finds dependencies from .SRCINFO files and lists them in buildable stages.
+]]
+local identifier = lpeg.R"az" + lpeg.R"09" + lpeg.S"@+_"
+identifier = identifier * (identifier + lpeg.S".-")^0
+local whitespace = lpeg.S" \t"^1
+local rest = (1 - lpeg.S"\n")^0
+local definition = lpeg.C(identifier) * whitespace * "=" * whitespace * lpeg.C(rest) * "\n"
+local subdefinition = whitespace * definition
+local emptylines = (whitespace * "\n")^1
+local block = lpeg.Ct(lpeg.Ct(definition) * lpeg.Ct(subdefinition)^0)
+local thing = block * (emptylines * block)^0
+local capture = lpeg.Ct(thing)
+for root, dirs, files in dir.walk(".") do
+ for _, file in pairs(files) do
+ if file == ".SRCINFO" then
+ local pathname = path.normpath(path.join(root, file))
+ local srcinfo<close> = io.open(pathname)
+ local content = srcinfo:read("a")
+ io.write(pathname, " ")
+ pretty.dump(capture:match(content))
+ print()
+ -- From this, find {,make,check}depends and group packages into stages.
+ end
+ end
+end