Misc cleanups and performance improvements.
- There's no need to check rval for prop_dictionary_get_*, we are sure the objects are there at prop_dictionary_set_* time. - Avoid two chdir(2) calls per INSTALL/REMOVE run. - Avoid using access(2) to check for existence of INSTALL/REMOVE scripts, just try to run the executable directly and check for ENOENT.
This commit is contained in:
@@ -66,18 +66,8 @@ xbps_check_pkg_integrity_all(void)
|
||||
}
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgname", &pkgname)) {
|
||||
prop_object_iterator_release(iter);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"version", &version)) {
|
||||
prop_object_iterator_release(iter);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||
printf("Checking %s-%s ...\n", pkgname, version);
|
||||
if ((rv = xbps_check_pkg_integrity(pkgname)) != 0)
|
||||
nbrokenpkgs++;
|
||||
@@ -192,12 +182,7 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
goto out;
|
||||
}
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"file", &file)) {
|
||||
prop_object_iterator_release(iter);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||
path = xbps_xasprintf("%s/%s",
|
||||
xbps_get_rootdir(), file);
|
||||
if (path == NULL) {
|
||||
@@ -205,13 +190,8 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"sha256", &sha256)) {
|
||||
free(path);
|
||||
prop_object_iterator_release(iter);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"sha256", &sha256);
|
||||
rv = xbps_check_file_hash(path, sha256);
|
||||
switch (rv) {
|
||||
case 0:
|
||||
@@ -253,12 +233,7 @@ xbps_check_pkg_integrity(const char *pkgname)
|
||||
goto out;
|
||||
}
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"file", &file)) {
|
||||
prop_object_iterator_release(iter);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||
path = xbps_xasprintf("%s/%s",
|
||||
xbps_get_rootdir(), file);
|
||||
if (path == NULL) {
|
||||
|
Reference in New Issue
Block a user