diff options
author | Aki <please@ignore.pl> | 2023-12-13 01:16:14 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2023-12-13 01:16:14 +0100 |
commit | 80584b846c59ee5e7357d7da435cff0fcbcde386 (patch) | |
tree | bd7b65e66a0289c6d4f89a9cab05c12be564b98a | |
parent | 3150e436b8fd67d1742e7cbc025b6a4357724f43 (diff) | |
download | depstage-master.zip depstage-master.tar.gz depstage-master.tar.bz2 |
-rw-r--r-- | depstage.lua | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/depstage.lua b/depstage.lua index ef223a7..249d1ab 100644 --- a/depstage.lua +++ b/depstage.lua @@ -3,28 +3,21 @@ 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 srcinfo = require "srcinfo" local args = lapp [[ Finds dependencies from .SRCINFO files and lists them in buildable stages. + +Usage: depstage [-h] [<pathname>] + -h, --help Display this help message and exit. + <pathname> (default '.') Optional path to directory to start recursive transversal from. ]] -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 root, dirs, files in dir.walk(args.pathname) 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") + local handle<close> = io.open(pathname) io.write(pathname, " ") - pretty.dump(capture:match(content)) + pretty.dump(srcinfo(handle)) print() -- From this, find {,make,check}depends and group packages into stages. end |