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:
Juan RP
2010-11-06 06:44:00 +01:00
parent f8629652da
commit ec7cdde1e0
22 changed files with 228 additions and 461 deletions

View File

@ -154,13 +154,11 @@ xbps_check_is_repo_string_remote(const char *uri)
static const char *
xbps_get_pkgver_from_dict(prop_dictionary_t d)
{
const char *pkgver;
const char *pkgver = NULL;
assert(d != NULL);
if (!prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver))
return NULL;
prop_dictionary_get_cstring_nocopy(d, "pkgver", &pkgver);
return pkgver;
}
@ -379,10 +377,8 @@ xbps_get_binpkg_local_path(prop_dictionary_t pkgd, const char *repoloc)
{
const char *filen, *arch, *cdir;
if (!prop_dictionary_get_cstring_nocopy(pkgd, "filename", &filen))
return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch))
return NULL;
prop_dictionary_get_cstring_nocopy(pkgd, "filename", &filen);
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
cdir = xbps_get_cachedir();
if (cdir == NULL)
return NULL;
@ -419,7 +415,7 @@ const char *
xbps_get_rootdir(void)
{
if (rootdir == NULL)
rootdir = "";
rootdir = "/";
return rootdir;
}