Changeset View
Changeset View
Standalone View
Standalone View
tools/pkgbase/metalog_reader.lua
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | function main(args) | ||||
if filename == nil then | if filename == nil then | ||||
io.stderr:write('Missing filename.\n') | io.stderr:write('Missing filename.\n') | ||||
usage() | usage() | ||||
end | end | ||||
local sess = Analysis_session(filename, verbose, w_notagdirs) | local sess = Analysis_session(filename, verbose, w_notagdirs) | ||||
local errors | |||||
kevans: Drop the assignment, it'll default to `nil` which is a falsey value | |||||
if printall then | if printall then | ||||
io.write('--- PACKAGE REPORTS ---\n') | io.write('--- PACKAGE REPORTS ---\n') | ||||
io.write(sess.pkg_report_full()) | io.write(sess.pkg_report_full()) | ||||
io.write('--- LINTING REPORTS ---\n') | io.write('--- LINTING REPORTS ---\n') | ||||
print_lints(sess) | errors = print_lints(sess) | ||||
elseif checkonly then | elseif checkonly then | ||||
print_lints(sess) | errors = print_lints(sess) | ||||
elseif pkgonly then | elseif pkgonly then | ||||
io.write(sess.pkg_report_simple(dcount, dsize, { | io.write(sess.pkg_report_simple(dcount, dsize, { | ||||
fuid and sess.pkg_issetuid or nil, | fuid and sess.pkg_issetuid or nil, | ||||
fgid and sess.pkg_issetgid or nil, | fgid and sess.pkg_issetgid or nil, | ||||
fid and sess.pkg_issetid or nil | fid and sess.pkg_issetid or nil | ||||
})) | })) | ||||
else | else | ||||
io.stderr:write('This text should not be displayed.') | io.stderr:write('This text should not be displayed.') | ||||
usage() | usage() | ||||
end | end | ||||
if errors then | |||||
return 1 | |||||
end | end | ||||
end | |||||
--- @param man boolean | --- @param man boolean | ||||
function usage(man) | function usage(man) | ||||
local sn = 'Usage: '..arg[0].. ' [-h] [-a | -c | -p [-count] [-size] [-f...]] [-W...] metalog-path \n' | local sn = 'Usage: '..arg[0].. ' [-h] [-a | -c | -p [-count] [-size] [-f...]] [-W...] metalog-path \n' | ||||
if man then | if man then | ||||
io.write('\n') | io.write('\n') | ||||
io.write(sn) | io.write(sn) | ||||
io.write( | io.write( | ||||
Show All 31 Lines | |||||
--- @param sess Analysis_session | --- @param sess Analysis_session | ||||
function print_lints(sess) | function print_lints(sess) | ||||
local dupwarn, duperr = sess.dup_report() | local dupwarn, duperr = sess.dup_report() | ||||
io.write(dupwarn) | io.write(dupwarn) | ||||
io.write(duperr) | io.write(duperr) | ||||
local inodewarn, inodeerr = sess.inode_report() | local inodewarn, inodeerr = sess.inode_report() | ||||
io.write(inodewarn) | io.write(inodewarn) | ||||
io.write(inodeerr) | io.write(inodeerr) | ||||
return #duperr > 0 or #inodeerr > 0 | |||||
Not Done Inline Actionsreturn #duperr or #inodeerr, perhaps kevans: `return #duperr or #inodeerr`, perhaps | |||||
Done Inline ActionsOr actually return #duperr > 0 or #inodeerr > 0 emaste: Or actually `return #duperr > 0 or #inodeerr > 0` | |||||
end | end | ||||
--- @param t table | --- @param t table | ||||
function sortedPairs(t) | function sortedPairs(t) | ||||
local sortedk = {} | local sortedk = {} | ||||
for k in next, t do sortedk[#sortedk+1] = k end | for k in next, t do sortedk[#sortedk+1] = k end | ||||
table.sort(sortedk) | table.sort(sortedk) | ||||
local i = 0 | local i = 0 | ||||
▲ Show 20 Lines • Show All 353 Lines • ▼ Show 20 Lines | return { | ||||
pkg_issetid = pkg_issetid, | pkg_issetid = pkg_issetid, | ||||
pkg_report_full = pkg_report_full, | pkg_report_full = pkg_report_full, | ||||
pkg_report_simple = pkg_report_simple, | pkg_report_simple = pkg_report_simple, | ||||
dup_report = dup_report, | dup_report = dup_report, | ||||
inode_report = inode_report | inode_report = inode_report | ||||
} | } | ||||
end | end | ||||
main(arg) | os.exit(main(arg)) |
Drop the assignment, it'll default to nil which is a falsey value