[pacman-dev] [PATCH] Do not warn about missing database if being downloaded

Allan McRae allan at archlinux.org
Mon Oct 29 01:37:35 EDT 2012


When a configured repo database is not already downloaded, a warning
message such as "warning: database file for 'testing' does not exist"
is printed.  Disable this warning when the database is scheduled to
be downloaded in the transaction.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/alpm.h    | 4 +++-
 lib/libalpm/be_sync.c | 3 +--
 src/pacman/callback.c | 6 ++++++
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 66cd6b0..fb4d845 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -358,7 +358,9 @@ typedef enum _alpm_event_t {
 	ALPM_EVENT_DISKSPACE_DONE,
 	/** An optdepend for another package is being removed
 	 * The requiring package and its dependency are passed to the callback */
-	ALPM_EVENT_OPTDEP_REQUIRED
+	ALPM_EVENT_OPTDEP_REQUIRED,
+	/** A configured repository database is missing */
+	ALPM_EVENT_DATABASE_MISSING
 } alpm_event_t;
 
 /** Event callback */
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 033f8b7..f980246 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -89,8 +89,7 @@ static int sync_db_validate(alpm_db_t *db)
 	if(_alpm_access(db->handle, NULL, dbpath, R_OK) != 0 && errno == ENOENT) {
 		db->status &= ~DB_STATUS_EXISTS;
 		db->status |= DB_STATUS_MISSING;
-		_alpm_log(db->handle, ALPM_LOG_WARNING,
-				"database file for '%s' does not exist\n", db->treename);
+		EVENT(db->handle, ALPM_EVENT_DATABASE_MISSING, db->treename, NULL);
 		goto valid;
 	}
 	db->status |= DB_STATUS_EXISTS;
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index a51aa4b..a249a6e 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -243,6 +243,12 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
 			printf(_(":: %s optionally requires %s\n"), alpm_pkg_get_name(data1),
 				alpm_dep_compute_string(data2));
 			break;
+		case ALPM_EVENT_DATABASE_MISSING:
+			if(!config->op_s_sync) {
+				pm_printf(ALPM_LOG_WARNING,
+					"database file for '%s' does not exist\n", (char *)data1);
+			}
+			break;
 		/* all the simple done events, with fallthrough for each */
 		case ALPM_EVENT_FILECONFLICTS_DONE:
 		case ALPM_EVENT_CHECKDEPS_DONE:
-- 
1.8.0



More information about the pacman-dev mailing list