summaryrefslogtreecommitdiffstats
path: root/src/util/testpkg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/testpkg.c')
-rw-r--r--src/util/testpkg.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index d0d9cac1..c6f02e34 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -40,23 +40,28 @@ static void output_cb(pmloglevel_t level, const char *fmt, va_list args)
int main(int argc, char *argv[])
{
int retval = 1; /* default = false */
+ pmhandle_t *handle;
+ enum _pmerrno_t err;
pmpkg_t *pkg = NULL;
if(argc != 2) {
fprintf(stderr, "usage: %s <package file>\n", BASENAME);
- return(1);
+ return 1;
}
- 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_logcb(handle, output_cb);
- if(alpm_pkg_load(argv[1], 1, &pkg) == -1 || pkg == NULL) {
- switch(pm_errno) {
+ if(alpm_pkg_load(handle, argv[1], 1, PM_PGP_VERIFY_OPTIONAL, &pkg) == -1
+ || pkg == NULL) {
+ enum _pmerrno_t err = alpm_errno(handle);
+ switch(err) {
case PM_ERR_PKG_OPEN:
printf("Cannot open the given file.\n");
break;
@@ -65,7 +70,7 @@ int main(int argc, char *argv[])
printf("Package is invalid.\n");
break;
default:
- printf("libalpm error: %s\n", alpm_strerrorlast());
+ printf("libalpm error: %s\n", alpm_strerror(err));
break;
}
retval = 1;
@@ -75,9 +80,9 @@ int main(int argc, char *argv[])
retval = 0;
}
- if(alpm_release() == -1) {
- fprintf(stderr, "error releasing alpm: %s\n", alpm_strerrorlast());
+ if(alpm_release(handle) == -1) {
+ fprintf(stderr, "error releasing alpm\n");
}
- return(retval);
+ return retval;
}