From 86069256b2b89e906ac5875ff620ec01d21c2f84 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Sat, 4 Aug 2007 21:40:03 +0000 Subject: [PATCH] - new refresh options added: --force, --force-build, --force-download, --build-only, --download-only --- doc/zypper.8 | 16 ++++++++++++++++ src/zypper-sources.cc | 35 +++++++++++++++++++++++++++++++---- src/zypper.cc | 12 +++++++++++- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/doc/zypper.8 b/doc/zypper.8 index 42e33f4..9e65071 100644 --- a/doc/zypper.8 +++ b/doc/zypper.8 @@ -274,8 +274,24 @@ Disable auto-refresh for the repository. Refresh repositories specified by their alias or number. If no repositories are specified, all enabled repositories will be refreshed. .IP Refreshing a repository means downloading metadata of resolvables from media (if needed), storing it in local cache (typically under /var/cache/zypp/raw/ directory) and preparsing the metadata into an sqlite database (/var/cache/zypp/zypp.db). +.TP +.I \-f, \-\-force +Force a complete refresh of specified repositories. This option will cause both the download of raw metadata and parsing of the metadata to be forced even if everything indicates a refresh is not needed. +.TP +.I \-b, \-\-force\-build +Force only reparsing of cached metadata and rebuilding of the database. Raw metadata download will not be forced. +.TP +.I \-d, \-\-force\-download +Force only download of current copy of repository metadata. Parsing and rebuild of the database will not be forced. +.TP +.I \-B, \-\-build\-only +Only parse the metadata and build the database, don't download raw metadata into the cache. This will enable you to repair damaged database from cached data without accessing network at all. +.TP +.I \-D, \-\-download\-only +Only download the raw metadata, don't parse it or build the database. .SH "GLOBAL OPTIONS" + .TP .I \-h, \-\-help Help. If a \fBcommand\fR is specified together with --help option, command specific help is displayed. diff --git a/src/zypper-sources.cc b/src/zypper-sources.cc index b146c87..63bad0c 100644 --- a/src/zypper-sources.cc +++ b/src/zypper-sources.cc @@ -312,11 +312,38 @@ int refresh_repos(vector & arguments) // do the refresh try { - cout_n << format(_("Refreshing '%s'")) % it->alias() << endl; - manager.refreshMetadata(repo, RepoManager::RefreshIfNeeded); + if (!copts.count("build-only")) + { + bool force_download = + copts.count("force") || copts.count("force-download"); + + cout_n << format(_("Refreshing '%s'")) % it->alias(); + if (force_download) + cout_n << " " << _("(forced)"); + cout_n << endl; + + MIL << "calling refreshMetadata" << (force_download ? ", forced" : "") + << endl; + + manager.refreshMetadata(repo, force_download ? + RepoManager::RefreshForced : RepoManager::RefreshIfNeeded); + } - cout_v << _("Creating repository cache...") << endl; - manager.buildCache(repo, RepoManager::BuildIfNeeded); + if (!copts.count("download-only")) + { + bool force_build = + copts.count("force") || copts.count("force-build"); + + cout_v << _("Creating repository cache"); + if (force_build) + cout_v << " " << _("(forced)"); + cout_v << endl; + + MIL << "calling buildCache" << (force_build ? ", forced" : "") << endl; + + manager.buildCache(repo, force_build ? + RepoManager::BuildForced : RepoManager::BuildIfNeeded); + } //cout_n << _("DONE") << endl << endl; } diff --git a/src/zypper.cc b/src/zypper.cc index 13f0c26..e625d54 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -415,6 +415,11 @@ int one_command(const ZypperCommand & command, int argc, char **argv) } else if (command == ZypperCommand::REFRESH) { static struct option refresh_options[] = { + {"force", no_argument, 0, 'f'}, + {"force-build", no_argument, 0, 'b'}, + {"force-download", no_argument, 0, 'd'}, + {"build-only", no_argument, 0, 'B'}, + {"download-only", no_argument, 0, 'D'}, {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; @@ -425,7 +430,12 @@ int one_command(const ZypperCommand & command, int argc, char **argv) "Refresh repositories specified by their alias or number." " If none are specified, all enabled repositories will be refreshed.\n" "\n" - "This command has no additional options.\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" ); } else if (command == ZypperCommand::LIST_UPDATES) { -- 2.7.4