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);
|
||||
|
Reference in New Issue
Block a user