Lines Matching +full:package +full:- +full:mode
3 -- SPDX-License-Identifier: BSD-2-Clause
4 --
5 -- Copyright(c) 2020 The FreeBSD Foundation.
6 --
7 -- Redistribution and use in source and binary forms, with or without
8 -- modification, are permitted provided that the following conditions
9 -- are met:
10 -- 1. Redistributions of source code must retain the above copyright
11 -- notice, this list of conditions and the following disclaimer.
12 -- 2. Redistributions in binary form must reproduce the above copyright
13 -- notice, this list of conditions and the following disclaimer in the
14 -- documentation and/or other materials provided with the distribution.
15 --
16 -- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 -- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 -- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 -- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 -- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 -- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 -- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 -- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 -- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 -- SUCH DAMAGE.
41 if args[i] == '-h' then
43 elseif args[i] == '-a' then
45 elseif args[i] == '-c' then
48 elseif args[i] == '-p' then
53 if args[i] == '-count' then
55 elseif args[i] == '-size' then
57 elseif args[i] == '-fsetuid' then
59 elseif args[i] == '-fsetgid' then
61 elseif args[i] == '-fsetid' then
64 i = i-1
68 elseif args[i] == '-v' then
70 elseif args[i] == '-Wcheck-notagdir' then
72 elseif args[i]:match('^%-') then
90 io.write('--- PACKAGE REPORTS ---\n')
92 io.write('--- LINTING REPORTS ---\n')
112 --- @param man boolean
114 …local sn = 'Usage: '..arg[0].. ' [-h] [-a | -c | -p [-count] [-size] [-f...]] [-W...] metalog-path…
123 format that's returned by `mtree -c | mtree -C`
126 -a prints all scan results. this is the default option if no option
128 -c lints the file and gives warnings/errors, including duplication
130 -Wcheck-notagdir entries with dir type and no tags will be also
132 -p list all package names found in the file as exactly specified by
133 `tags=package=...`
134 -count display the number of files of the package
135 -size display the size of the package
136 -fsetgid only include packages with setgid files
137 -fsetuid only include packages with setuid files
138 -fsetid only include packages with setgid or setuid files
139 -v verbose mode
140 -h help page
150 --- @param sess Analysis_session
161 --- @param t table
173 --- @param t table <T, U>
174 --- @param f function <U -> U>
181 --- @class MetalogRow
182 -- a table contaning file's info, from a line content from METALOG file
183 -- all fields in the table are strings
184 -- sample output:
185 -- {
186 -- filename = ./usr/share/man/man3/inet6_rthdr_segments.3.gz
187 -- lineno = 5
188 -- attrs = {
189 -- gname = 'wheel'
190 -- uname = 'root'
191 -- mode = '0444'
192 -- size = '1166'
193 -- time = nil
194 -- type = 'file'
195 -- tags = 'package=clibs,debug'
196 -- }
197 -- }
198 --- @param line string
202 -- mtree file has space escaped as '\\040', not affecting splitting
203 -- string by space
205 local k, v = attrpair:match('^(.-)=(.+)')
214 -- check if an array of MetalogRows are equivalent. if not, the first field
215 -- that's different is returned secondly
216 --- @param rows MetalogRow[]
217 --- @param ignore_name boolean
218 --- @param ignore_tags boolean
224 -- ignoring linenum in METALOG file as it's not relavant
241 --- @param tagstr string
245 if seg:match('package=') then
251 ext = ext == '' and seg or ext..'-'..seg
255 ..(ext == '' and '' or '-'..ext)
256 ..(pkgend == '' and '' or '-'..pkgend)
260 --- @class Analysis_session
261 --- @param metalog string
262 --- @param verbose boolean
263 --- @param w_notagdirs boolean turn on to also check directories
266 local files = {} -- map<string, MetalogRow[]>
267 -- set is map<elem, bool>. if bool is true then elem exists
268 local pkgs = {} -- map<string, set<string>>
269 ----- used to keep track of files not belonging to a pkg. not used so
270 ----- it is commented with -----
271 -----local nopkg = {} -- set<string>
272 --- @public
274 --- @public
277 -- returns number of files in package and size of package
278 -- nil is returned upon errors
279 --- @param pkgname string
284 -- normally, there should be only one row per filename
285 -- if these rows are equal, there should be warning, but it
286 -- does not affect size counting. if not, it is an error
299 --- @param pkgname string
300 --- @param mode number
301 local function pkg_ismode(pkgname, mode)
304 if tonumber(row.attrs.mode, 8) & mode ~= 0 then
312 --- @param pkgname string
313 --- @public
318 --- @param pkgname string
319 --- @public
324 --- @param pkgname string
325 --- @public
330 -- sample return:
331 -- { [*string]: { count=1, size=2, issetuid=true, issetgid=true } }
344 -- returns a string describing package scan report
345 --- @public
349 sb[#sb+1] = 'Package '..pkgname..':'
362 --- @param have_count boolean
363 --- @param have_size boolean
364 --- @param filters function[]
365 --- @public
366 -- returns a string describing package size report.
367 -- sample: "mypackage 2 2048"* if both booleans are true
373 -- doing a foldl to all the function results with (and)
385 -- returns a string describing duplicate file warnings,
386 -- returns a string describing duplicate file errors
387 --- @public
393 if iseq then -- repeated line, just a warning
406 -- same filename (possibly different tags), different metadata, an error
419 -- returns a string describing warnings of found hard links
420 -- returns a string describing errors of found hard links
421 --- @public
423 -- obtain inodes of filenames
425 local inm = {} -- map<number, string[]>
426 local unstatables = {} -- string[]
428 -- i only took the first row of a filename,
429 -- and skip links and folders
447 -- i only took the first row of a filename
474 -- The METALOG file is assumed to be at the top of the stage directory.
484 -- scan all lines and put file data into the dictionaries
485 local firsttimes = {} -- set<string>
488 -----local isinpkg = false
490 -- skip lines beginning with #
492 -- skip blank lines
496 -- entries with dir and no tags... ignore for the first time
511 ------isinpkg = true
513 -----if not isinpkg then nopkg[data.filename] = true end