bin/xbps-pkgdb: use -errno values for error states
...when checking a package. This will give more relevant information than before, removes a message that is misleading in many cases, and allows for some minor simplification. before: ``` $ doas xbps-pkgdb runit-void; echo $? ERROR: runit-void: hash mismatch for /etc/runit/2. ERROR: runit-void: files check FAILED. Failed to check `runit-void': Operation not permitted 1 ``` after: ``` $ doas xbps-pkgdb runit-void; echo $? ERROR: runit-void: hash mismatch for /etc/runit/2. ERROR: runit-void: files check FAILED. 1 ``` this does not change the behaviour of `xbps-pkgdb -a`
This commit is contained in:
parent
c78231f00c
commit
79f29ed53e
@ -100,7 +100,7 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
xbps_error_printf("%s: cannot read %s, ignoring...\n",
|
||||
pkgname, buf);
|
||||
free(buf);
|
||||
return -1;
|
||||
return -ENOENT;
|
||||
}
|
||||
rv = xbps_file_sha256_check(buf, sha256);
|
||||
free(buf);
|
||||
@ -112,7 +112,7 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
xbps_object_release(filesd);
|
||||
xbps_error_printf("%s: metadata file has been "
|
||||
"modified!\n", pkgname);
|
||||
return 1;
|
||||
return -rv;
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,5 +135,5 @@ do { \
|
||||
|
||||
#undef RUN_PKG_CHECK
|
||||
|
||||
return errors ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
return errors;
|
||||
}
|
||||
|
@ -183,9 +183,9 @@ main(int argc, char **argv)
|
||||
} else {
|
||||
for (i = optind; i < argc; i++) {
|
||||
rv = check_pkg_integrity(&xh, NULL, argv[i]);
|
||||
if (rv != 0)
|
||||
if (rv < 0)
|
||||
xbps_error_printf("Failed to check "
|
||||
"`%s': %s\n", argv[i], strerror(rv));
|
||||
"`%s': %s\n", argv[i], strerror(-rv));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user