Mailinglist Archive: zypp-commit (545 mails)

< Previous Next >
[zypp-commit] r8447 - in /branches/tmp/ma/jump_sat/zypper: ./ doc/ package/ src/
  • From: dmacvicar@xxxxxxxxxxxxxxxx
  • Date: Sat, 02 Feb 2008 22:26:11 -0000
  • Message-id: <20080202222611.5D24026D92@xxxxxxxxxxxxxxxx>
Author: dmacvicar
Date: Sat Feb 2 23:26:10 2008
New Revision: 8447

URL: http://svn.opensuse.org/viewcvs/zypp?rev=8447&view=rev
Log:
- merge trunk rev 8446

Modified:
branches/tmp/ma/jump_sat/zypper/CMakeLists.txt
branches/tmp/ma/jump_sat/zypper/VERSION.cmake
branches/tmp/ma/jump_sat/zypper/doc/zypper.8
branches/tmp/ma/jump_sat/zypper/package/zypper.changes
branches/tmp/ma/jump_sat/zypper/src/CMakeLists.txt
branches/tmp/ma/jump_sat/zypper/src/zypper-misc.cc
branches/tmp/ma/jump_sat/zypper/src/zypper-repos.cc
branches/tmp/ma/jump_sat/zypper/src/zypper-repos.h
branches/tmp/ma/jump_sat/zypper/src/zypper-utils.cc
branches/tmp/ma/jump_sat/zypper/src/zypper-utils.h
branches/tmp/ma/jump_sat/zypper/src/zypper.cc
branches/tmp/ma/jump_sat/zypper/src/zypper.h

Modified: branches/tmp/ma/jump_sat/zypper/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/CMakeLists.txt?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/zypper/CMakeLists.txt Sat Feb 2 23:26:10 2008
@@ -20,21 +20,16 @@
# system configuration dir (etc)

IF( NOT DEFINED SYSCONFDIR )
- IF ( ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" )
- # if installing in usr, set sysconfg to etc
SET( SYSCONFDIR /etc )
- ELSE ( ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" )
- SET ( SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc" )
- ENDIF ( ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" )
ENDIF( NOT DEFINED SYSCONFDIR )
-MESSAGE(STATUS "Config files will be installed in ${SYSCONFDIR}" )
+MESSAGE( "** Config files will be installed in ${SYSCONFDIR}" )

# system configuration dir (etc)

IF( NOT DEFINED MANDIR )
- SET( MANDIR ${CMAKE_INSTALL_PREFIX}/share/man )
+ SET( MANDIR ${INSTALL_PREFIX}/share/man )
ENDIF( NOT DEFINED MANDIR )
-
+MESSAGE( "** Manual files will be installed in ${MANDIR}" )

# PACKAGE


Modified: branches/tmp/ma/jump_sat/zypper/VERSION.cmake
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/VERSION.cmake?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/VERSION.cmake (original)
+++ branches/tmp/ma/jump_sat/zypper/VERSION.cmake Sat Feb 2 23:26:10 2008
@@ -20,4 +20,4 @@

SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "9")
-SET(VERSION_PATCH "4")
+SET(VERSION_PATCH "6")

Modified: branches/tmp/ma/jump_sat/zypper/doc/zypper.8
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/doc/zypper.8?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/doc/zypper.8 (original)
+++ branches/tmp/ma/jump_sat/zypper/doc/zypper.8 Sat Feb 2 23:26:10 2008
@@ -1,4 +1,4 @@
-.TH "zypper" "8" "0.9.4" "zypper" "System Tools"
+.TH "zypper" "8" "0.9.6" "zypper" "System Tools"
.SH "SYNTAX"
.LP
zypper [\fI\-\-global\-options\fR] <\fBcommand\fR>
[\fI\-\-command\-options\fR] [\fBcommand-arguments\fR]
@@ -57,9 +57,9 @@
the info command are: package, patch, pattern, product.

.TP
-.B install (in) [options] <name> ...
+.B install (in) [options] <name|rpm_file_uri> ...
.TP
-.B install (in) [options] --capability <capability> ...
+.B install (in) [options] --capability <capability|rpm_file_uri> ...
Install or update packages or other resolvables.

The resolvables can be selected by their name or by a capability they provide.
@@ -74,7 +74,18 @@

If EDITION is not specified, the newest available version will be installed.
This also means that if the package is already installed and newer versions
-are available, it will get upgraded to the newest one.
+are available, it will get upgraded to the newest one.
+
+Zypper is also able to install plain RPM files while trying to satisfy their
+dependencies using packages from defined repositories. You can install a plain
+RPM file by specifying its location in the install command arguments either
+as a local path or an URI. E.g.:
+
+\fB$ zypper install ~/rpms/foo.rpm http://some.site/bar.rpm\fR
+
+Zypper will download the files into its cache directory
(/var/cache/zypper/RPMS),
+add this directory as a temporary \fBplaindir\fR repository and mark the
+respective resolvables for installation.

.TP
\fI\-r, \-\-repo\fR <alias>
@@ -111,6 +122,10 @@

The default value is 'on' in the interactive mode and 'off' in the
non-interactive mode. If this option is specified, it takes the preference.
+.TP
+.I \-D, \-\-dry\-run
+Test the installation, do not actually install any package. This option will
+add the \-\-test option to the rpm commands run by the install command.

.TP
.B source-install (si) <name> ...
@@ -159,6 +174,10 @@
.I \-R, \-\-force\-resolution
Force the solver to find a solution, even if it would mean removing all
packages
with unfulfilled requirements.
+.TP
+.I \-D, \-\-dry\-run
+Test the removal of packages, do not actually remove anything. This option will
+add the \-\-test option to the rpm commands run by the remove command.

.TP
.B update (up) [options]
@@ -187,6 +206,10 @@
.I \-R, \-\-force\-resolution
Force the solver to find a solution, even if it would mean removing all
packages
with unfulfilled requirements.
+.TP
+.I \-D, \-\-dry\-run
+Test the update, do not actually install or update any package. This option
will
+add the \-\-test option to the rpm commands run by the update command.

.B NOTE:
Zypper prefers to update only those packages for which a patch
@@ -209,7 +232,10 @@
.TP
.I \-\-debug\-solver
Create solver test case for debugging. See the install command for details.
-
+.TP
+.I \-D, \-\-dry\-run
+Test the upgrade, do not actually install or update any package. This option
will
+add the \-\-test option to the rpm commands run by the dist-upgrade command.

.TP
\fBsearch\fR (\fBse\fR) [\fIoptions\fR] [\fBquerystring\fR] ...
@@ -403,28 +429,54 @@
.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'.
.TP
-.I \-\-no\-gpg\-checks
-Ignore GPG check failures and continue. If a GPG issue occurs when using this
option zypper prints and logs a warning and automatically continues without
interrupting the operation. Use this option with causion, as you can easily
overlook security problems by using it.
-.TP
-.I \-R, \-\-root <dir>
-Operates on a different root directory. This option influences the location
-of the repos.d directory and the meta-data cache directory and also causes rpm
-to be run with the --root option to do the actual installation or removal of
-packages. Note that the ZYpp lock is still created in the original system,
-as well as temporary files. See also the FILES section.
-
-.TP
.I \-D, \-\-reposd\-dir <dir>
Use the specified directory to look for the repository definition (*.repo)
files.
The default value is /etc/zypp/repos.d.
.TP
-.I \-D, \-\-cache\-dir <dir>
+.I \-C, \-\-cache\-dir <dir>
Use an alternative directory to look for the repository meta-data cache
database file (zypp.db).
The default value is /var/cache/zypp.
.TP
-.I \-D, \-\-raw\-cache\-dir <dir>
+.I \-\-raw\-cache\-dir <dir>
Use the specified directory for storing raw copies of repository meta-data
files.
The default value is /var/cache/zypp/raw.
+.LP
+Repository Options:
+.TP
+.I \-\-no\-gpg\-checks
+Ignore GPG check failures and continue. If a GPG issue occurs when using this
+option zypper prints and logs a warning and automatically continues without
+interrupting the operation. Use this option with causion, as you can easily
+overlook security problems by using it.
+.TP
+.I \-p, \-\-plus\-repo <URI>
+Use an additional repository for this operation. The repository aliased tmp#
+and named by the specified URI will be added for this operation and removed
+at the end. You can specify this option multiple times.
+.TP
+.I \-\-disable\-repositories
+Do not read meta-data from repositories. This option will prevent loading of
+resolvables from repositories, thus making zypper work only with the installed
+resolvables (if \-\-disable\-system\-resolvables was not specified).
+.TP
+.I \-\-no\-refresh
+Do not auto-refresh repositories (ignore the autorefresh setting). Useful to
save
+time when doing operations like search, if there is not a need to have
+a completely up to date meta-data.
+.LP
+Target Options:
+.TP
+.I \-R, \-\-root <dir>
+Operates on a different root directory. This option influences the location
+of the repos.d directory and the meta-data cache directory and also causes rpm
+to be run with the --root option to do the actual installation or removal of
+packages. Note that the ZYpp lock is still created in the original system,
+as well as temporary files. See also the FILES section.
+.TP
+.I \-\-disable\-system\-resolvables
+This option servers mainly for testing purposes. It will cause zypper to act
+as if there were no packages installed in the system. Use with causion as you
+can damage your system using this option.

.SH "METADATA REFRESH POLICY"
.LP

Modified: branches/tmp/ma/jump_sat/zypper/package/zypper.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/package/zypper.changes?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/package/zypper.changes (original)
+++ branches/tmp/ma/jump_sat/zypper/package/zypper.changes Sat Feb 2 23:26:10
2008
@@ -1,4 +1,47 @@
-------------------------------------------------------------------
+Fri Feb 1 18:25:17 CET 2008 - jkupec@xxxxxxx
+
+- --no-refresh global option added (bnc #356741)
+- fixed renaming to an existing alias (bnc #228216)
+- r8436
+- 0.9.6
+
+-------------------------------------------------------------------
+Thu Jan 31 13:17:57 CET 2008 - jkupec@xxxxxxx
+
+- fixed zypper help shell (bnc #357262)
+- r8419
+
+-------------------------------------------------------------------
+Thu Jan 17 14:22:56 CET 2008 - jkupec@xxxxxxx
+
+- --dry-run for in, rm, up, and dup (bnc #350736)
+- r8306:8311
+
+-------------------------------------------------------------------
+Mon Jan 14 16:14:22 CET 2008 - jkupec@xxxxxxx
+
+- ability to install plain RPM files whose locations are specified
+ in the install command arguments (FATE #302151, bug #230223).
+- r8261:8274
+- 0.9.5
+
+-------------------------------------------------------------------
+Wed Jan 9 17:51:20 CET 2008 - jkupec@xxxxxxx
+
+- support # and URI as well as alias in --repo (#298312)
+- multiple --repo allowed now in all commands supporting the option
+- --repo for refresh (less surprises for users)
+- r8249:8250
+
+-------------------------------------------------------------------
+Fri Jan 4 12:54:19 CET 2008 - jkupec@xxxxxxx
+
+- new global options: --plus-repo, --disable-repositories,
+ --disable-system-resolvables (#224886)
+- r8195
+
+-------------------------------------------------------------------
Tue Dec 11 17:45:41 CET 2007 - jkupec@xxxxxxx

- product and pattern (#266896) support added to the info command

Modified: branches/tmp/ma/jump_sat/zypper/src/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/CMakeLists.txt?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/CMakeLists.txt (original)
+++ branches/tmp/ma/jump_sat/zypper/src/CMakeLists.txt Sat Feb 2 23:26:10 2008
@@ -1,8 +1,10 @@
ADD_DEFINITIONS (
-DPACKAGE=\\\"${PACKAGE}\\\"
- -DLOCALEDIR=\\\"${CMAKE_INSTALL_PREFIX}/share/locale\\\"
+ -DLOCALEDIR=\\\"${INSTALL_PREFIX}/share/locale\\\"
)

+MESSAGE ( "** Locale dir is ${INSTALL_PREFIX}/share/locale" )
+
SET (zypper_HEADERS
zypper.h
zypper-main.h
@@ -46,6 +48,8 @@
RUNTIME DESTINATION ${INSTALL_PREFIX}/bin
)

+MESSAGE ( "** ZYpper binary will be installed in ${INSTALL_PREFIX}/bin" )
+
ADD_EXECUTABLE( zypp-checkpatches zypp-checkpatches.cc zypper-updates.cc )
TARGET_LINK_LIBRARIES( zypp-checkpatches ${ZYPP_LIBRARY} )

@@ -63,7 +67,7 @@
)


-# logrotate config file
+# installation_sources script
INSTALL(
PROGRAMS installation_sources
DESTINATION ${INSTALL_PREFIX}/bin

Modified: branches/tmp/ma/jump_sat/zypper/src/zypper-misc.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/zypper-misc.cc?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/zypper-misc.cc (original)
+++ branches/tmp/ma/jump_sat/zypper/src/zypper-misc.cc Sat Feb 2 23:26:10 2008
@@ -578,7 +578,7 @@
return retry;
}

-typedef map<KindOf<Resolvable>,set<ResObject::constPtr> > KindToResObjectSet;
+typedef map<Resolvable::Kind,set<ResObject::constPtr> > KindToResObjectSet;

void show_summary_resolvable_list(const string & label,
KindToResObjectSet::const_iterator it,
@@ -932,7 +932,7 @@
God->resolver()->setForceResolve( force_resolution );

cout_v << _("Resolving dependencies...") << endl;
- DBG << "Calling the solver..." << endl;
+ DBG << "Calling the solver..." << endl;
return God->resolver()->resolvePool();
}

@@ -1505,16 +1505,30 @@

if (!confirm_licenses(zypper)) return;

- cerr_v << _("committing") << endl;
- MIL << "committing..." << endl;
-
try {
//! \todo fix the media reporting correctly
gData.show_media_progress_hack = true;

- ZYppCommitResult result = God->commit(
+ cerr_v << _("committing"); MIL << "committing...";
+
+ ZYppCommitResult result;
+ if (copts.count("dry-run"))
+ {
+ cerr_v << " " << _("(dry run)") << endl; MIL << "(dry run)";
+
+ result = God->commit(ZYppCommitPolicy().dryRun(true));
+ }
+ else
+ {
+ cerr_v << endl; // endl after 'committing'
+
+ result = God->commit(
ZYppCommitPolicy().syncPoolAfterCommit(zypper.runningShell()));
- was_installed = true;
+
+ was_installed = true;
+ }
+
+ MIL << endl << "DONE" << endl;

gData.show_media_progress_hack = false;

@@ -1527,7 +1541,7 @@
ZYPP_CAUGHT(e);
report_problem(e,
_("Problem downloading the package file from the repository:"),
- _("Please, see the above error message to for a hint."));
+ _("Please see the above error message to for a hint."));
zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
return;
}
@@ -1535,7 +1549,7 @@
ZYPP_CAUGHT(e);
report_problem(e,
_("Problem downloading the package file from the repository:"),
- _("Please, see the above error message to for a hint."));
+ _("Please see the above error message to for a hint."));
zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
return;
}
@@ -1566,7 +1580,7 @@
{
if (zypper.globalOpts().machine_readable)
cout << "<message type=\"warning\">" << _("One of installed patches
requires reboot of"
- " your machine. Please, do it as soon as possible.") <<
"</message>" << endl;
+ " your machine. Please do it as soon as possible.") <<
"</message>" << endl;
else
cout << _("WARNING: One of installed patches requires a reboot of"
" your machine. Please do it as soon as possible.") << endl;
@@ -1632,7 +1646,7 @@
" license(s) confirmation.") << " ";
// TranslatorExplanation Don't translate the
'--auto-agree-with-licenses',
// it is a command line option
- cout << _("Please, restart the operation in interactive"
+ cout << _("Please restart the operation in interactive"
" mode and confirm your agreement with required license(s),"
" or use the --auto-agree-with-licenses option.")
<< endl;

Modified: branches/tmp/ma/jump_sat/zypper/src/zypper-repos.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/zypper-repos.cc?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/zypper-repos.cc (original)
+++ branches/tmp/ma/jump_sat/zypper/src/zypper-repos.cc Sat Feb 2 23:26:10 2008
@@ -34,6 +34,18 @@
extern ZYpp::Ptr God;
extern RuntimeData gData;

+// ----------------------------------------------------------------------------
+
+template <typename Target, typename Source>
+void safe_lexical_cast (Source s, Target &tr) {
+ try {
+ tr = boost::lexical_cast<Target> (s);
+ }
+ catch (boost::bad_lexical_cast &) {
+ }
+}
+
+// ----------------------------------------------------------------------------

static bool refresh_raw_metadata(const Zypper & zypper,
const RepoInfo & repo,
@@ -91,7 +103,7 @@
{
report_problem(e,
boost::str(format(_("Problem downloading files from '%s'.")) %
repo.name()),
- _("Please, see the above error message to for a hint."));
+ _("Please see the above error message to for a hint."));

return true; // error
}
@@ -102,7 +114,7 @@
if (!repo.filepath().empty())
cerr << format(
// TranslatorExplanation the first %s is a .repo file path
- _("Please, add one or more base URL (baseurl=URL) entries to %s for
repository '%s'."))
+ _("Please add one or more base URL (baseurl=URL) entries to %s for
repository '%s'."))
% repo.filepath() % repo.name() << endl;

return true; // error
@@ -120,7 +132,7 @@
ZYPP_CAUGHT(e);
report_problem(e,
boost::str(format(_("Repository '%s' is invalid.")) % repo.name()),
- _("Please, check if the URLs defined for this repository are pointing
to a valid repository."));
+ _("Please check if the URLs defined for this repository are pointing
to a valid repository."));

return true; // error
}
@@ -205,6 +217,107 @@
// ---------------------------------------------------------------------------

/**
+ * Try to find RepoInfo counterparts among known repositories by alias, number,
+ * or URI, based on the list of strings given as the iterator range \a being
and
+ * \a end. Matching RepoInfos will be added to \a repos and those with no match
+ * will be added to \a not_found.
+ */
+template<typename T>
+void get_repos(Zypper & zypper,
+ const T & begin, const T & end,
+ list<RepoInfo> & repos, list<string> & not_found)
+{
+ RepoManager manager(zypper.globalOpts().rm_options);
+ list<RepoInfo> known = manager.knownRepositories();
+
+ for (T it = begin; it != end; ++it)
+ {
+ RepoInfo repo;
+
+ // can i find it by alias, #, or the url, in that order?
+ unsigned int number = 1; // repo number
+ for (list<RepoInfo>::const_iterator known_it = known.begin();
+ known_it != known.end(); ++known_it, number++)
+ {
+ unsigned int tmp = 0;
+ safe_lexical_cast (*it, tmp); // try to make an int out of the string
+
+ try
+ {
+ if (known_it->alias() == *it ||
+ tmp == number ||
+ find(known_it->baseUrlsBegin(),known_it->baseUrlsEnd(),Url(*it))
+ != known_it->baseUrlsEnd())
+ {
+ repo = *known_it;
+ break;
+ }
+ }
+ catch(const url::UrlException &){}
+ } // END for all known repos
+
+ // no match found
+ if (repo.alias().empty())
+ {
+ not_found.push_back(*it);
+ continue;
+ }
+
+ // repo found
+ // is it a duplicate? compare by alias and URIs
+ //! \todo operator== in RepoInfo?
+ bool duplicate = false;
+ for (list<RepoInfo>::const_iterator repo_it = repos.begin();
+ repo_it != repos.end(); ++repo_it)
+ {
+ bool equals = true;
+
+ // alias
+ if (repo_it->alias() != repo.alias())
+ equals = false;
+
+ if (equals)
+ {
+ // URIs (all of them)
+ for (RepoInfo::urls_const_iterator urlit = repo_it->baseUrlsBegin();
+ urlit != repo_it->baseUrlsEnd(); ++urlit)
+ try {
+ if (find(repo.baseUrlsBegin(),repo.baseUrlsEnd(),Url(*it))
+ != repo.baseUrlsEnd())
+ equals = false;
+ }
+ catch(const url::UrlException &){}
+ }
+
+ if (equals)
+ duplicate = true;
+ } // END for all found so far
+
+ if (!duplicate)
+ repos.push_back(repo);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
+/**
+ * Say "Repository %s not found" for all strings in \a not_found list.
+ */
+static void report_unknown_repos(list<string> not_found)
+{
+ for (list<string>::iterator it = not_found.begin();
+ it != not_found.end(); ++it)
+ cerr << format(_("Repository '%s' not found by its alias, number, or
URI."))
+ % *it << endl;
+
+ if (!not_found.empty())
+ cout_n << _("Use 'zypper repos' to get the list of defined repositories.")
+ << endl;
+}
+
+// ---------------------------------------------------------------------------
+
+/**
* Fill gData.repositories with active repos (enabled or specified) and refresh
* if autorefresh is on.
*/
@@ -216,38 +329,35 @@
cond_init_target(zypper);
RepoManager manager(zypper.globalOpts().rm_options);

- string specific_repo = copts.count("repo") ? copts["repo"].front() : "";
-
+ // get repositories specified with --repo or --catalog
+ list<string> not_found;
+ parsed_opts::const_iterator it;
+ if ((it = copts.find("repo")) != copts.end())
+ get_repos(zypper, it->second.begin(), it->second.end(), gData.repos,
not_found);
// rug compatibility
- //! \todo support repo #
- if (specific_repo.empty())
- specific_repo = copts.count("catalog") ? copts["catalog"].front() : "";
-
- if (!specific_repo.empty())
- {
- MIL << "--repo set to '" << specific_repo
- << "'. Going to operate on this repo only." << endl;
- try { gData.repos.push_back(manager.getRepositoryInfo(specific_repo)); }
- catch (const repo::RepoNotFoundException & ex)
- {
- cerr << format(_("Repository '%s' not found.")) % specific_repo << endl;
- ERR << specific_repo << " not found";
- zypper.setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
- return;
- }
- catch (const Exception & ex)
- {
- cerr << format(_("Error reading repository description file for '%s'."))
- % specific_repo << endl;
- cerr_v << _("Reason: ") << ex.asUserString() << endl;
- ZYPP_CAUGHT(ex);
- zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
- return;
- }
+ if ((it = copts.find("catalog")) != copts.end())
+ get_repos(zypper, it->second.begin(), it->second.end(), gData.repos,
not_found);
+ if (!not_found.empty())
+ {
+ report_unknown_repos(not_found);
+ zypper.setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
}
- else
+
+ // if no repository was specified on the command line, use all known repos
+ if (gData.repos.empty())
gData.repos = manager.knownRepositories();

+ // additional repositories (--plus-repo)
+ if (!gData.additional_repos.empty())
+ {
+ for (list<RepoInfo>::iterator it = gData.additional_repos.begin();
+ it != gData.additional_repos.end(); ++it)
+ {
+ add_repo(zypper, *it);
+ gData.repos.push_back(*it);
+ }
+ }

for (std::list<RepoInfo>::iterator it = gData.repos.begin();
it != gData.repos.end(); ++it)
@@ -255,8 +365,10 @@
RepoInfo repo(*it);
MIL << "checking if to refresh " << repo.name() << endl;

- //! \todo honor command line options/commands
- bool do_refresh = repo.enabled() && repo.autorefresh();
+ bool do_refresh =
+ repo.enabled() &&
+ repo.autorefresh() &&
+ !zypper.globalOpts().no_refresh;

if (do_refresh)
{
@@ -479,6 +591,12 @@
exit(ZYPPER_EXIT_ERR_ZYPP);
}

+ // add the additional repos specified with the --plus-repo to the list
+ if (!gData.additional_repos.empty())
+ repos.insert(repos.end(),
+ gData.additional_repos.begin(),
+ gData.additional_repos.end());
+
// export to file or stdout in repo file format
if (copts.count("export"))
{
@@ -520,22 +638,12 @@

// ----------------------------------------------------------------------------

-template <typename Target, typename Source>
-void safe_lexical_cast (Source s, Target &tr) {
- try {
- tr = boost::lexical_cast<Target> (s);
- }
- catch (boost::bad_lexical_cast &) {
- }
-}
-
-// ----------------------------------------------------------------------------
-
-int refresh_repos(Zypper & zypper, vector<string> & arguments)
+void refresh_repos(Zypper & zypper)
{
// need gpg keys when downloading (#304672)
cond_init_target(zypper);
RepoManager manager(zypper.globalOpts().rm_options);
+
list<RepoInfo> repos;
try
{
@@ -546,135 +654,125 @@
ZYPP_CAUGHT(e);
report_problem(e,
_("Error reading repositories:"));
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}

+ // get the list of repos specified on the command line ...
+ list<RepoInfo> specified;
+ list<string> not_found;
+ // ...as command arguments
+ get_repos(zypper, zypper.arguments().begin(), zypper.arguments().end(),
+ specified, not_found);
+ // ...as --repo options
+ parsed_opts::const_iterator tmp1;
+ if ((tmp1 = copts.find("repo")) != copts.end())
+ get_repos(zypper, tmp1->second.begin(), tmp1->second.end(), specified,
not_found);
+ report_unknown_repos(not_found);
+
+ cout_v << _("Specified repositories: ");
+ for (list<RepoInfo>::const_iterator it = specified.begin();
+ it != specified.end(); ++it)
+ cout_v << it->alias() << " ";
+ cout_v << endl;
+
unsigned error_count = 0;
unsigned enabled_repo_count = repos.size();
- unsigned repo_number = 0;
- unsigned argc = arguments.size();
- for (std::list<RepoInfo>::iterator it = repos.begin();
- it != repos.end(); ++it)
- {
- RepoInfo repo(*it);
- repo_number++;

- if (argc)
+ if (!specified.empty() || not_found.empty())
+ {
+ for (std::list<RepoInfo>::iterator it = repos.begin();
+ it != repos.end(); ++it)
{
- bool specified_found = false;
-
- // search for the repo alias among arguments
- for (vector<string>::iterator it = arguments.begin();
- it != arguments.end(); ++it)
- if ((*it) == repo.alias())
- {
- specified_found = true;
- arguments.erase(it);
- break;
- }
-
- // search for the repo number among arguments
- if (!specified_found)
- for (vector<string>::iterator it = arguments.begin();
- it != arguments.end(); ++it)
- {
- unsigned tmp = 0;
- safe_lexical_cast (*it, tmp);
- if (tmp == repo_number)
+ RepoInfo repo(*it);
+
+ if (!specified.empty())
+ {
+ bool found = false;
+ for (list<RepoInfo>::const_iterator it = specified.begin();
+ it != specified.end(); ++it)
+ if (it->alias() == repo.alias())
{
- specified_found = true;
- arguments.erase(it);
+ found = true;
break;
}
+
+ if (!found)
+ {
+ DBG << repo.alias() << "(#" << ") not specified,"
+ << " skipping." << endl;
+ enabled_repo_count--;
+ continue;
}
-
- if (!specified_found)
+ }
+
+ // skip disabled repos
+ if (!repo.enabled())
{
- DBG << repo.alias() << "(#" << repo_number << ") not specified,"
- << " skipping." << endl;
+ string msg = boost::str(
+ format(_("Skipping disabled repository '%s'")) % repo.name());
+
+ if (specified.empty())
+ cout_v << msg << endl;
+ else
+ cerr << msg << endl;
+
enabled_repo_count--;
continue;
}
- }
-
- // skip disabled repos
- if (!repo.enabled())
- {
- string msg = boost::str(
- format(_("Skipping disabled repository '%s'")) % repo.name());
-
- if (argc)
- cerr << msg << endl;
- else
- cout_v << msg << endl;
-
- enabled_repo_count--;
- continue;
- }
-
-
- // do the refresh
-
- // raw metadata refresh
- bool error = false;
- if (!copts.count("build-only"))
- {
- bool force_download =
- copts.count("force") || copts.count("force-download");
-
- // without this a cd is required to be present in the drive on each
refresh
- // (or more 'refresh needed' check)
- bool is_cd = is_changeable_media(*repo.baseUrlsBegin());
- if (!force_download && is_cd)
+
+ // do the refresh
+
+ // raw metadata refresh
+ bool error = false;
+ if (!copts.count("build-only"))
{
- MIL << "Skipping refresh of a changeable read-only media." << endl;
- continue;
+ bool force_download =
+ copts.count("force") || copts.count("force-download");
+
+ // without this a cd is required to be present in the drive on each
refresh
+ // (or more 'refresh needed' check)
+ bool is_cd = is_changeable_media(*repo.baseUrlsBegin());
+ if (!force_download && is_cd)
+ {
+ MIL << "Skipping refresh of a changeable read-only media." << endl;
+ continue;
+ }
+
+ MIL << "calling refreshMetadata" << (force_download ? ", forced" : "")
+ << endl;
+
+ error = refresh_raw_metadata(zypper, repo, force_download);
+ }
+
+ // db rebuild
+ if (!(error || copts.count("download-only")))
+ {
+ bool force_build =
+ copts.count("force") || copts.count("force-build");
+
+ MIL << "calling buildCache" << (force_build ? ", forced" : "") << endl;
+
+ error = build_cache(zypper, repo, force_build);
+ }
+
+ if (error)
+ {
+ cerr << format(_("Skipping repository '%s' because of the above
error."))
+ % repo.name() << endl;
+ ERR << format("Skipping repository '%s' because of the above error.")
+ % repo.name() << endl;
+ error_count++;
}
-
- MIL << "calling refreshMetadata" << (force_download ? ", forced" : "")
- << endl;
-
- error = refresh_raw_metadata(zypper, repo, force_download);
- }
-
- // db rebuild
- if (!(error || copts.count("download-only")))
- {
- bool force_build =
- copts.count("force") || copts.count("force-build");
-
- MIL << "calling buildCache" << (force_build ? ", forced" : "") << endl;
-
- error = build_cache(zypper, repo, force_build);
- }
-
- if (error)
- {
- cerr << format(_("Skipping repository '%s' because of the above error."))
- % repo.name() << endl;
- ERR << format("Skipping repository '%s' because of the above error.")
- % repo.name() << endl;
- error_count++;
}
}
-
- // the rest of arguments are those not found, complain to the user
- bool show_hint = arguments.size();
- for (vector<string>::iterator it = arguments.begin();
- it != arguments.end();)
- {
- cerr << format(_("Repository '%s' not found by its alias or number.")) %
*it
- << endl;
- it = arguments.erase(it);
- }
- if (show_hint)
- cout_n << _("Use 'zypper repos' to get the list of defined repositories.")
- << endl;
+ else
+ enabled_repo_count = 0;

// print the result message
if (enabled_repo_count == 0)
{
- if (argc)
+ if (!specified.empty() || !not_found.empty())
cerr << _("Specified repositories are not enabled or defined.");
else
cerr << _("There are no enabled repositories defined.");
@@ -686,19 +784,19 @@
else if (error_count == enabled_repo_count)
{
cerr << _("Could not refresh the repositories because of errors.") << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
else if (error_count)
{
cerr << _("Some of the repositories have not been refreshed because of an
error.") << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
- else if (argc)
+ else if (!specified.empty())
cout << _("Specified repositories have been refreshed.") << endl;
else
cout << _("All repositories have been refreshed.") << endl;
-
- return ZYPPER_EXIT_OK;
}

// ----------------------------------------------------------------------------
@@ -722,8 +820,7 @@

// ----------------------------------------------------------------------------

-static
-int add_repo(Zypper & zypper, RepoInfo & repo)
+void add_repo(Zypper & zypper, RepoInfo & repo)
{
RepoManager manager(zypper.globalOpts().rm_options);

@@ -756,36 +853,40 @@
catch (const RepoAlreadyExistsException & e)
{
ZYPP_CAUGHT(e);
- cerr << format(_("Repository named '%s' already exists. Please, use
another alias."))
+ cerr << format(_("Repository named '%s' already exists. Please use another
alias."))
% repo.alias() << endl;
ERR << "Repository named '" << repo.alias() << "' already exists." << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
catch (const RepoUnknownTypeException & e)
{
ZYPP_CAUGHT(e);
cerr << _("Can't find a valid repository at given location:") << endl;
cerr << _("Could not determine the type of the repository."
- " Please, check if the defined URLs (see below) point to a valid
repository:");
+ " Please check if the defined URLs (see below) point to a valid
repository:");
for(RepoInfo::urls_const_iterator uit = repo.baseUrlsBegin();
uit != repo.baseUrlsEnd(); ++uit)
cerr << (*uit) << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
catch (const RepoException & e)
{
ZYPP_CAUGHT(e);
report_problem(e,
_("Problem transferring repository data from specified URL:"),
- is_cd ? "" : _("Please, check whether the specified URL is
accessible."));
+ is_cd ? "" : _("Please check whether the specified URL is
accessible."));
ERR << "Problem transferring repository data from specified URL" << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
catch (const Exception & e)
{
ZYPP_CAUGHT(e);
report_problem(e, _("Unknown problem when adding repository:"));
- return ZYPPER_EXIT_ERR_BUG;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_BUG);
+ return;
}

cout << format(_("Repository '%s' successfully added")) % repo.name();
@@ -804,7 +905,12 @@
cout_n << _("Enabled") << ": " << (repo.enabled() ? _("Yes") : _("No")) <<
endl;
// TranslatorExplanation used as e.g. "Autorefresh: Yes"
cout_n << _("Autorefresh") << ": " << (repo.autorefresh() ? _("Yes") :
_("No")) << endl;
- cout_n << "URL: " << *repo.baseUrlsBegin() << endl;
+
+ cout_n << "URL:";
+ for (RepoInfo::urls_const_iterator uit = repo.baseUrlsBegin();
+ uit != repo.baseUrlsEnd(); uit++)
+ cout_n << " " << *uit;
+ cout_n << endl;
}

MIL << "Repository successfully added: " << repo << endl;
@@ -818,12 +924,11 @@
if (error)
{
cerr << format(_("Problem reading data from '%s' media")) % repo.name()
<< endl;
- cerr << _("Please, check if your installation media is valid and
readable.") << endl;
- return ZYPPER_EXIT_ERR_ZYPP;
+ cerr << _("Please check if your installation media is valid and
readable.") << endl;
+ zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
+ return;
}
}
-
- return ZYPPER_EXIT_OK;
}

// ----------------------------------------------------------------------------
@@ -850,7 +955,7 @@
if ( !indeterminate(autorefresh) )
repo.setAutorefresh((autorefresh == true));

- zypper.setExitCode(add_repo(zypper, repo));
+ add_repo(zypper, repo);
}

// ----------------------------------------------------------------------------
@@ -908,12 +1013,25 @@
{
RepoInfo repo = *it;

+ if(repo.alias().empty())
+ {
+ cerr << _("A repository with no alias defined found in the file,
skipping.") << endl;
+ continue;
+ }
+
+ if(repo.baseUrlsEmpty())
+ {
+ cerr << format(_("Repository '%s' has no URL defined, skipping.")) %
repo.name() << endl;
+ continue;
+ }
+
MIL << "enabled: " << enabled << " autorefresh: " << autorefresh << endl;
if ( !indeterminate(enabled) )
repo.setEnabled((enabled == true));
if ( !indeterminate(autorefresh) )
repo.setAutorefresh((autorefresh == true));
MIL << "enabled: " << repo.enabled() << " autorefresh: " <<
repo.autorefresh() << endl;
+
add_repo(zypper, repo);
}

@@ -929,34 +1047,16 @@
}

// ----------------------------------------------------------------------------
-/*
-static
-bool looks_like_url (const string& s) {
- static bool schemes_shown = false;
- if (!schemes_shown) {
- cerr_vv << "Registered schemes: " << Url::getRegisteredSchemes () << endl;
- schemes_shown = true;
- }

- string::size_type pos = s.find (':');
- if (pos != string::npos) {
- string scheme (s, 0, pos);
- if (Url::isRegisteredScheme (scheme)) {
- return true;
- }
- }
- return false;
-}
-*/
-static bool do_remove_repo(Zypper & zypper, const RepoInfo & repoinfo)
+bool remove_repo(Zypper & zypper, const RepoInfo & repoinfo)
{
RepoManager manager(zypper.globalOpts().rm_options);
bool found = true;
try
{
manager.removeRepository(repoinfo);
- cout << format(_("Repository %s has been removed.")) % repoinfo.name() <<
endl;
- MIL << format("Repository %s has been removed.") % repoinfo.name() << endl;
+ cout << format(_("Repository '%s' has been removed.")) % repoinfo.name()
<< endl;
+ MIL << format("Repository '%s' has been removed.") % repoinfo.name() <<
endl;
}
catch (const repo::RepoNotFoundException & ex)
{
@@ -971,10 +1071,14 @@

bool remove_repo(Zypper & zypper, const std::string &alias )
{
- RepoInfo info;
- info.setAlias(alias);
+ list<RepoInfo> repos =
+ RepoManager(zypper.globalOpts().rm_options).knownRepositories();
+ for (list<RepoInfo>::const_iterator it = repos.begin();
+ it != repos.end(); ++it)
+ if (it->alias() == alias)
+ return remove_repo(zypper, *it);

- return do_remove_repo(zypper, info);
+ return false;
}

bool remove_repo(Zypper & zypper, const Url & url, const url::ViewOption &
urlview)
@@ -984,7 +1088,7 @@
try
{
RepoInfo info = manager.getRepositoryInfo(url, urlview);
- found = do_remove_repo(zypper, info);
+ found = remove_repo(zypper, info);
}
catch (const repo::RepoNotFoundException & ex)
{
@@ -1007,19 +1111,25 @@
repo.setAlias(newalias);
manager.modifyRepository(alias, repo);

- cout << format(_("Repository %s renamed to %s")) % alias % repo.alias() <<
endl;
- MIL << format("Repository %s renamed to %s") % alias % repo.alias() <<
endl;
+ cout << format(_("Repository '%s' renamed to '%s'")) % alias %
repo.alias() << endl;
+ MIL << format("Repository '%s' renamed to '%s'") % alias % repo.alias() <<
endl;
}
catch (const RepoNotFoundException & ex)
{
- cerr << format(_("Repository %s not found.")) % alias << endl;
+ cerr << format(_("Repository '%s' not found.")) % alias << endl;
ERR << "Repo " << alias << " not found" << endl;
}
+ catch (const RepoAlreadyExistsException & ex)
+ {
+ cerr << format(_(
+ "Repository named '%s' already exists. Please use another alias."))
+ % newalias << endl;
+ }
catch (const Exception & ex)
{
cerr << _("Error while modifying the repository:") << endl;
cerr << ex.asUserString() << endl;
- cerr << format(_("Leaving repository %s unchanged.")) % alias << endl;
+ cerr << format(_("Leaving repository '%s' unchanged.")) % alias << endl;

ERR << "Error while modifying the repository:" << ex.asUserString() <<
endl;
}

Modified: branches/tmp/ma/jump_sat/zypper/src/zypper-repos.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/zypper-repos.h?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/zypper-repos.h (original)
+++ branches/tmp/ma/jump_sat/zypper/src/zypper-repos.h Sat Feb 2 23:26:10 2008
@@ -25,7 +25,7 @@
/**
* Refresh all enabled repositories.
*/
-int refresh_repos(Zypper & zypper, std::vector<std::string> & arguments);
+void refresh_repos(Zypper & zypper);


/**
@@ -36,8 +36,6 @@
* \param type
* \param enabled Whether the repo should be enabled
* \param autorefresh Whether the repo should have autorefresh turned on
- * \return ZYPPER_EXIT_ERR_ZYPP on unexpected zypp exception,
- * ZYPPER_EXIT_OK otherwise
*/
void add_repo_by_url(Zypper & zypper,
const zypp::Url & url,
@@ -54,8 +52,6 @@
* \param repo_file_url Valid URL of the repo file.
* \param enabled Whether the repo should be enabled
* \param autorefresh Whether the repo should have autorefresh turned on
- * \return ZYPPER_EXIT_ERR_ZYPP on unexpected zypp exception,
- * ZYPPER_EXIT_OK otherwise
*/
void add_repo_from_file(Zypper & zypper,
const std::string & repo_file_url,
@@ -63,13 +59,20 @@
boost::tribool autorefresh = boost::indeterminate);

/**
- * Delte repository specified by \a alias.
+ * Add repository specified by \repo to system repositories.
+ */
+void add_repo(Zypper & zypper, zypp::RepoInfo & repo);
+
+/**
+ * Remove repository specified by \a alias.
*/
bool remove_repo(Zypper & zypper, const std::string &alias );

bool remove_repo(Zypper & zypper,
const zypp::Url & url, const zypp::url::ViewOption & urlview);

+bool remove_repo(Zypper & zypper, const zypp::RepoInfo & repoinfo);
+
/**
* Rename repository specified by \a alias to \a newalias.
*/

Modified: branches/tmp/ma/jump_sat/zypper/src/zypper-utils.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/zypper-utils.cc?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/zypper-utils.cc (original)
+++ branches/tmp/ma/jump_sat/zypper/src/zypper-utils.cc Sat Feb 2 23:26:10 2008
@@ -1,12 +1,15 @@
#include <fstream>
+#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>

#include "zypp/base/Logger.h"
#include "zypp/media/MediaManager.h"
+#include "zypp/Pathname.h"

#include "zypper-main.h"
#include "zypper-utils.h"
+#include "zypper-callbacks.h"

using namespace std;
using namespace zypp;
@@ -38,6 +41,8 @@
return "\004";
}

+// ----------------------------------------------------------------------------
+
/// tell the user to report a bug, and how
// (multiline, with endls)
ostream& report_a_bug (ostream& stm)
@@ -48,6 +53,8 @@
<< _("See http://en.opensuse.org/Zypper#Troubleshooting for
instructions.") << endl;
}

+// ----------------------------------------------------------------------------
+
bool is_changeable_media(const zypp::Url & url)
{
MIL << "Checking if this is a changeable medium" << endl;
@@ -70,29 +77,29 @@

// ----------------------------------------------------------------------------

-string kind_to_string_localized(const KindOf<Resolvable> & kind, unsigned long
count)
+string kind_to_string_localized(const Resolvable::Kind & kind, unsigned long
count)
{
- if (kind == ResTraits<Package>::kind.asString())
+ if (kind == ResTraits<Package>::kind)
return _PL("package", "packages", count);
- if (kind == ResTraits<Selection>::kind.asString())
+ if (kind == ResTraits<Selection>::kind)
return _PL("selection", "selections", count);
- if (kind == ResTraits<Pattern>::kind.asString())
+ if (kind == ResTraits<Pattern>::kind)
return _PL("pattern", "patterns", count);
- if (kind == ResTraits<Product>::kind.asString())
+ if (kind == ResTraits<Product>::kind)
return _PL("product", "product", count);
- if (kind == ResTraits<Patch>::kind.asString())
+ if (kind == ResTraits<Patch>::kind)
return _PL("patch", "patches", count);
- if (kind == ResTraits<Script>::kind.asString())
+ if (kind == ResTraits<Script>::kind)
return _PL("script", "scripts", count);
- if (kind == ResTraits<Message>::kind.asString())
+ if (kind == ResTraits<Message>::kind)
return _PL("message", "messages", count);
- if (kind == ResTraits<Language>::kind.asString())
+ if (kind == ResTraits<Language>::kind)
return _PL("language", "languages", count);
- if (kind == ResTraits<Atom>::kind.asString())
+ if (kind == ResTraits<Atom>::kind)
return _PL("atom", "atoms", count);
- if (kind == ResTraits<SystemResObject>::kind.asString())
+ if (kind == ResTraits<SystemResObject>::kind)
return _PL("system", "systems", count);
- if (kind == ResTraits<SrcPackage>::kind.asString())
+ if (kind == ResTraits<SrcPackage>::kind)
return _PL("srcpackage", "srcpackages", count);
// default
return _PL("resolvable", "resolvables", count);
@@ -100,16 +107,127 @@

// ----------------------------------------------------------------------------

-Url make_url (const string & url_s) {
+bool looks_like_url (const string& s)
+{
+/*
+ static bool schemes_shown = false;
+ if (!schemes_shown) {
+ DBG << "Registered schemes: " << Url::getRegisteredSchemes () << endl;
+ schemes_shown = true;
+ }
+*/
+ string::size_type pos = s.find (':');
+ if (pos != string::npos) {
+ string scheme (s, 0, pos);
+ if (Url::isRegisteredScheme (scheme)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// ----------------------------------------------------------------------------
+
+Url make_url (const string & url_s)
+{
Url u;
+ string urlstr(url_s);
+
+ if (!url_s.empty() && !looks_like_url(url_s))
+ {
+ DBG << "'" << url_s << "' does not look like a URL, trying to treat it
like a local path" << endl;
+
+ Pathname path;
+ // make an url from absolute path
+ if (url_s[0] == '/')
+ path = url_s;
+ // make absolute path url from relative path
+ else
+ {
+ char buf[PATH_MAX];
+ if (getcwd(buf, PATH_MAX) != NULL)
+ {
+ DBG << "current working directory: " << buf << endl;
+ path = string(buf) + "/" + url_s;
+ }
+ }
+
+ if (PathInfo(path).isExist())
+ {
+ urlstr = "dir:" + path.absolutename().asString();
+ DBG << "resulting url: " << urlstr << endl;
+ }
+ else
+ DBG << "specified local path does not exist or is not accessible" <<
endl;
+ }

try {
- u = Url( (url_s[0] == '/') ? string("dir:") + url_s : url_s );
+ u = Url(urlstr);
}
catch ( const Exception & excpt_r ) {
ZYPP_CAUGHT( excpt_r );
- cerr << _("Given URL is invalid.") << endl;
- cerr << excpt_r.asUserString() << endl;
+ cerr << _("Given URL is invalid") << ": " << urlstr
+ << " (" << excpt_r.asUserString() << ")" << endl;
}
return u;
}
+
+// ----------------------------------------------------------------------------
+
+bool looks_like_rpm_file(const string & s)
+{
+ // don't even bother to check strings shorter than 4 chars.
+ if (s.size() <= 4)
+ return false;
+
+ if (s.rfind(".rpm") == s.size() - 4 || // ends with .rpm
+ s.find("./") == 0 || // starts with ./, ../, or /
indicating
+ s.find("../") == 0 || // a local path
+ s.find("/") == 0)
+ return true;
+
+ return false;
+}
+
+// ----------------------------------------------------------------------------
+
+Pathname cache_rpm(const string & rpm_uri_str, const string & cache_dir)
+{
+ Url rpmurl = make_url(rpm_uri_str);
+ Pathname rpmpath(rpmurl.getPathName());
+ rpmurl.setPathName(rpmpath.dirname().asString()); // directory
+ rpmpath = rpmpath.basename(); // rpm file name
+
+ try
+ {
+ media::MediaManager mm;
+ media::MediaAccessId mid = mm.open(rpmurl);
+ mm.attachDesiredMedia(mid);
+
+ mm.provideFile(mid, rpmpath.basename());
+ Pathname localrpmpath = mm.localPath(mid, rpmpath.basename());
+ Pathname cachedrpmpath = cache_dir;
+ filesystem::assert_dir(cachedrpmpath);
+ bool error =
+ filesystem::copy(localrpmpath, cachedrpmpath / localrpmpath.basename());
+
+ mm.release(mid);
+ mm.close(mid);
+
+ if (error)
+ {
+ cerr << _("Problem copying the specified RPM file to the cache
directory.")
+ << endl << _("Perhaps you are running out of disk space.") << endl;
+ return Pathname();
+ }
+ return cachedrpmpath / localrpmpath.basename();
+ }
+ catch (const Exception & e)
+ {
+ report_problem(e,
+ _("Problem downloading the specified RPM file") + string(":"),
+ _("Please check whether the file is accessible."));
+ }
+
+ return Pathname();
+}

Modified: branches/tmp/ma/jump_sat/zypper/src/zypper-utils.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/zypper-utils.h?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/zypper-utils.h (original)
+++ branches/tmp/ma/jump_sat/zypper/src/zypper-utils.h Sat Feb 2 23:26:10 2008
@@ -6,6 +6,7 @@

#include "zypp/Url.h"
#include "zypp/Resolvable.h"
+#include "zypp/Pathname.h"

std::string readline_getline();

@@ -17,12 +18,37 @@
bool is_changeable_media(const zypp::Url & url);

std::string kind_to_string_localized(
- const zypp::KindOf<zypp::Resolvable> & kind, unsigned long count);
+ const zypp::Resolvable::Kind & kind, unsigned long count);

/**
- * Constructor wrapper catching exceptions,
- * returning an empty one on error.
+ * Creates a Url out of \a urls_s. If the url_s looks looks_like_url()
+ * Url(url_s) is returned. Otherwise if \a url_s represends a valid path to
+ * a file or directory, a dir:// Url is returned. Otherwise an empty Url is
+ * returned.
*/
zypp::Url make_url (const std::string & url_s);

+/**
+ * Returns <code>true</code> if the string \a s contains a substring starting
+ * at the beginning and ending before the first colon matches any of registered
+ * schemes (Url::isRegisteredScheme()).
+ */
+bool looks_like_url (const std::string& s);
+
+/**
+ * Returns <code>true</code> if \a s ends with ".rpm" or starts with "/", "./",
+ * or "../".
+ */
+bool looks_like_rpm_file(const std::string & s);
+
+/**
+ * Download the RPM file specified by \a rpm_uri_str and copy it into
+ * \a cache_dir.
+ *
+ * \return The local Pathname of the file in the cache on success, empty
+ * Pathname if a problem occurs.
+ */
+zypp::Pathname cache_rpm(const std::string & rpm_uri_str,
+ const std::string & cache_dir);
+
#endif /*ZYPPER_UTILS_H*/

Modified: branches/tmp/ma/jump_sat/zypper/src/zypper.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/zypper.cc?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/zypper.cc (original)
+++ branches/tmp/ma/jump_sat/zypper/src/zypper.cc Sat Feb 2 23:26:10 2008
@@ -27,6 +27,8 @@
#include "zypp/repo/RepoException.h"
#include "zypp/zypp_detail/ZYppReadOnlyHack.h"

+#include "zypp/target/rpm/RpmHeader.h" // for install <.rpmURI>
+
#include "zypper-main.h"
#include "zypper.h"
#include "zypper-repos.h"
@@ -90,23 +92,26 @@
MIL << "Caught exit request:" << endl << e.msg() << endl;
return exitCode();
}
+
+ if (runningHelp())
+ {
+ safeDoCommand();
+ return exitCode();
+ }

switch(command().toEnum())
{
case ZypperCommand::SHELL_e:
commandShell();
- return ZYPPER_EXIT_OK;
+ cleanup();
+ return exitCode();

case ZypperCommand::NONE_e:
- {
- if (runningHelp())
- return ZYPPER_EXIT_OK;
- else
- return ZYPPER_EXIT_ERR_SYNTAX;
- }
+ return ZYPPER_EXIT_ERR_SYNTAX;

default:
safeDoCommand();
+ cleanup();
return exitCode();
}

@@ -115,9 +120,9 @@
return exitCode();
}

-void print_main_help()
+void print_main_help(const Zypper & zypper)
{
- static string help_global_options = _(" Options:\n"
+ static string help_global_options = _(" Global Options:\n"
"\t--help, -h\t\tHelp.\n"
"\t--version, -V\t\tOutput the version number.\n"
"\t--quiet, -q\t\tSuppress normal output, print only error messages.\n"
@@ -126,11 +131,22 @@
"\t--table-style, -s\tTable style (integer).\n"
"\t--rug-compatible, -r\tTurn on rug compatibility.\n"
"\t--non-interactive, -n\tDon't ask anything, use default answers
automatically.\n"
+ "\t--reposd-dir, -D <dir>\tUse alternative repository definition files
directory.\n"
+ "\t--cache-dir, -C <dir>\tUse alternative meta-data cache database
directory.\n"
+ "\t--raw-cache-dir <dir>\tUse alternative raw meta-data cache directory\n"
+ );
+
+ static string help_global_source_options = _(
+ "\tRepository Options:\n"
"\t--no-gpg-checks\t\tIgnore GPG check failures and continue.\n"
+ "\t--plus-repo, -p <URI>\tUse an additional repository\n"
+ "\t--disable-repositories\tDo not read meta-data from repositories.\n"
+ "\t--no-refresh\tDo not refresh the repositories.\n"
+ );
+
+ static string help_global_target_options = _("\tTarget Options:\n"
"\t--root, -R <dir>\tOperate on a different root directory.\n"
- "\t--reposd-dir, D <dir>\tUse alternative repository definition files
directory.\n"
- "\t--cache-dir, C <dir>\tUse alternative meta-data cache database
directory.\n"
- "\t--raw-cache-dir <dir>\tUse alternative raw meta-data cache directory\n"
+ "\t--disable-system-resolvables Do not read installed resolvables\n"
);

static string help_commands = _(
@@ -162,15 +178,30 @@
"\tzypper [--global-options] <command> [--command-options] [arguments]\n"
);

- cout << help_usage << endl << help_global_options << endl << help_commands;
+ cout
+ << help_usage << endl
+ << help_global_options << endl
+ << help_global_source_options << endl
+ << help_global_target_options << endl
+ << help_commands << endl;
+
+ print_command_help_hint(zypper);
}

-void Zypper::print_unknown_command_hint()
+void print_unknown_command_hint(const Zypper & zypper)
{
// TranslatorExplanation %s is "help" or "zypper help" depending on whether
// zypper shell is running or not
cout << format(_("Type '%s' to get a list of global options and commands."))
- % (runningShell() ? "help" : "zypper help") << endl;
+ % (zypper.runningShell() ? "help" : "zypper help") << endl;
+}
+
+void print_command_help_hint(const Zypper & zypper)
+{
+ // TranslatorExplanation %s is "help" or "zypper help" depending on whether
+ // zypper shell is running or not
+ cout << format(_("Type '%s' to get a command-specific help."))
+ % (zypper.runningShell() ? "help <command>" : "zypper help <command>") <<
endl;
}

/*
@@ -184,21 +215,26 @@
MIL << "START" << endl;

static struct option global_options[] = {
- {"help", no_argument, 0, 'h'},
- {"verbose", no_argument, 0, 'v'},
- {"quiet", no_argument, 0, 'q'},
- {"version", no_argument, 0, 'V'},
- {"terse", no_argument, 0, 't'},
- {"table-style", required_argument, 0, 's'},
- {"rug-compatible", no_argument, 0, 'r'},
- {"non-interactive", no_argument, 0, 'n'},
- {"no-gpg-checks", no_argument, 0, 0 },
- {"root", required_argument, 0, 'R'},
- {"reposd-dir", required_argument, 0, 'D'},
- {"cache-dir", required_argument, 0, 'C'},
- {"raw-cache-dir", required_argument, 0, 0 },
- {"opt", optional_argument, 0, 'o'},
- {"disable-system-resolvables", optional_argument, 0, 'o'},
+ {"help", no_argument, 0, 'h'},
+ {"verbose", no_argument, 0, 'v'},
+ {"quiet", no_argument, 0, 'q'},
+ {"version", no_argument, 0, 'V'},
+ {"terse", no_argument, 0, 't'},
+ {"table-style", required_argument, 0, 's'},
+ {"rug-compatible", no_argument, 0, 'r'},
+ {"non-interactive", no_argument, 0, 'n'},
+ {"no-gpg-checks", no_argument, 0, 0 },
+ {"root", required_argument, 0, 'R'},
+ {"reposd-dir", required_argument, 0, 'D'},
+ {"cache-dir", required_argument, 0, 'C'},
+ {"raw-cache-dir", required_argument, 0, 0 },
+ {"opt", optional_argument, 0, 'o'},
+ // TARGET OPTIONS
+ {"disable-system-resolvables", no_argument, 0, 0 },
+ // REPO OPTIONS
+ {"plus-repo", required_argument, 0, 'p'},
+ {"disable-repositories", no_argument, 0, 0 },
+ {"no-refresh", no_argument, 0, 0 },
{0, 0, 0, 0}
};

@@ -300,40 +336,33 @@
cout << "<stream>" << endl;
}

- if (gopts.count("disable-repositories") ||
- gopts.count("disable-system-sources"))
+ if (gopts.count("disable-repositories"))
{
MIL << "Repositories disabled, using target only." << endl;
- cout_n <<
+ cout <<
_("Repositories disabled, using the database of installed packages
only.")
<< endl;
_gopts.disable_system_sources = true;
}
else
{
- MIL << "System sources enabled" << endl;
+ MIL << "Repositories enabled" << endl;
+ }
+
+ if (gopts.count("no-refresh"))
+ {
+ _gopts.no_refresh = true;
+ cout_v << _("Autorefresh disabled.") << endl;
+ MIL << "Autorefresh disabled." << endl;
}

if (gopts.count("disable-system-resolvables"))
{
MIL << "System resolvables disabled" << endl;
- cout_v << _("Ignoring installed resolvables...") << endl;
+ cout << _("Ignoring installed resolvables.") << endl;
_gopts.disable_system_resolvables = true;
}
-/*
- if (gopts.count("source"))
- {
- list<string> sources = gopts["source"];
- for (list<string>::const_iterator it = sources.begin(); it !=
sources.end(); ++it )
- {
- Url url = make_url (*it);
- if (!url.isValid())
- setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
- return;
- _gopts.additional_sources.push_back(url);
- }
- }
-*/
+
// testing option
if ((it = gopts.find("opt")) != gopts.end()) {
cout << "Opt arg: ";
@@ -353,7 +382,7 @@
//setCommand(ZypperCommand::NONE);
}
}
- else
+ else if (!gopts.count("version"))
setRunningHelp();

if (command() == ZypperCommand::HELP)
@@ -368,29 +397,86 @@
if (!arg.empty() && arg != "-h" && arg != "--help")
{
cout << e.asUserString() << endl;
- print_unknown_command_hint();
+ print_unknown_command_hint(*this);
ZYPP_THROW(ExitRequestException("help provided"));
}
}
}
else
{
- print_main_help();
+ print_main_help(*this);
ZYPP_THROW(ExitRequestException("help provided"));
}
}
else if (command() == ZypperCommand::NONE)
{
if (runningHelp())
- print_main_help();
+ print_main_help(*this);
else if (gopts.count("version"))
cout << PACKAGE " " VERSION << endl;
else
{
- print_unknown_command_hint();
+ print_unknown_command_hint(*this);
setExitCode(ZYPPER_EXIT_ERR_SYNTAX);
}
}
+ else if (command() == ZypperCommand::SHELL && optind < _argc)
+ {
+ string arg = _argv[optind++];
+ if (!arg.empty())
+ {
+ if (arg == "-h" || arg == "--help")
+ setRunningHelp(true);
+ else
+ {
+ report_too_many_arguments("shell\n");
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ ZYPP_THROW(ExitRequestException("help provided"));
+ }
+ }
+ }
+
+ // additional repositories
+ if (gopts.count("plus-repo"))
+ {
+ if (command() == ZypperCommand::ADD_REPO ||
+ command() == ZypperCommand::REMOVE_REPO ||
+ command() == ZypperCommand::MODIFY_REPO ||
+ command() == ZypperCommand::RENAME_REPO ||
+ command() == ZypperCommand::REFRESH)
+ {
+ // TranslatorExplanation The %s is "--plus-repo"
+ cout << format(_("The %s option has no effect here, ignoring."))
+ % "--plus-repo" << endl;
+ }
+ else
+ {
+ list<string> repos = gopts["plus-repo"];
+
+ int count = 1;
+ for (list<string>::const_iterator it = repos.begin();
+ it != repos.end(); ++it)
+ {
+ Url url = make_url (*it);
+ if (!url.isValid())
+ {
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
+ }
+
+ RepoInfo repo;
+ repo.addBaseUrl(url);
+ repo.setEnabled(true);
+ repo.setAutorefresh(true);
+ repo.setAlias(boost::str(format("tmp%d") % count));
+ repo.setName(url.asString());
+
+ gData.additional_repos.push_back(repo);
+ DBG << "got additional repo: " << url << endl;
+ count++;
+ }
+ }
+ }

MIL << "DONE" << endl;
}
@@ -438,17 +524,15 @@
setCommand(ZypperCommand(command_str));
if (command() == ZypperCommand::SHELL_QUIT)
break;
- else if (command() == ZypperCommand::SHELL)
- cout << _("You already are running zypper's shell.") << endl;
else if (command() == ZypperCommand::NONE)
- print_unknown_command_hint();
+ print_unknown_command_hint(*this);
else
safeDoCommand();
}
catch (Exception & e)
{
cerr << e.msg() << endl;
- print_unknown_command_hint();
+ print_unknown_command_hint(*this);
}

shellCleanup();
@@ -512,7 +596,7 @@
try
{
processCommandOptions();
- if (command() == ZypperCommand::NONE)
+ if (command() == ZypperCommand::NONE || exitCode())
return;
doCommand();
}
@@ -548,18 +632,6 @@
struct option no_options = {0, 0, 0, 0};
struct option *specific_options = &no_options;

-/* string help_global_source_options = _(
- " Repository options:\n"
- "\t--disable-repositories, -D\t\tDo not read data from defined
repositories.\n"
- "\t--plus-repo <URI|.repo>\t\tRead additional repository\n" //! \todo
additional repo
- );*/
-//! \todo preserve for rug comp. "\t--disable-system-sources, -D\t\tDo not
read the system sources\n"
-//! \todo preserve for rug comp. "\t--source, -S\t\tRead additional source\n"
-
-// string help_global_target_options = _(" Target options:\n"
-// "\t--disable-system-resolvables, -T\t\tDo not read system installed
resolvables\n"
-// );
-
// this could be done in the processGlobalOptions() if there was no
// zypper shell
if (command() == ZypperCommand::HELP)
@@ -576,14 +648,14 @@
if (!cmd.empty() && cmd != "-h" && cmd != "--help")
{
cout << ex.asUserString() << endl;
- print_unknown_command_hint();
+ print_unknown_command_hint(*this);
return;
}
}
}
else
{
- print_main_help();
+ print_main_help(*this);
return;
}
}
@@ -594,11 +666,8 @@
// print help on help
case ZypperCommand::HELP_e:
{
- print_unknown_command_hint();
- // TranslatorExplanation %s is "help" or "zypper help" depending on whether
- // zypper shell is running or not
- cout << format(_("Type '%s' to get a command-specific help."))
- % (runningShell() ? "help <command>" : "zypper help <command>") << endl;
+ print_unknown_command_hint(*this);
+ print_command_help_hint(*this);
break;
}

@@ -620,6 +689,7 @@
{"agree-to-third-party-licenses", no_argument, 0, 0},
{"debug-solver", no_argument, 0, 0},
{"force-resolution", required_argument, 0, 'R'},
+ {"dry-run", no_argument, 0, 'D'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
@@ -627,13 +697,14 @@
_command_help = boost::str(format(_(
// TranslatorExplanation the first %s = "package, patch, pattern,
product"
// and the second %s = "package"
- "install (in) [options] <capability> ...\n"
+ "install (in) [options] <capability|rpm_file_uri> ...\n"
"\n"
- "Install resolvables with specified capabilities. A capability is"
+ "Install resolvables with specified capabilities or RPM files with"
+ " specified location. A capability is"
" NAME[OP<VERSION>], where OP is one of <, <=, =, >=, >.\n"
"\n"
" Command options:\n"
- "-r, --repo <alias> Install resolvables only from
repository specified by alias.\n"
+ "-r, --repo <alias|#|URI> Install resolvables only from
repository specified by alias.\n"
"-t, --type <type> Type of resolvable (%s)\n"
" Default: %s\n"
"-n, --name Select resolvables by plain name, not
by capability\n"
@@ -643,6 +714,7 @@
" See 'man zypper' for more details.\n"
" --debug-solver Create solver test case for debugging\n"
"-R, --force-resolution <on|off> Force the solver to find a solution
(even agressive)\n"
+ "-D, --dry-run Test the installation, do not actually
install\n"
)) % "package, patch, pattern, product" % "package");
break;
}
@@ -661,6 +733,7 @@
{"no-confirm", no_argument, 0, 'y'},
{"debug-solver", no_argument, 0, 0},
{"force-resolution", required_argument, 0, 'R'},
+ {"dry-run", no_argument, 0, 'D'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
@@ -674,13 +747,14 @@
" NAME[OP<VERSION>], where OP is one of <, <=, =, >=, >.\n"
"\n"
" Command options:\n"
- "-r, --repo <alias> Operate only with resolvables from
repository specified by alias.\n"
+ "-r, --repo <alias|#|URI> Operate only with resolvables from
repository specified by alias.\n"
"-t, --type <type> Type of resolvable (%s)\n"
" Default: %s\n"
"-n, --name Select resolvables by plain name, not
by capability\n"
"-C, --capability Select resolvables by capability\n"
" --debug-solver Create solver test case for
debugging\n"
"-R, --force-resolution <on|off> Force the solver to find a solution
(even agressive)\n"
+ "-D, --dry-run Test the removal, do not actually
remove\n"
)) % "package, patch, pattern, product" % "package");
break;
}
@@ -818,6 +892,7 @@
{"force-download", no_argument, 0, 'd'},
{"build-only", no_argument, 0, 'B'},
{"download-only", no_argument, 0, 'D'},
+ {"repo", required_argument, 0, 'r'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
@@ -829,11 +904,12 @@
" If none are specified, all enabled repositories will be refreshed.\n"
"\n"
" Command options:\n"
- "-f, --force Force a complete refresh\n"
- "-b, --force-build Force rebuild of the database\n"
- "-d, --force-download Force download of raw metadata\n"
- "-B, --build-only Only build the database, don't download
metadata.\n"
- "-D, --download-only Only download raw metadata, don't build the
database\n"
+ "-f, --force Force a complete refresh\n"
+ "-b, --force-build Force rebuild of the database\n"
+ "-d, --force-download Force download of raw metadata\n"
+ "-B, --build-only Only build the database, don't download
metadata.\n"
+ "-D, --download-only Only download raw metadata, don't build the
database\n"
+ "-r, --repo <alias|#|URI> Refresh only specified repositories.\n"
);
break;
}
@@ -858,10 +934,12 @@
"List all available updates\n"
"\n"
" Command options:\n"
- "-t, --type <type> Type of resolvable (%s)\n"
- " Default: %s\n"
- "-r, --repo <alias> List only updates from the repository specified by
the alias.\n"
- " --best-effort Do a 'best effort' approach to update, updates to a
lower than latest-and-greatest version are also acceptable.\n"
+ "-t, --type <type> Type of resolvable (%s)\n"
+ " Default: %s\n"
+ "-r, --repo <alias|#|URI> List only updates from the repository
specified by the alias.\n"
+ " --best-effort Do a 'best effort' approach to update,
updates to\n"
+ " a lower than latest-and-greatest version
are\n"
+ " also acceptable.\n"
)) % "package, patch, pattern, product" % "patch");
break;
}
@@ -883,6 +961,7 @@
{"best-effort", no_argument, 0, 0},
{"debug-solver", no_argument, 0, 0},
{"force-resolution", required_argument, 0, 'R'},
+ {"dry-run", no_argument, 0, 'D'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
@@ -898,13 +977,14 @@
"\n"
"-t, --type <type> Type of resolvable (%s)\n"
" Default: %s\n"
- "-r, --repo <alias> Limit updates to the repository
specified by the alias.\n"
+ "-r, --repo <alias|#|URI> Limit updates to the repository
specified by the alias.\n"
" --skip-interactive Skip interactive updates\n"
"-l, --auto-agree-with-licenses Automatically say 'yes' to third party
license confirmation prompt.\n"
" See man zypper for more details.\n"
" --best-effort Do a 'best effort' approach to update,
updates to a lower than latest-and-greatest version are also acceptable\n"
" --debug-solver Create solver test case for debugging\n"
"-R, --force-resolution <on|off> Force the solver to find a solution
(even agressive)\n"
+ "-D, --dry-run Test the update, do not actually
update\n"
)) % "package, patch, pattern, product" % "patch");
break;
}
@@ -915,6 +995,7 @@
{"repo", required_argument, 0, 'r'},
{"auto-agree-with-licenses", no_argument, 0, 'l'},
{"debug-solver", no_argument, 0, 0},
+ {"dry-run", no_argument, 0, 'D'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
@@ -926,10 +1007,11 @@
"\n"
" Command options:\n"
"\n"
- "-r, --repo <alias> Limit the upgrade to the repository
specified by the alias.\n"
+ "-r, --repo <alias|#|URI> Limit the upgrade to the repository
specified by the alias.\n"
"-l, --auto-agree-with-licenses Automatically say 'yes' to third party
license confirmation prompt.\n"
" See man zypper for more details.\n"
" --debug-solver Create solver test case for debugging\n"
+ "-D, --dry-run Test the upgrade, do not actually
upgrade\n"
);
break;
}
@@ -1002,7 +1084,7 @@
"\n"
" Command options:\n"
"\n"
- "-r, --repo <alias> Check for patches only in the repository specified
by the alias.\n"
+ "-r, --repo <alias|#|URI> Check for patches only in the repository
specified by the alias.\n"
);
break;
}
@@ -1024,7 +1106,7 @@
"\n"
" Command options:\n"
"\n"
- "-r, --repo <alias> Check for patches only in the repository specified
by the alias.\n"
+ "-r, --repo <alias|#|URI> Check for patches only in the repository
specified by the alias.\n"
);
break;
}
@@ -1047,10 +1129,11 @@
"Show full information for packages")) + "\n"
"\n" +
_(" Command options:") + "\n" +
- _("-r, --repo <alias> Work only with the repository specified by the
alias.") + "\n" +
+ _("-r, --repo <alias|#|URI> Work only with the repository specified by
the alias.") + "\n" +
boost::str(format(
- _("-t, --type <type> Type of resolvable (%s)\n"
- " Default: %s")) % "package, patch, pattern,
product" % "package") + "\n";
+ _("-t, --type <type> Type of resolvable (%s)\n"
+ " Default: %s"))
+ % "package, patch, pattern, product" % "package") + "\n";

break;
}
@@ -1143,7 +1226,7 @@
"Show updates and patches in xml format\n"
"\n"
" Command options:\n"
- "-r, --repo <alias> Work only with updates from repository specified by
alias.\n"
+ "-r, --repo <alias|#|URI> Work only with updates from repository
specified by alias.\n"
);
break;
}
@@ -1165,6 +1248,23 @@
break;
}

+ case ZypperCommand::SHELL_e:
+ {
+ static struct option quit_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+ specific_options = quit_options;
+ _command_help = _(
+ "shell\n"
+ "\n"
+ "Enter the zypper command shell.\n"
+ "\n"
+ "This command has no additional options.\n"
+ );
+ break;
+ }
+
default:
{
ERR << "Unknown or unexpected command" << endl;
@@ -1180,7 +1280,7 @@
if (copts.count("_unknown"))
{
setExitCode(ZYPPER_EXIT_ERR_SYNTAX);
- ERR << "Unknown command, returning." << endl;
+ ERR << "Unknown option, returning." << endl;
return;
}

@@ -1534,8 +1634,12 @@
setExitCode(ZYPPER_EXIT_ERR_PRIVILEGES);
return;
}
+
+ if (globalOpts().no_refresh)
+ cout << format(_("The '%s' global option has no effect here."))
+ % "--no-refresh" << endl;

- setExitCode(refresh_repos(*this, _arguments));
+ refresh_repos(*this);
return;
}

@@ -1586,17 +1690,97 @@
return;
}

- init_repos(*this);
- if (exitCode() != ZYPPER_EXIT_OK)
- return;
+ bool install_not_remove = command() == ZypperCommand::INSTALL;
+
+ // check for rpm files among the arguments
+ list<string> rpms_files_caps;
+ if (install_not_remove)
+ {
+ for (vector<string>::iterator it = _arguments.begin();
+ it != _arguments.end(); )
+ {
+ if (looks_like_rpm_file(*it))
+ {
+ DBG << *it << " looks like rpm file" << endl;
+ cout_v << format(
+ _("'%s' looks like an RPM file. Will try to download it.")) % *it
+ << endl;
+
+ // download the rpm into the cache
+ //! \todo do we want this or a tmp dir? What about the files cached
before?
+ //! \todo optimize: don't mount the same media multiple times for
each rpm
+ Pathname rpmpath = cache_rpm(*it,
+ (_gopts.root_dir != "/" ? _gopts.root_dir : "")
+ + ZYPPER_RPM_CACHE_DIR);
+
+ if (rpmpath.empty())
+ {
+ cerr << format(_("Problem with the RPM file specified as '%s',
skipping."))
+ % *it << endl;
+ }
+ else
+ {
+ using target::rpm::RpmHeader;
+ // rpm header (need name-version-release)
+ RpmHeader::constPtr header =
+ RpmHeader::readPackage(rpmpath, RpmHeader::NOSIGNATURE);
+ if (header)
+ {
+ string nvrcap =
+ header->tag_name() + "=" +
+ header->tag_version() + "-" +
+ header->tag_release();
+ DBG << "rpm package capability: " << nvrcap << endl;
+
+ // store the rpm file capability string (name=version-release)
+ rpms_files_caps.push_back(nvrcap);
+ }
+ else
+ {
+ cerr << format(
+ _("Problem reading the RPM header of %s. Is it an RPM file?"))
+ % *it << endl;
+ }
+ }
+
+ // remove this rpm argument
+ it = _arguments.erase(it);
+ }
+ else
+ ++it;
+ }
+ }
+
+ // if there were some rpm files, add the rpm cache as a temporary plaindir
repo
+ if (!rpms_files_caps.empty())
+ {
+ // add a plaindir repo
+ RepoInfo repo;
+ repo.setType(repo::RepoType::RPMPLAINDIR);
+ repo.addBaseUrl(Url("dir://"
+ + (_gopts.root_dir != "/" ? _gopts.root_dir : "")
+ + ZYPPER_RPM_CACHE_DIR));
+ repo.setEnabled(true);
+ repo.setAutorefresh(true);
+ repo.setAlias("_tmpRPMcache_");
+ repo.setName(_("RPM files cache"));

- //! \todo support temporary additional repos
- /*
- for ( std::list<Url>::const_iterator it =
globalOpts().additional_sources.begin(); it !=
globalOpts().additional_sources.end(); ++it )
+ gData.additional_repos.push_back(repo);
+ }
+ // no rpms and no other arguments either
+ else if (_arguments.empty())
{
- include_source_by_url( *it );
+ cout << _("No valid arguments specified.") << endl;
+ setExitCode(ZYPPER_EXIT_ERR_INVALID_ARGS);
+ return;
}
- */
+
+ //! \todo quit here if the argument list remains empty after founding only
invalid rpm args
+
+ // prepare repositories
+ init_repos(*this);
+ if (exitCode() != ZYPPER_EXIT_OK)
+ return;

if ( gData.repos.empty() )
{
@@ -1605,21 +1789,31 @@
" Nothing can be installed.") << endl;
}

+ // prepare target
cond_init_target(*this);
+ // load metadata
cond_load_resolvables(*this);

- bool install_not_remove = command() == ZypperCommand::INSTALL;
+ // mark resolvables for installation/removal
bool by_capability = false; // install by name by default
+ //! \todo install by capability by default in the future (need to improve
its output)
if (copts.count("capability"))
by_capability = true;
for ( vector<string>::const_iterator it = _arguments.begin();
- it != _arguments.end(); ++it ) {
+ it != _arguments.end(); ++it )
+ {
if (by_capability)
mark_by_capability (*this, install_not_remove, kind, *it);
else
mark_by_name (install_not_remove, kind, *it);
}

+ // rpm files
+ for ( list<string>::const_iterator it = rpms_files_caps.begin();
+ it != rpms_files_caps.end(); ++it )
+ mark_by_capability (*this, true, kind, *it);
+
+ // solve dependencies
if (copts.count("debug-solver"))
{
establish();
@@ -2116,10 +2310,35 @@
return;
}

+ else if (command() == ZypperCommand::SHELL)
+ {
+ if (runningHelp())
+ cout << _command_help;
+ else if (runningShell())
+ cout << _("You already are running zypper's shell.") << endl;
+ else
+ {
+ cerr << _("Unexpected program flow") << "." << endl;
+ report_a_bug(cerr);
+ }
+
+ return;
+ }
+
// if the program reaches this line, something went wrong
setExitCode(ZYPPER_EXIT_ERR_BUG);
}

+void Zypper::cleanup()
+{
+ MIL << "START" << endl;
+
+ // remove the additional repositories specified by --plus-repo
+ for (list<RepoInfo>::const_iterator it = gData.additional_repos.begin();
+ it != gData.additional_repos.end(); ++it)
+ remove_repo(*this, *it);
+}
+
// Local Variables:
// c-basic-offset: 2
// End:

Modified: branches/tmp/ma/jump_sat/zypper/src/zypper.h
URL:
http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/zypper/src/zypper.h?rev=8447&r1=8446&r2=8447&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/zypper/src/zypper.h (original)
+++ branches/tmp/ma/jump_sat/zypper/src/zypper.h Sat Feb 2 23:26:10 2008
@@ -16,6 +16,10 @@
#include "zypper-command.h"
#include "zypper-getopt.h"

+/** directory for storing manually installed (zypper install foo.rpm) RPM files
+ */
+#define ZYPPER_RPM_CACHE_DIR "/var/cache/zypper/RPMS"
+
/**
* Structure for holding global options.
*/
@@ -30,6 +34,7 @@
non_interactive(false),
no_gpg_checks(false),
machine_readable(false),
+ no_refresh(false),
root_dir("/")
{}

@@ -52,6 +57,8 @@
bool non_interactive;
bool no_gpg_checks;
bool machine_readable;
+ /** Whether to disable autorefresh. */
+ bool no_refresh;
std::string root_dir;
zypp::RepoManagerOptions rm_options;
};
@@ -92,8 +99,6 @@
int argc() { return _running_shell ? _sh_argc : _argc; }
char ** argv() { return _running_shell ? _sh_argv : _argv; }

- void print_unknown_command_hint();
-
private:
Zypper();
~Zypper();
@@ -104,6 +109,7 @@
void shellCleanup();
void safeDoCommand();
void doCommand();
+ void cleanup();

void setCommand(const ZypperCommand & command) { _command = command; }
void setRunningShell(bool value = true) { _running_shell = value; }
@@ -129,6 +135,9 @@
char **_sh_argv;
};

+void print_main_help(const Zypper & zypper);
+void print_unknown_command_hint(const Zypper & zypper);
+void print_command_help_hint(const Zypper & zypper);

struct RuntimeData
{
@@ -137,6 +146,7 @@
{}

std::list<zypp::RepoInfo> repos;
+ std::list<zypp::RepoInfo> additional_repos;
int patches_count;
int security_patches_count;
zypp::ResStore repo_resolvables;

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages