Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/util/testpkg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/testpkg.c')
-rw-r--r--src/util/testpkg.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/util/testpkg.c b/src/util/testpkg.c
index d0d9cac1..ac2dde28 100644
--- a/src/util/testpkg.c
+++ b/src/util/testpkg.c
@@ -24,14 +24,14 @@
#define BASENAME "testpkg"
-static void output_cb(pmloglevel_t level, const char *fmt, va_list args)
+static void output_cb(alpm_loglevel_t level, const char *fmt, va_list args)
{
if(fmt[0] == '\0') {
return;
}
switch(level) {
- case PM_LOG_ERROR: printf("error: "); break;
- case PM_LOG_WARNING: printf("warning: "); break;
+ case ALPM_LOG_ERROR: printf("error: "); break;
+ case ALPM_LOG_WARNING: printf("warning: "); break;
default: return; /* skip other messages */
}
vprintf(fmt, args);
@@ -40,32 +40,38 @@ static void output_cb(pmloglevel_t level, const char *fmt, va_list args)
int main(int argc, char *argv[])
{
int retval = 1; /* default = false */
- pmpkg_t *pkg = NULL;
+ alpm_handle_t *handle;
+ enum _alpm_errno_t err;
+ alpm_pkg_t *pkg = NULL;
+ const alpm_siglevel_t level = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL;
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) {
- case PM_ERR_PKG_OPEN:
+ if(alpm_pkg_load(handle, argv[1], 1, level, &pkg) == -1
+ || pkg == NULL) {
+ err = alpm_errno(handle);
+ switch(err) {
+ case ALPM_ERR_PKG_OPEN:
printf("Cannot open the given file.\n");
break;
- case PM_ERR_LIBARCHIVE:
- case PM_ERR_PKG_INVALID:
+ case ALPM_ERR_LIBARCHIVE:
+ case ALPM_ERR_PKG_INVALID:
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 +81,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;
}