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:
@@ -111,16 +111,8 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
|
||||
"file, skipping!\n", file, XBPS_PKGPROPS);
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_get_cstring_nocopy(newpkgd, "pkgname", &pkgname)) {
|
||||
prop_object_release(newpkgd);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_get_cstring_nocopy(newpkgd, "version", &version)) {
|
||||
prop_object_release(newpkgd);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "version", &version);
|
||||
/*
|
||||
* Check if this package exists already in the index, but first
|
||||
* checking the version. If current package version is greater
|
||||
@@ -135,12 +127,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
|
||||
goto out;
|
||||
}
|
||||
} else if (curpkgd) {
|
||||
if (!prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"version", ®ver)) {
|
||||
prop_object_release(newpkgd);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd, "version", ®ver);
|
||||
if (xbps_cmpver(version, regver) <= 0) {
|
||||
fprintf(stderr, "W: skipping %s. %s-%s already "
|
||||
"registered.\n", filen, pkgname, regver);
|
||||
@@ -153,12 +140,8 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
|
||||
* in package index, remove outdated binpkg file
|
||||
* and its dictionary from the pkg index.
|
||||
*/
|
||||
if (!prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"filename", &oldfilen)) {
|
||||
prop_object_release(newpkgd);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd,
|
||||
"filename", &oldfilen);
|
||||
oldfilepath = xbps_xasprintf("%s/%s", filedir, oldfilen);
|
||||
if (oldfilepath == NULL) {
|
||||
prop_object_release(newpkgd);
|
||||
|
@@ -292,11 +292,7 @@ show_pkg_deps_from_repolist(const char *pkgname)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"version", &ver)) {
|
||||
rv = errno;
|
||||
break;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "version", &ver);
|
||||
printf("Repository %s [pkgver: %s]\n", rd->rp_uri, ver);
|
||||
(void)xbps_callback_array_iter_in_dict(pkgd,
|
||||
"run_depends", list_strings_sep_in_array, NULL);
|
||||
|
@@ -164,11 +164,7 @@ show_pkg_files(prop_dictionary_t filesd)
|
||||
return EINVAL;
|
||||
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"file", &file)) {
|
||||
prop_object_iterator_release(iter);
|
||||
return errno;
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||
printf("%s\n", file);
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
|
Reference in New Issue
Block a user