.TP
.I \-r, \-\-repo <alias|name|#|URI>
Restrict the lock to the specified repository.
+.TP
+.I \-t, \-\-type <type>
+Restrict the lock to packages of specified type (default: package).
+See section \fBPackage Types\fR for list
+of available package types.
+
.TP
.B cleanlocks (cl)
{
static struct option options[] =
{
+ {"type", required_argument, 0, 't'},
{"repo", required_argument, 0, 'r'},
// rug compatiblity (although rug does not seem to support this)
{"catalog", required_argument, 0, 'c'},
"\n"
" Command options:\n"
"-r, --repo <alias|#|URI> Remove only locks with specified repository.\n"
- ), "zypper locks");
+ "-t, --type <type> Type of package (%s).\n"
+ " Default: %s.\n"
+ ), "zypper locks", "package, patch, pattern, product", "package");
break;
}
return;
}
- if (_arguments.size() < 1)
+ if (_arguments.empty())
{
report_required_arg_missing(out(), _command_help);
setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
return;
}
- initRepoManager();
- init_target(*this);
- init_repos(*this);
- if (exitCode() != ZYPPER_EXIT_OK)
- return;
- load_resolvables(*this);
+ ResKindSet kinds;
+ if (copts.count("type"))
+ {
+ std::list<std::string>::const_iterator it;
+ for (it = copts["type"].begin(); it != copts["type"].end(); ++it)
+ {
+ kind = string_to_kind( *it );
+ if (kind == ResObject::Kind())
+ {
+ out().error(boost::str(format(
+ _("Unknown package type '%s'.")) % *it));
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
+ kinds.insert(kind);
+ }
+ }
+ //else
+ // let remove_locks determine the appropriate type
- remove_locks(*this, _arguments);
+ remove_locks(*this, _arguments, kinds);
break;
}
void add_locks(Zypper & zypper, const Zypper::ArgList & args, const ResKindSet & kinds)
{
- Locks::size_type start = 0;
try
{
Locks & locks = Locks::instance();
locks.read(Pathname::assertprefix
(zypper.globalOpts().root_dir, ZConfig::instance().locksFile()));
- start = locks.size();
+ Locks::size_type start = locks.size();
for_(it,args.begin(),args.end())
{
PoolQuery q;
}
-void remove_locks(Zypper & zypper, const Zypper::ArgList & args)
+void remove_locks(Zypper & zypper, const Zypper::ArgList & args, const ResKindSet & kinds)
{
try
{
//TODO fill query in one method to have consistent add/remove
//TODO what to do with repo and kinds?
PoolQuery q;
- // derive kind from the name: (rl should also support -t)
- sat::Solvable::SplitIdent split( *args_it );
- q.addAttribute( sat::SolvAttr::name, split.name().asString() );
- q.addKind( split.kind() );
- q.setMatchGlob();
+ if ( kinds.empty() ) // derive it from the name
+ {
+ // derive kind from the name: (rl should also support -t)
+ sat::Solvable::SplitIdent split( *args_it );
+ q.addAttribute( sat::SolvAttr::name, split.name().asString() );
+ q.addKind( split.kind() );
+ }
+ else
+ {
+ q.addAttribute(sat::SolvAttr::name, *args_it);
+ for_(itk, kinds.begin(), kinds.end()) {
+ q.addKind(*itk);
+ }
+ }
+ q.setMatchGlob();
parsed_opts::const_iterator itr;
if ((itr = copts.find("repo")) != copts.end())
{
void list_locks(Zypper & zypper);
void add_locks(Zypper & zypper, const Zypper::ArgList & args, const ResKindSet & kinds);
-void remove_locks(Zypper & zypper, const Zypper::ArgList & args);
+void remove_locks(Zypper & zypper, const Zypper::ArgList & args, const ResKindSet & kinds);
#endif /*ZYPPERLOCKS_H_*/