* Move is_local standalone field to status enum
* Create VALID/INVALID flag pair
* Create EXISTS/MISSING flag pair
With these additional fields, we can be more intelligent with database
loading and messages to the user. We now only warn once if a sync
database does not exist and do not continue to try to load it once we
have marked it as missing.
The reason for the flags existing in pairs is so the unknown case can be
represented. There should never be a time when both flags in the same
group are true, but if they are both false, it represents the unknown
case. Care is taken to always manipulate both flags at the same time.
Signed-off-by: Dan McGee <dan@archlinux.org>
---
Allan, this should fix your problem. Some sample output from this patch:
dmcgee@galway ~/projects/pacman (master)
$ sudo ./src/pacman/pacman -Su
warning: database file for 'community' does not exist
:: Starting full system upgrade...
warning: emacs: local (23.3-1) is newer than extra (23.3a-1)
warning: git: local (1.7.6-2) is newer than extra (1.7.6-1)
error: failed to prepare transaction (could not find database)
dmcgee@galway ~/projects/pacman (master)
$ sudo ./src/pacman/pacman -Syu
warning: database file for 'testing' does not exist
warning: database file for 'core' does not exist
warning: database file for 'extra' does not exist
warning: database file for 'community-testing' does not exist
warning: database file for 'multilib' does not exist
warning: database file for 'community' does not exist
warning: database file for 'bogusrepo' does not exist
:: Synchronizing package databases...
testing 15.5K 329.3K/s 00:00:00 [################################################## ##] 100%
core 35.6K 259.1K/s 00:00:00 [################################################## ##] 100%
extra 474.1K 900.9K/s 00:00:01 [################################################## ##] 100%
community-testing 5.1K 1624.3K/s 00:00:00 [################################################## ##] 100%
multilib 26.5K 313.0K/s 00:00:00 [################################################## ##] 100%
community 448.7K 859.9K/s 00:00:01 [################################################## ##] 100%
bogusrepo 2.9K 1418.8K/s 00:00:00 [################################################## ##] 100%
:: Starting full system upgrade...
warning: emacs: local (23.3-1) is newer than extra (23.3a-1)
warning: git: local (1.7.6-2) is newer than extra (1.7.6-1)
warning: scorched3d: local (43.2-1) is newer than community (43.2a-1)
resolving dependencies...
looking for inter-conflicts...
struct db_operations {
@@ -63,16 +68,13 @@ struct __alpm_db_t {
char *treename;
/* do not access directly, use _alpm_db_path(db) for lazy access */
char *_path;
- /* also indicates whether we are RO or RW */
- int is_local;
- /* flags determining validity, loaded caches, etc. */
- enum _alpm_dbstatus_t status;
alpm_pkghash_t *pkgcache;
alpm_list_t *grpcache;
alpm_list_t *servers;
- alpm_siglevel_t siglevel;
-
struct db_operations *ops;
+ /* flags determining validity, local, loaded caches, etc. */
+ enum _alpm_dbstatus_t status;
+ alpm_siglevel_t siglevel;
};
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 19d2c84..a88af5e 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -424,7 +424,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg)
/* We have a DB package. if it is a local package, then we should
* only search the local DB; else search all known sync databases. */
db = pkg->origin_data.db;
- if(db->is_local) {
+ if(db->status & DB_STATUS_LOCAL) {
find_requiredby(pkg, db, &reqs);
} else {
for(i = pkg->handle->dbs_sync; i; i = i->next) {
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 1807e70..a5964b9 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -319,9 +319,12 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
/* ensure all sync database are valid since we will be using them */
for(i = handle->dbs_sync; i; i = i->next) {
const alpm_db_t *db = i->data;
- if(!(db->status & DB_STATUS_VALID)) {
+ if(db->status & DB_STATUS_INVALID) {
RET_ERR(handle, ALPM_ERR_DB_INVALID, -1);
}
+ if(db->status & DB_STATUS_MISSING) {
+ RET_ERR(handle, ALPM_ERR_DB_NOT_FOUND, -1);
+ }
}