summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-08-22 03:28:05 +0200
committerDan McGee <dan@archlinux.org>2007-08-22 03:28:05 +0200
commitc22e381a8b86412b6c181446128affe32ab1d71e (patch)
tree198d527a3d49819f57fabd8355673328969cc893 /lib/libalpm/db.c
parent13525255dcd257e69d7c246bf32ceb263fbc31b9 (diff)
downloadpacman-c22e381a8b86412b6c181446128affe32ab1d71e.tar.gz
pacman-c22e381a8b86412b6c181446128affe32ab1d71e.tar.xz
Post trial install changes, round one
A bunch of changes related to my first "real" install of pacman-git into /usr/local and trying to use it. * Shift some uses of free -> FREE in libalpm. * Move stat and sanity checks of config paths into libalpm from the config and argument parsing in pacman.c. * Fix issue where dbpath still was not defined early enough due to its requirement for being used in alpm_db_register. This should be rewritten so it doesn't have this dependency, but this will work for now. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index aa9f5b30..32ac48bc 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -73,7 +73,7 @@ pmdb_t SYMEXPORT *alpm_db_register(const char *treename)
/** Unregister all package databases
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int SYMEXPORT alpm_db_unregister_all()
+int SYMEXPORT alpm_db_unregister_all(void)
{
alpm_list_t *i;
@@ -431,7 +431,7 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles)
/** Get a list of upgradable packages on the current system
* @return a pmsyncpkg_t list of packages that are out of date
*/
-alpm_list_t SYMEXPORT *alpm_db_get_upgrades()
+alpm_list_t SYMEXPORT *alpm_db_get_upgrades(void)
{
alpm_list_t *syncpkgs = NULL;
const alpm_list_t *i, *j, *k, *m;
@@ -592,15 +592,13 @@ pmdb_t *_alpm_db_new(const char *dbpath, const char *treename)
db = calloc(1, sizeof(pmdb_t));
if(db == NULL) {
- _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
- sizeof(pmdb_t));
+ _alpm_log(PM_LOG_ERROR, "calloc : %s\n", strerror(errno));
RET_ERR(PM_ERR_MEMORY, NULL);
}
db->path = calloc(1, pathsize);
if(db->path == NULL) {
- _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"),
- pathsize);
+ _alpm_log(PM_LOG_ERROR, "calloc : %s\n", strerror(errno));
FREE(db);
RET_ERR(PM_ERR_MEMORY, NULL);
}
@@ -723,6 +721,7 @@ pmdb_t *_alpm_db_register(const char *treename)
RET_ERR(PM_ERR_DB_OPEN, NULL);
}
snprintf(path, PATH_MAX, "%s%s", dbpath, treename);
+ /* TODO this is rediculous, we try to do this even if we can't */
if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) {
_alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it",
path);
@@ -731,7 +730,7 @@ pmdb_t *_alpm_db_register(const char *treename)
}
}
- db = _alpm_db_new(handle->dbpath, treename);
+ db = _alpm_db_new(dbpath, treename);
if(db == NULL) {
RET_ERR(PM_ERR_DB_CREATE, NULL);
}