.\" Man page for e2-ls-project
.\"
-.\" (c)2007-2016 emlix GmbH
+.\" (c)2007-2017 emlix GmbH
.\"
.TH e2-ls-project 1 "@VERSION@"
e2-ls-project \- show project information of an e2factory project
.SH SYNOPSIS
-e2-ls-project [<option>]... [<result> ]
+e2-ls-project [<option> ...] [<result> ...]
.SH DESCRIPTION
\fBe2-ls-project\fR is part of the e2factory commandline tools.
-.br
\fBe2-ls-project\fR displays the configuration and components of the
current e2factory project.
-If <result> is given, reduce output to that result and all results it depends on.
+With no argument, the default results and dependencies are selected.
+If <result> is given, <result> and dependencies are selected instead.
.SH RETURN VALUE
-Normally, exit status is 0. On error, it is non-zero.
+Normal exit status is 0. On error, it is non-zero.
.SH OPTIONS
.TP
.BR \-\-all
-Show all sources and results, even if not currently used by the project.
+Select all results, sources, licences and chroot groups of the project.
.TP
.BR \-\-dot
Generate graph for processing with graphviz, see dot(1).
.BR \-\-env
Also show env variables.
.TP
+.BR \-\-unused
+Show unused results, sources, licences and chroot groups with respect to default
+results and arguments.
+.TP
For further global options, see \fBe2factory\fR(1).
.SH EXAMPLES
Generate a graph and convert it to pdf.
.SH SEE ALSO
.BR e2factory (1)
-
-.SH COPYRIGHT
-(c)2007-2016 emlix GmbH
--- e2-ls-project command
-- @module local.e2-ls-project
--- Copyright (C) 2007-2016 emlix GmbH, see file AUTHORS
+-- Copyright (C) 2007-2017 emlix GmbH, see file AUTHORS
--
-- This file is part of e2factory, the emlix embedded build system.
-- For more information see http://www.e2factory.org
local result = require("result")
local source = require("source")
+--- Shows unused results, sources, licences, and chroot groups.
+-- @param results Vector of used result names.
+-- @param chrootgroups Vector of used chroot group names.
+-- @param sources Vector of used source names.
+-- @param licences Vector of used licence names.
+-- @return Always returns true.
+-- @raise Assert
+local function show_unused(results, chrootgroups, sources, licences)
+ assertIsTable(results)
+ assertIsTable(chrootgroups)
+ assertIsTable(sources)
+ assertIsTable(licences)
+
+ --- Returns all names from all_dict that are not found in seen_vec. Name
+ -- must be a string.
+ -- @param all_dict Dictionary filled with (name, ignored type) pairs
+ -- @param seen_vec Vector filled with (ignored number, name) pairs
+ -- @return Sorted vector with names.
+ local function subtract(all_dict, seen_vec)
+ local seen = {}
+ local ret = {}
+
+ for _,name in ipairs(seen_vec) do
+ assertIsString(name)
+ seen[name] = true
+ end
+
+ for name,_ in pairs(all_dict) do
+ assertIsString(name)
+ if not seen[name] then
+ table.insert(ret, name)
+ end
+ end
+
+ table.sort(ret)
+ return ret
+ end
+
+ console.infof("unused results: %s\n",
+ table.concat(subtract(result.results, results), " "))
+
+ console.infof("unused sources: %s\n",
+ table.concat(subtract(source.sources, sources), " "))
+
+ console.infof("unused licences: %s\n",
+ table.concat(subtract(licence.licences, licences), " "))
+
+ console.infof("unused chroot groups: %s\n",
+ table.concat(subtract(chroot.groups_byname, chrootgroups), " "))
+
+ return true
+end
+
--- e2 ls-project entry point.
-- @param arg Arguments.
-- @return Always true.
e2option.flag("all", "show unused results and sources, too")
e2option.flag("chroot", "show chroot groups as well")
e2option.flag("env", "show environment vars as well")
+ e2option.flag("unused", "show unused results, sources, licences and chroot groups")
local opts, arguments = e2option.parse(arg)
if not opts then
end
table.sort(licences)
+ if opts.unused then
+ return show_unused(results, chrootgroups, sources, licences)
+ end
+
local function pempty(s1, s2, s3)
console.infof(" %s %s %s\n", s1, s2, s3)
end