index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/alpm.c | 2 | ||||
-rw-r--r-- | lib/libalpm/alpm.h | 39 | ||||
-rw-r--r-- | lib/libalpm/be_local.c | 24 | ||||
-rw-r--r-- | lib/libalpm/db.c | 32 | ||||
-rw-r--r-- | lib/libalpm/handle.c | 24 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 2 | ||||
-rw-r--r-- | src/pacman/conf.c | 2 | ||||
-rw-r--r-- | src/pacman/database.c | 4 | ||||
-rw-r--r-- | src/pacman/deptest.c | 2 | ||||
-rw-r--r-- | src/pacman/query.c | 14 | ||||
-rw-r--r-- | src/pacman/remove.c | 4 | ||||
-rw-r--r-- | src/pacman/sync.c | 22 | ||||
-rw-r--r-- | src/pacman/util.c | 4 | ||||
-rw-r--r-- | src/util/cleanupdelta.c | 2 | ||||
-rw-r--r-- | src/util/pactree.c | 6 | ||||
-rw-r--r-- | src/util/testdb.c | 4 |
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index 3f7ab4ba..2915a05f 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -106,7 +106,7 @@ int SYMEXPORT alpm_release(alpm_handle_t *myhandle) myhandle->db_local = NULL; } - if(alpm_db_unregister_all(myhandle) == -1) { + if(alpm_unregister_all_syncdbs(myhandle) == -1) { ret = -1; } diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 5b7f6275..ca650928 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -553,7 +553,7 @@ int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t leve * libalpm functions. * @return a reference to the local database */ -alpm_db_t *alpm_option_get_localdb(alpm_handle_t *handle); +alpm_db_t *alpm_get_localdb(alpm_handle_t *handle); /** Get the list of sync databases. * Returns a list of alpm_db_t structures, one for each registered @@ -561,7 +561,7 @@ alpm_db_t *alpm_option_get_localdb(alpm_handle_t *handle); * @param handle the context handle * @return a reference to an internal list of alpm_db_t structures */ -alpm_list_t *alpm_option_get_syncdbs(alpm_handle_t *handle); +alpm_list_t *alpm_get_syncdbs(alpm_handle_t *handle); /** Register a sync database of packages. * @param handle the context handle @@ -570,20 +570,20 @@ alpm_list_t *alpm_option_get_syncdbs(alpm_handle_t *handle); * database; note that this must be a '.sig' file type verification * @return an alpm_db_t* on success (the value), NULL on error */ -alpm_db_t *alpm_db_register_sync(alpm_handle_t *handle, const char *treename, +alpm_db_t *alpm_register_syncdb(alpm_handle_t *handle, const char *treename, alpm_siglevel_t level); -/** Unregister a package database. - * @param db pointer to the package database to unregister +/** Unregister all package databases. + * @param handle the context handle * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int alpm_db_unregister(alpm_db_t *db); +int alpm_unregister_all_syncdbs(alpm_handle_t *handle); -/** Unregister all package databases. - * @param handle the context handle +/** Unregister a package database. + * @param db pointer to the package database to unregister * @return 0 on success, -1 on error (pm_errno is set accordingly) */ -int alpm_db_unregister_all(alpm_handle_t *handle); +int alpm_db_unregister(alpm_db_t *db); /** Get the name of a package database. * @param db pointer to the package database @@ -636,7 +636,7 @@ alpm_list_t *alpm_db_get_pkgcache(alpm_db_t *db); * @param name of the group * @return the groups entry on success, NULL on error */ -alpm_group_t *alpm_db_readgroup(alpm_db_t *db, const char *name); +alpm_group_t *alpm_db_get_group(alpm_db_t *db, const char *name); /** Get the group cache of a package database. * @param db pointer to the package database to get the group from @@ -651,15 +651,6 @@ alpm_list_t *alpm_db_get_groupcache(alpm_db_t *db); */ alpm_list_t *alpm_db_search(alpm_db_t *db, const alpm_list_t *needles); -/** Set install reason for a package in db. - * @param handle the context handle - * @param pkg the package to update - * @param reason the new install reason - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int alpm_db_set_pkgreason(alpm_handle_t *handle, alpm_pkg_t *pkg, - alpm_pkgreason_t reason); - /** @} */ /** @addtogroup alpm_api_packages Package Functions @@ -929,6 +920,16 @@ off_t alpm_pkg_download_size(alpm_pkg_t *newpkg); alpm_list_t *alpm_pkg_unused_deltas(alpm_pkg_t *pkg); +/** Set install reason for a package in the local database. + * The provided package object must be from the local database or this method + * will fail. The write to the local database is performed immediately. + * @param pkg the package to update + * @param reason the new install reason + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int alpm_pkg_set_reason(alpm_pkg_t *pkg, alpm_pkgreason_t reason); + + /* End of alpm_pkg */ /** @} */ diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c index 137da1a8..9a8c0ec7 100644 --- a/lib/libalpm/be_local.c +++ b/lib/libalpm/be_local.c @@ -948,6 +948,30 @@ int _alpm_local_db_remove(alpm_db_t *db, alpm_pkg_t *info) return ret; } +int SYMEXPORT alpm_pkg_set_reason(alpm_pkg_t *pkg, alpm_pkgreason_t reason) +{ + ASSERT(pkg != NULL, return -1); + ASSERT(pkg->origin == PKG_FROM_LOCALDB, + RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1)); + ASSERT(pkg->origin_data.db == pkg->handle->db_local, + RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1)); + + _alpm_log(pkg->handle, ALPM_LOG_DEBUG, + "setting install reason %u for %s\n", reason, pkg->name); + if(alpm_pkg_get_reason(pkg) == reason) { + /* we are done */ + return 0; + } + /* set reason (in pkgcache) */ + pkg->reason = reason; + /* write DESC */ + if(_alpm_local_db_write(pkg->handle->db_local, pkg, INFRQ_DESC)) { + RET_ERR(pkg->handle, ALPM_ERR_DB_WRITE, -1); + } + + return 0; +} + struct db_operations local_db_ops = { .validate = local_db_validate, .populate = local_db_populate, diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 6492a9b9..261c2a45 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -43,7 +43,7 @@ */ /** Register a sync database of packages. */ -alpm_db_t SYMEXPORT *alpm_db_register_sync(alpm_handle_t *handle, +alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle, const char *treename, alpm_siglevel_t level) { /* Sanity checks */ @@ -68,7 +68,7 @@ void _alpm_db_unregister(alpm_db_t *db) } /** Unregister all package databases. */ -int SYMEXPORT alpm_db_unregister_all(alpm_handle_t *handle) +int SYMEXPORT alpm_unregister_all_syncdbs(alpm_handle_t *handle) { alpm_list_t *i; alpm_db_t *db; @@ -261,7 +261,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_pkgcache(alpm_db_t *db) } /** Get a group entry from a package database. */ -alpm_group_t SYMEXPORT *alpm_db_readgroup(alpm_db_t *db, const char *name) +alpm_group_t SYMEXPORT *alpm_db_get_group(alpm_db_t *db, const char *name) { ASSERT(db != NULL, return NULL); db->handle->pm_errno = 0; @@ -289,32 +289,6 @@ alpm_list_t SYMEXPORT *alpm_db_search(alpm_db_t *db, const alpm_list_t* needles) return _alpm_db_search(db, needles); } -/** Set install reason for a package in db. */ -int SYMEXPORT alpm_db_set_pkgreason(alpm_handle_t *handle, alpm_pkg_t *pkg, - alpm_pkgreason_t reason) -{ - CHECK_HANDLE(handle, return -1); - ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); - ASSERT(pkg->origin == PKG_FROM_LOCALDB, - RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); - ASSERT(pkg->origin_data.db == handle->db_local, - RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1)); - - _alpm_log(handle, ALPM_LOG_DEBUG, - "setting install reason %u for %s\n", reason, pkg->name); - if(alpm_pkg_get_reason(pkg) == reason) { - /* we are done */ - return 0; - } - /* set reason (in pkgcache) */ - pkg->reason = reason; - /* write DESC */ - if(_alpm_local_db_write(handle->db_local, pkg, INFRQ_DESC)) { - RET_ERR(handle, ALPM_ERR_DB_WRITE, -1); - } - - return 0; -} /** @} */ diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 2187dca9..ec4cc56b 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -265,18 +265,6 @@ int SYMEXPORT alpm_option_get_checkspace(alpm_handle_t *handle) return handle->checkspace; } -alpm_db_t SYMEXPORT *alpm_option_get_localdb(alpm_handle_t *handle) -{ - CHECK_HANDLE(handle, return NULL); - return handle->db_local; -} - -alpm_list_t SYMEXPORT *alpm_option_get_syncdbs(alpm_handle_t *handle) -{ - CHECK_HANDLE(handle, return NULL); - return handle->dbs_sync; -} - int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb) { CHECK_HANDLE(handle, return -1); @@ -635,4 +623,16 @@ alpm_siglevel_t SYMEXPORT alpm_option_get_default_siglevel(alpm_handle_t *handle return handle->siglevel; } +alpm_db_t SYMEXPORT *alpm_get_localdb(alpm_handle_t *handle) +{ + CHECK_HANDLE(handle, return NULL); + return handle->db_local; +} + +alpm_list_t SYMEXPORT *alpm_get_syncdbs(alpm_handle_t *handle) +{ + CHECK_HANDLE(handle, return NULL); + return handle->dbs_sync; +} + /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 6967b49b..94788294 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -248,7 +248,7 @@ alpm_list_t SYMEXPORT *alpm_find_group_pkgs(alpm_list_t *dbs, for(i = dbs; i; i = i->next) { alpm_db_t *db = i->data; - alpm_group_t *grp = alpm_db_readgroup(db, name); + alpm_group_t *grp = alpm_db_get_group(db, name); if(!grp) continue; diff --git a/src/pacman/conf.c b/src/pacman/conf.c index e1bff189..bfa8cad6 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -664,7 +664,7 @@ static int finish_section(struct section_t *section, int parse_options) } /* if we are not looking at options sections only, register a db */ - db = alpm_db_register_sync(config->handle, section->name, section->siglevel); + db = alpm_register_syncdb(config->handle, section->name, section->siglevel); if(db == NULL) { pm_printf(ALPM_LOG_ERROR, _("could not register '%s' database (%s)\n"), section->name, alpm_strerror(alpm_errno(config->handle))); diff --git a/src/pacman/database.c b/src/pacman/database.c index b9736618..f8795c04 100644 --- a/src/pacman/database.c +++ b/src/pacman/database.c @@ -61,11 +61,11 @@ int pacman_database(alpm_list_t *targets) return 1; } - db_local = alpm_option_get_localdb(config->handle); + db_local = alpm_get_localdb(config->handle); for(i = targets; i; i = alpm_list_next(i)) { char *pkgname = i->data; alpm_pkg_t *pkg = alpm_db_get_pkg(db_local, pkgname); - if(!pkg || alpm_db_set_pkgreason(config->handle, pkg, reason)) { + if(!pkg || alpm_pkg_set_reason(pkg, reason)) { pm_printf(ALPM_LOG_ERROR, _("could not set install reason for package %s (%s)\n"), pkgname, alpm_strerror(alpm_errno(config->handle))); retval = 1; diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index 63e7985d..ecca36ef 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -31,7 +31,7 @@ int pacman_deptest(alpm_list_t *targets) { alpm_list_t *i; alpm_list_t *deps = NULL; - alpm_db_t *localdb = alpm_option_get_localdb(config->handle); + alpm_db_t *localdb = alpm_get_localdb(config->handle); for(i = targets; i; i = alpm_list_next(i)) { char *target = i->data; diff --git a/src/pacman/query.c b/src/pacman/query.c index 66813e35..0a6891aa 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -132,7 +132,7 @@ static int query_fileowner(alpm_list_t *targets) } strcpy(path, root); - db_local = alpm_option_get_localdb(config->handle); + db_local = alpm_get_localdb(config->handle); for(t = targets; t; t = alpm_list_next(t)) { char *filename, *dname, *rpath; @@ -245,7 +245,7 @@ static int query_search(alpm_list_t *targets) { alpm_list_t *i, *searchlist; int freelist; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); /* if we have a targets list, search for packages matching it */ if(targets) { @@ -304,7 +304,7 @@ static int query_group(alpm_list_t *targets) alpm_list_t *i, *j; const char *grpname = NULL; int ret = 0; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); if(targets == NULL) { for(j = alpm_db_get_groupcache(db_local); j; j = alpm_list_next(j)) { @@ -320,7 +320,7 @@ static int query_group(alpm_list_t *targets) for(i = targets; i; i = alpm_list_next(i)) { alpm_group_t *grp; grpname = i->data; - grp = alpm_db_readgroup(db_local, grpname); + grp = alpm_db_get_group(db_local, grpname); if(grp) { const alpm_list_t *p; for(p = grp->packages; p; p = alpm_list_next(p)) { @@ -344,7 +344,7 @@ static int is_foreign(alpm_pkg_t *pkg) { const char *pkgname = alpm_pkg_get_name(pkg); alpm_list_t *j; - alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle); + alpm_list_t *sync_dbs = alpm_get_syncdbs(config->handle); int match = 0; for(j = sync_dbs; j; j = alpm_list_next(j)) { @@ -393,7 +393,7 @@ static int filter(alpm_pkg_t *pkg) } /* check if this pkg is outdated */ if(config->op_q_upgrade && (alpm_sync_newversion(pkg, - alpm_option_get_syncdbs(config->handle)) == NULL)) { + alpm_get_syncdbs(config->handle)) == NULL)) { return 0; } return 1; @@ -512,7 +512,7 @@ int pacman_query(alpm_list_t *targets) } } - db_local = alpm_option_get_localdb(config->handle); + db_local = alpm_get_localdb(config->handle); /* operations on all packages in the local DB * valid: no-op (plain -Q), list, info, check diff --git a/src/pacman/remove.c b/src/pacman/remove.c index 3de57695..d6378236 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -38,7 +38,7 @@ static int fnmatch_cmp(const void *pattern, const void *string) static int remove_target(const char *target) { alpm_pkg_t *pkg; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); alpm_list_t *p; if((pkg = alpm_db_get_pkg(db_local, target)) != NULL) { @@ -52,7 +52,7 @@ static int remove_target(const char *target) } /* fallback to group */ - alpm_group_t *grp = alpm_db_readgroup(db_local, target); + alpm_group_t *grp = alpm_db_get_group(db_local, target); if(grp == NULL) { pm_printf(ALPM_LOG_ERROR, "'%s': target not found\n", target); return -1; diff --git a/src/pacman/sync.c b/src/pacman/sync.c index e22f94f7..700bb780 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -49,7 +49,7 @@ static int sync_cleandb(const char *dbpath, int keep_used) return 1; } - syncdbs = alpm_option_get_syncdbs(config->handle); + syncdbs = alpm_get_syncdbs(config->handle); rewinddir(dir); /* step through the directory one file at a time */ @@ -147,8 +147,8 @@ static int sync_cleandb_all(void) static int sync_cleancache(int level) { alpm_list_t *i; - alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle); - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_list_t *sync_dbs = alpm_get_syncdbs(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); alpm_list_t *cachedirs = alpm_option_get_cachedirs(config->handle); int ret = 0; @@ -320,7 +320,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) alpm_list_t *i, *j, *ret; int freelist; int found = 0; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); for(i = syncs; i; i = alpm_list_next(i)) { alpm_db_t *db = i->data; @@ -389,7 +389,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) const char *grpname = i->data; for(j = syncs; j; j = alpm_list_next(j)) { alpm_db_t *db = j->data; - alpm_group_t *grp = alpm_db_readgroup(db, grpname); + alpm_group_t *grp = alpm_db_get_group(db, grpname); if(grp) { /* get names of packages in group */ @@ -496,7 +496,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets) static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) { alpm_list_t *i, *j, *ls = NULL; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); if(targets) { for(i = targets; i; i = alpm_list_next(i)) { @@ -551,8 +551,8 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) static alpm_list_t *syncfirst(void) { alpm_list_t *i, *res = NULL; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); - alpm_list_t *syncdbs = alpm_option_get_syncdbs(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); + alpm_list_t *syncdbs = alpm_get_syncdbs(config->handle); for(i = config->syncfirst; i; i = alpm_list_next(i)) { const char *pkgname = i->data; @@ -572,7 +572,7 @@ static alpm_list_t *syncfirst(void) { static alpm_db_t *get_db(const char *dbname) { alpm_list_t *i; - for(i = alpm_option_get_syncdbs(config->handle); i; i = i->next) { + for(i = alpm_get_syncdbs(config->handle); i; i = i->next) { alpm_db_t *db = i->data; if(strcmp(alpm_db_get_name(db), dbname) == 0) { return db; @@ -709,7 +709,7 @@ static int process_target(const char *target, int error) alpm_list_free(dblist); } else { targname = targstring; - dblist = alpm_option_get_syncdbs(config->handle); + dblist = alpm_get_syncdbs(config->handle); ret = process_targname(dblist, targname, error); } @@ -911,7 +911,7 @@ int pacman_sync(alpm_list_t *targets) return 1; } - sync_dbs = alpm_option_get_syncdbs(config->handle); + sync_dbs = alpm_get_syncdbs(config->handle); if(config->op_s_sync) { /* grab a fresh package list */ diff --git a/src/pacman/util.c b/src/pacman/util.c index 27efdb0a..49beb83d 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -104,7 +104,7 @@ int check_syncdbs(size_t need_repos, int check_valid) { int ret = 0; alpm_list_t *i; - alpm_list_t *sync_dbs = alpm_option_get_syncdbs(config->handle); + alpm_list_t *sync_dbs = alpm_get_syncdbs(config->handle); if(need_repos && sync_dbs == NULL) { pm_printf(ALPM_LOG_ERROR, _("no usable package repositories configured.\n")); @@ -977,7 +977,7 @@ static int pkg_cmp(const void *p1, const void *p2) void display_targets(void) { alpm_list_t *i, *targets = NULL; - alpm_db_t *db_local = alpm_option_get_localdb(config->handle); + alpm_db_t *db_local = alpm_get_localdb(config->handle); for(i = alpm_trans_get_add(config->handle); i; i = alpm_list_next(i)) { alpm_pkg_t *pkg = i->data; diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index ea34fe7f..2f7720b5 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -71,7 +71,7 @@ static void checkdbs(alpm_list_t *dbnames) { for(i = dbnames; i; i = alpm_list_next(i)) { const char *dbname = i->data; - db = alpm_db_register_sync(handle, dbname, level); + db = alpm_register_syncdb(handle, dbname, level); if(db == NULL) { fprintf(stderr, "error: could not register sync database '%s' (%s)\n", dbname, alpm_strerror(alpm_errno(handle))); diff --git a/src/util/pactree.c b/src/util/pactree.c index 0adc2ea8..a7dab9f1 100644 --- a/src/util/pactree.c +++ b/src/util/pactree.c @@ -184,7 +184,7 @@ static int register_syncs(void) { section = strndup(&line[1], linelen - 2); if(section && strcmp(section, "options") != 0) { - alpm_db_register_sync(handle, section, level); + alpm_register_syncdb(handle, section, level); } } } @@ -468,9 +468,9 @@ int main(int argc, char *argv[]) ret = 1; goto finish; } - dblist = alpm_option_get_syncdbs(handle); + dblist = alpm_get_syncdbs(handle); } else { - dblist = alpm_list_add(dblist, alpm_option_get_localdb(handle)); + dblist = alpm_list_add(dblist, alpm_get_localdb(handle)); freelist = 1; } diff --git a/src/util/testdb.c b/src/util/testdb.c index c12aee04..f3a7b659 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -207,7 +207,7 @@ static int check_localdb(void) return ret; } - db = alpm_option_get_localdb(handle); + db = alpm_get_localdb(handle); pkglist = alpm_db_get_pkgcache(db); ret += check_deps(pkglist); ret += check_conflicts(pkglist); @@ -224,7 +224,7 @@ static int check_syncdbs(alpm_list_t *dbnames) for(i = dbnames; i; i = alpm_list_next(i)) { const char *dbname = i->data; - db = alpm_db_register_sync(handle, dbname, level); + db = alpm_register_syncdb(handle, dbname, level); if(db == NULL) { fprintf(stderr, "error: could not register sync database (%s)\n", alpm_strerror(alpm_errno(handle))); |