index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | src/util/cleanupdelta.c | 26 |
diff --git a/src/util/cleanupdelta.c b/src/util/cleanupdelta.c index 71ba3a47..98291706 100644 --- a/src/util/cleanupdelta.c +++ b/src/util/cleanupdelta.c @@ -29,9 +29,11 @@ #define BASENAME "cleanupdelta" +pmhandle_t *handle = NULL; + static void cleanup(int signum) { - if(alpm_release() == -1) { - fprintf(stderr, "error releasing alpm: %s\n", alpm_strerrorlast()); + if(handle && alpm_release(handle) == -1) { + fprintf(stderr, "error releasing alpm\n"); } exit(signum); @@ -65,7 +67,7 @@ static void checkpkgs(alpm_list_t *pkglist) } } -static void checkdbs(char *dbpath, alpm_list_t *dbnames) { +static void checkdbs(const char *dbpath, alpm_list_t *dbnames) { char syncdbpath[PATH_MAX]; pmdb_t *db = NULL; alpm_list_t *i; @@ -73,10 +75,10 @@ static void checkdbs(char *dbpath, alpm_list_t *dbnames) { for(i = dbnames; i; i = alpm_list_next(i)) { char *dbname = alpm_list_getdata(i); snprintf(syncdbpath, PATH_MAX, "%s/sync/%s", dbpath, dbname); - db = alpm_db_register_sync(dbname); + db = alpm_db_register_sync(handle, dbname); if(db == NULL) { fprintf(stderr, "error: could not register sync database (%s)\n", - alpm_strerrorlast()); + alpm_strerror(alpm_errno(handle))); return; } checkpkgs(alpm_db_get_pkgcache(db)); @@ -93,7 +95,8 @@ static void usage(void) { int main(int argc, char *argv[]) { - char *dbpath = DBPATH; + const char *dbpath = DBPATH; + enum _pmerrno_t err; int a = 1; alpm_list_t *dbnames = NULL; @@ -117,15 +120,14 @@ int main(int argc, char *argv[]) usage(); } - if(alpm_initialize() == -1) { - fprintf(stderr, "cannot initialize alpm: %s\n", alpm_strerrorlast()); - return(1); + handle = alpm_initialize(ROOTDIR, dbpath, &err); + if(!handle) { + fprintf(stderr, "cannot initialize alpm: %s\n", alpm_strerror(err)); + return 1; } /* let us get log messages from libalpm */ - alpm_option_set_logcb(output_cb); - - alpm_option_set_dbpath(dbpath); + alpm_option_set_logcb(handle, output_cb); checkdbs(dbpath,dbnames); alpm_list_free(dbnames); |