Author: jkupec
Date: Fri Sep 19 22:44:38 2008
New Revision: 11108
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11108&view=rev
Log:
- 'licenses' command added (fate #303703)
Modified:
trunk/zypper/doc/zypper.8
trunk/zypper/src/Command.cc
trunk/zypper/src/Command.h
trunk/zypper/src/Zypper.cc
trunk/zypper/src/misc.cc
trunk/zypper/src/misc.h
Modified: trunk/zypper/doc/zypper.8
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/doc/zypper.8?rev=11108&r1=11107&r2=11108&view=diff
==============================================================================
--- trunk/zypper/doc/zypper.8 (original)
+++ trunk/zypper/doc/zypper.8 Fri Sep 19 22:44:38 2008
@@ -925,6 +925,23 @@
is read from <current-rootdir>/etc/products.d/baseproduct and the architecture
is determined from uname and CPU flags.
+.TP
+.B licenses
+Prints a report about \fBlicenses\fR and \fBEULA\fRs of installed packages
+to standard output.
+
+First, a list of all packages and their licenses and/or EULAs is shown.
+This is followed by a summary, including the total number of installed
+packages, the number of installed
+packages with EULAs that required a confirmation from the user. Since the
+EULAs are not stored on the system and can only be read from repository
+metadata, the summary includes also the number of installed packages
+that have their counterpart in repositories. The report ends with a list
+of all licenses uses by the installed packages.
+
+This command can be useful for companies redistributiong a custom
+distribution (like appliances) to figure out what licenses they are bound by.
+
.SH "GLOBAL OPTIONS"
Modified: trunk/zypper/src/Command.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/Command.cc?rev=11108&r1=11107&r2=11108&view=diff
==============================================================================
--- trunk/zypper/src/Command.cc (original)
+++ trunk/zypper/src/Command.cc Fri Sep 19 22:44:38 2008
@@ -63,6 +63,7 @@
const ZypperCommand ZypperCommand::TARGET_OS(ZypperCommand::TARGET_OS_e);
const ZypperCommand ZypperCommand::VERSION_CMP(ZypperCommand::VERSION_CMP_e);
+const ZypperCommand ZypperCommand::LICENSES(ZypperCommand::LICENSES_e);
const ZypperCommand ZypperCommand::HELP(ZypperCommand::HELP_e);
const ZypperCommand ZypperCommand::SHELL(ZypperCommand::SHELL_e);
@@ -134,6 +135,7 @@
_table["targetos"] = _table["tos"] = ZypperCommand::TARGET_OS_e;
_table["versioncmp"] = _table["vcmp"] = ZypperCommand::VERSION_CMP_e;
+ _table["licenses"] = ZypperCommand::LICENSES_e;
_table["help"] = _table["?"] = ZypperCommand::HELP_e;
_table["shell"] = _table["sh"] = ZypperCommand::SHELL_e;
Modified: trunk/zypper/src/Command.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/Command.h?rev=11108&r1=11107&r2=11108&view=diff
==============================================================================
--- trunk/zypper/src/Command.h (original)
+++ trunk/zypper/src/Command.h Fri Sep 19 22:44:38 2008
@@ -59,6 +59,7 @@
// utils/others
static const ZypperCommand TARGET_OS;
static const ZypperCommand VERSION_CMP;
+ static const ZypperCommand LICENSES;
static const ZypperCommand HELP;
static const ZypperCommand SHELL;
@@ -126,6 +127,7 @@
TARGET_OS_e,
VERSION_CMP_e,
+ LICENSES_e,
HELP_e,
SHELL_e,
Modified: trunk/zypper/src/Zypper.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/Zypper.cc?rev=11108&r1=11107&r2=11108&view=diff
==============================================================================
--- trunk/zypper/src/Zypper.cc (original)
+++ trunk/zypper/src/Zypper.cc Fri Sep 19 22:44:38 2008
@@ -239,6 +239,7 @@
static string help_other_commands = _("\tOther Commands:\n"
"\tversioncmp, vcmp\tCompare two version strings.\n"
"\ttargetos, tos\t\tPrint the target operating system ID string.\n"
+ "\tlicenses\t\tPrint report about licenses and EULAs of installed packages.\n"
);
static string help_usage = _(
@@ -1949,6 +1950,24 @@
break;
}
+ case ZypperCommand::LICENSES_e:
+ {
+ static struct option options[] =
+ {
+ {"help", no_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+ specific_options = options;
+ _command_help = _(
+ "licenses\n"
+ "\n"
+ "Report Licenses and EULA of currently installed software packages.\n"
+ "\n"
+ "This command has no additional options.\n"
+ );
+ break;
+ }
+
case ZypperCommand::SHELL_QUIT_e:
{
static struct option quit_options[] = {
@@ -3002,10 +3021,10 @@
if (command() == ZypperCommand::RUG_PATCH_SEARCH)
_gopts.is_rug_compatible = true;
- zypp::PoolQuery query;
-
if (runningHelp()) { out().info(_command_help, Out::QUIET); return; }
+ zypp::PoolQuery query;
+
TriBool inst_notinst = indeterminate;
if (globalOpts().disable_system_resolvables || copts.count("uninstalled-only"))
{
@@ -3698,6 +3717,31 @@
break;
}
+ case ZypperCommand::LICENSES_e:
+ {
+ if (runningHelp()) { out().info(_command_help, Out::QUIET); return; }
+
+ if (!_arguments.empty())
+ {
+ report_too_many_arguments(_command_help);
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
+
+ init_repos(*this);
+ if (exitCode() != ZYPPER_EXIT_OK)
+ return;
+ init_target(*this);
+ // now load resolvables:
+ load_resolvables(*this);
+ // needed to compute status of PPP
+ resolve(*this);
+
+ report_licenses(*this);
+
+ break;
+ }
+
// -----------------------------( shell )------------------------------------
case ZypperCommand::SHELL_QUIT_e:
Modified: trunk/zypper/src/misc.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/misc.cc?rev=11108&r1=11107&r2=11108&view=diff
==============================================================================
--- trunk/zypper/src/misc.cc (original)
+++ trunk/zypper/src/misc.cc Fri Sep 19 22:44:38 2008
@@ -5,6 +5,7 @@
|__/|_| |_|
\*---------------------------------------------------------------------------*/
+#include <iostream>
#include <sstream>
#include