.B repos (lr)
List all defined repositories.
.IP
-Following data are printed for each source found: Enabled (whether the source is enabled), Refresh (whether autorefresh is enabled for the source), Type (YaST, YUM, ...), Name, and URI.
-.IP
-rug compatibility mode: if \fI-r\fR global option is set, zypper doesn't include 'Enabled' and 'Refresh' columns and prints rug's 'Status' column with values "Active" or "Disabled" instead.
+Following data are printed for each repository found: Enabled (whether the repository is enabled), Refresh (whether autorefresh is enabled for the repository), Type (YaST, YUM, Plaindir), Name, and URI.
+.TP
+.I \-e, \-\-export <FILE|->
+This option causes zypper to write repository definition of all defined
+repositories into a single file in repo file format.
+If '\-' is specified instead of a file name,
+the repositories will be written to the standard output.
.TP
.B renamerepo (nr) <alias> <new-alias>
Specifies table style to use. Table style is identified by an integer number. TODO
.TP
.I \-r, \-\-rug\-compatible
-Turns on rug compatibility. See compatibility notes next to affected commands.
+Turns on rug compatibility. See section COMPATIBILITY WITH RUG for details.
.TP
.I \-n, \-\-non\-interactive
Switches to non-interactive mode. In this mode zypper doesn't ask user to type answers to various prompts, but uses default answers automatically. The behaviour of this option is somewhat different than that of options like '--yes', since zypper can answer different answers to different questions. The answers also depend on other options like '--no-gpg-checks'.
.SH "COMPATIBILITY WITH RUG"
.LP
zypper is designed to be compatible with rug, which is a command\-line interface to the ZENworks Linux Management (ZLM) agent. Compared to rug, zypper does not need the ZLM daemon to run, and is intented to provide more and improved functionality. Following is a list of zypper-rug command aliases, supported rug command line options, and compatibility notes. See also compatibility notes in descriptions of zypper commands.
+.LP
+To enable rug compatible behaviour, use the \-r or \-\-rug\-compatible global option with each command.
-.LP
.SS Service Management Commands
.LP
ZENworks distinguishes services and catalogs. A service is
.I rug service-list (sl)
zypper repos (lr)
+.IP
+ zypper doesn't include 'Enabled' and 'Refresh' columns and prints rug's 'Status' column with values "Active" or "Disabled" instead.
+
+
.SS Package Management Commands
.TP
// ----------------------------------------------------------------------------
+void print_repos_to(const std::list<zypp::RepoInfo> &repos, ostream & out)
+{
+ for (std::list<RepoInfo>::const_iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ it->dumpRepoOn(out);
+ out << endl;
+ }
+}
+
+// ----------------------------------------------------------------------------
+
void list_repos()
{
RepoManager manager;
exit(ZYPPER_EXIT_ERR_ZYPP);
}
- print_repo_list(repos);
+ // export to file or stdout in repo file format
+ if (copts.count("export"))
+ {
+ string filename_str = copts["export"].front();
+ if (filename_str == "-")
+ {
+ print_repos_to(repos, cout);
+ }
+ else
+ {
+ if (filename_str.rfind(".repo") == string::npos)
+ filename_str += ".repo";
+
+ Pathname file(filename_str);
+ std::ofstream stream(file.c_str());
+ if (!stream)
+ {
+ cerr << format(_("Can't open %s for writing. Maybe you don't have write permissions?"))
+ % file.asString() << endl;
+ exit(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ }
+ else
+ {
+ print_repos_to(repos, stream);
+ cout << format(
+ _("Repositories have been successfully exported to %s."))
+ % (file.absolute() ? file.asString() : file.asString().substr(2))
+ << endl;
+ }
+ }
+ }
+ // print repo list as table
+ else
+ print_repo_list(repos);
}
// ----------------------------------------------------------------------------
#include <boost/logic/tribool.hpp>
#include <zypp/base/Logger.h>
-#include <zypp/zypp_detail/ZYppReadOnlyHack.h>
#include <zypp/repo/RepoException.h>
#include "zypper.h"
}
else if (command == ZypperCommand::LIST_REPOS) {
static struct option service_list_options[] = {
+ {"export", required_argument, 0, 'e'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
"\n"
"List all defined repositories.\n"
"\n"
- "This command has no additional options.\n"
+ " Command options:\n"
+ "-e, --export <FILE.repo> Export all defined repositories as a single local .repo file\n"
);
}
else if (command == ZypperCommand::REMOVE_REPO) {
// here come commands that need the lock
try {
- if (command == ZypperCommand::LIST_REPOS)
- zypp_readonly_hack::IWantIt (); // #247001
+// if (command == ZypperCommand::LIST_REPOS)
+// zypp_readonly_hack::IWantIt (); // #247001
God = zypp::getZYpp();
}