Author: jkupec Date: Fri Apr 18 14:52:13 2008 New Revision: 9700 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9700&view=rev Log: - 'mount' command added (rug compatibility alias for 'zypper addrepo -t plaindir <localpath>') (fate #302148) - --name option added to addrepo command to be able to set repo name - 'service-types' command (rug compatibility) - lists available service types (hardcoded) (fate #302148) - clean-cache, cc, you-clean-cache, yc aliases for rug (fate #302148) Modified: trunk/zypper/src/zypper-command.cc trunk/zypper/src/zypper-command.h trunk/zypper/src/zypper-repos.cc trunk/zypper/src/zypper-utils.cc trunk/zypper/src/zypper.cc Modified: trunk/zypper/src/zypper-command.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.cc?rev=9700&r1=9699&r2=9700&view=diff ============================================================================== --- trunk/zypper/src/zypper-command.cc (original) +++ trunk/zypper/src/zypper-command.cc Fri Apr 18 14:52:13 2008 @@ -57,6 +57,8 @@ const ZypperCommand ZypperCommand::RUG_PATCH_INFO(ZypperCommand::RUG_PATCH_INFO_e); const ZypperCommand ZypperCommand::RUG_PATTERN_INFO(ZypperCommand::RUG_PATTERN_INFO_e); const ZypperCommand ZypperCommand::RUG_PRODUCT_INFO(ZypperCommand::RUG_PRODUCT_INFO_e); +const ZypperCommand ZypperCommand::RUG_SERVICE_TYPES(ZypperCommand::RUG_SERVICE_TYPES_e); +const ZypperCommand ZypperCommand::RUG_MOUNT(ZypperCommand::RUG_MOUNT_e); ZypperCommand::ZypperCommand(const std::string & strval_r) : _command(parse(strval_r)) @@ -73,7 +75,7 @@ _table["modifyrepo"]= _table["mr"] = _table["service-modify"] = _table["sm"] = ZypperCommand::MODIFY_REPO_e; _table["repos"] = _table["lr"] = _table["service-list"] = _table["sl"] = ZypperCommand::LIST_REPOS_e; _table["refresh"] = _table["ref"] = ZypperCommand::REFRESH_e; - _table["clean"] = ZypperCommand::CLEAN_e; + _table["clean"] = _table["clean-cache"] = _table["cc"] = _table["you-clean-cache"] = _table["yc"] = ZypperCommand::CLEAN_e; _table["install"] = _table["in"] = ZypperCommand::INSTALL_e; _table["remove"] = _table["rm"] = ZypperCommand::REMOVE_e; @@ -110,6 +112,8 @@ _table["patch-info"] = ZypperCommand::RUG_PATCH_INFO_e; _table["pattern-info"] = ZypperCommand::RUG_PATTERN_INFO_e; _table["product-info"] = ZypperCommand::RUG_PRODUCT_INFO_e; + _table["service-types"] = _table["st"] = ZypperCommand::RUG_SERVICE_TYPES_e; + _table["mount"] = ZypperCommand::RUG_MOUNT_e; } std::mapstd::string,ZypperCommand::Command::const_iterator it Modified: trunk/zypper/src/zypper-command.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-command.h?rev=9700&r1=9699&r2=9700&view=diff ============================================================================== --- trunk/zypper/src/zypper-command.h (original) +++ trunk/zypper/src/zypper-command.h Fri Apr 18 14:52:13 2008 @@ -55,6 +55,8 @@ static const ZypperCommand RUG_PATCH_INFO; static const ZypperCommand RUG_PATTERN_INFO; static const ZypperCommand RUG_PRODUCT_INFO; + static const ZypperCommand RUG_SERVICE_TYPES; + static const ZypperCommand RUG_MOUNT; //!@} enum Command @@ -100,7 +102,9 @@ RUG_PATCH_INFO_e, RUG_PATTERN_INFO_e, - RUG_PRODUCT_INFO_e + RUG_PRODUCT_INFO_e, + RUG_SERVICE_TYPES_e, + RUG_MOUNT_e }; ZypperCommand(Command command) : _command(command) {} Modified: trunk/zypper/src/zypper-repos.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-repos.cc?rev=9700&r1=9699&r2=9700&view=diff ============================================================================== --- trunk/zypper/src/zypper-repos.cc (original) +++ trunk/zypper/src/zypper-repos.cc Fri Apr 18 14:52:13 2008 @@ -1302,6 +1302,9 @@ repo.setType(RepoType(type)); repo.setAlias(alias.empty() ? timestamp() : alias); + parsed_opts::const_iterator it = zypper.cOpts().find("name"); + if (it != zypper.cOpts().end()) + repo.setName(it->second.front()); repo.addBaseUrl(url); if ( !indeterminate(enabled) ) Modified: trunk/zypper/src/zypper-utils.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-utils.cc?rev=9700&r1=9699&r2=9700&view=diff ============================================================================== --- trunk/zypper/src/zypper-utils.cc (original) +++ trunk/zypper/src/zypper-utils.cc Fri Apr 18 14:52:13 2008 @@ -206,10 +206,15 @@ if (PathInfo(path).isExist()) { urlstr = "dir:" + url::encode(path.absolutename().asString(),"/"); - DBG << "resulting url: " << urlstr << endl; + MIL << "resulting url: " << urlstr << endl; } else - DBG << "specified local path does not exist or is not accessible" << endl; + { + Zypper::instance()->out().error( + _("Specified local path does not exist or is not accessible.")); + ERR << "specified local path does not exist or is not accessible" << endl; + return u; + } } try { Modified: trunk/zypper/src/zypper.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper.cc?rev=9700&r1=9699&r2=9700&view=diff ============================================================================== --- trunk/zypper/src/zypper.cc (original) +++ trunk/zypper/src/zypper.cc Fri Apr 18 14:52:13 2008 @@ -940,6 +940,7 @@ {"help", no_argument, 0, 'h'}, {"check", no_argument, 0, 'c'}, {"no-check", no_argument, 0, 'x'}, + {"name", no_argument, 0, 'n'}, {0, 0, 0, 0} }; specific_options = service_add_options; @@ -956,7 +957,8 @@ "-t, --type <TYPE> Type of repository (%s).\n" "-d, --disable Add the repository as disabled.\n" "-c, --check Probe URI.\n" - "-x, --no-check Don't probe URI, probe later during refresh.\n" + "-x, --no-check Don't probe URI, probe later during refresh.\n" + "-n, --name Specify descriptive name for the repository.\n" ), "yast2, rpm-md, plaindir"); break; } @@ -1681,6 +1683,48 @@ break; } + case ZypperCommand::RUG_SERVICE_TYPES_e: + { + static struct option options[] = { + {"help", no_argument, 0, 'h'}, + {0, 0, 0, 0} + }; + specific_options = options; + _command_help = _( + "service-types\n" + "\n" + "List available service types.\n" + ); + break; + } + + case ZypperCommand::RUG_MOUNT_e: + { + static struct option options[] = { + {"alias", required_argument, 0, 'a'}, + {"name", required_argument, 0, 'n'}, + // dummy for now - always recurse + {"recurse", required_argument, 0, 'r'}, + {"help", no_argument, 0, 'h'}, + {0, 0, 0, 0} + }; + specific_options = options; + _command_help = _( + // trunslators: this is a rug-compatibility command (equivalent of + // 'zypper addrepo -t plaindir URI'). You can refer to rug's translations + // for how to translate specific terms like channel or service if in doubt. + "mount\n" + "\n" + "Mount directory with RPMs as a channel.\n" + "\n" + " Command options:\n" + "-a, --alias <alias> Use given string as service alias.\n" + "-n, --name <name> Use given string as service name.\n" + "-r, --recurse Dive into subdirectories.\n" + ); + break; + } + default: { if (runningHelp()) @@ -1779,8 +1823,9 @@ } // --------------------------( addrepo )------------------------------------ - + case ZypperCommand::ADD_REPO_e: + case ZypperCommand::RUG_MOUNT_e: { if (runningHelp()) { out().info(_command_help, Out::QUIET); return; } @@ -1818,10 +1863,14 @@ // force specific repository type. Validation is done in add_repo_by_url() string type = copts.count("type") ? copts["type"].front() : ""; - - // display help message if insufficient info was given + if (command() == ZypperCommand::RUG_MOUNT || type == "mount") + type = "plaindir"; + else if (type == "zypp") + type = ""; + switch (_arguments.size()) { + // display help message if insufficient info was given case 0: out().error(_("Too few arguments.")); ERR << "Too few arguments." << endl; @@ -1829,17 +1878,35 @@ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS); return; case 1: - if( !isRepoFile(_arguments[0] )) + if (command() == ZypperCommand::RUG_MOUNT) + { + string alias; + parsed_opts::const_iterator it = _copts.find("alias"); + if (it != _copts.end()) + alias = it->second.front(); + // get the last component of the path + if (alias.empty()) + { + Pathname path(_arguments[0]); + alias = path.basename(); + } + _arguments.push_back(alias); + // continue to case 2: + } + else if( !isRepoFile(_arguments[0] )) { out().error( _("If only one argument is used, it must be a URI pointing to a .repo file.")); - ERR << "Not repo file." << endl; + ERR << "Not a repo file." << endl; out().info(_command_help); setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS); return; } - add_repo_from_file(*this,_arguments[0], enabled); - break; + else + { + add_repo_from_file(*this,_arguments[0], enabled); + break; + } case 2: Url url = make_url (_arguments[0]); if (!url.isValid()) @@ -2925,6 +2992,27 @@ break; } + case ZypperCommand::RUG_SERVICE_TYPES_e: + { + if (runningHelp()) { out().info(_command_help, Out::QUIET); return; } + + Table t; + + TableHeader th; + th << _("Alias") << _("Name") << _("Description"); + t << th; + + { TableRow tr; tr << "yum" << "YUM" << "YUM server service"; t << tr; } // rpm-md + { TableRow tr; tr << "yast" << "YaST2" << "YaST2 repository"; t << tr; } + { TableRow tr; tr << "zypp" << "ZYPP" << "ZYpp installation repository"; t << tr; } + { TableRow tr; tr << "mount" << "Mount" << "Mount a directory of RPMs"; t << tr; } + { TableRow tr; tr << "plaindir" << "Plaindir" << "Mount a directory of RPMs"; t << tr; } + + cout << t; + + break; + } + default: // if the program reaches this line, something went wrong setExitCode(ZYPPER_EXIT_ERR_BUG); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org