diff --git a/bin/xbps-bin/check.c b/bin/xbps-bin/check.c index 4df8895f..49693318 100644 --- a/bin/xbps-bin/check.c +++ b/bin/xbps-bin/check.c @@ -84,14 +84,13 @@ xbps_check_pkg_integrity(const char *pkgname) prop_array_t array; prop_object_t obj; prop_object_iterator_t iter; - const char *rootdir, *file, *sha256, *reqpkg; + const char *file, *sha256, *reqpkg; char *path; int rv = 0; bool broken = false, files_broken = false; assert(pkgname != NULL); - rootdir = xbps_get_rootdir(); pkgd = xbps_find_pkg_installed_from_plist(pkgname); if (pkgd == NULL) { printf("Package %s is not installed.\n", pkgname); @@ -101,7 +100,7 @@ xbps_check_pkg_integrity(const char *pkgname) /* * Check for props.plist metadata file. */ - path = xbps_xasprintf("%s/%s/metadata/%s/%s", rootdir, + path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, pkgname, XBPS_PKGPROPS); if (path == NULL) { rv = errno; @@ -130,7 +129,7 @@ xbps_check_pkg_integrity(const char *pkgname) /* * Check for files.plist metadata file. */ - path = xbps_xasprintf("%s/%s/metadata/%s/%s", rootdir, + path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, pkgname, XBPS_PKGFILES); if (path == NULL) { rv = errno; @@ -176,7 +175,8 @@ xbps_check_pkg_integrity(const char *pkgname) } while ((obj = prop_object_iterator_next(iter))) { prop_dictionary_get_cstring_nocopy(obj, "file", &file); - path = xbps_xasprintf("%s/%s", rootdir, file); + path = xbps_xasprintf("%s/%s", + xbps_get_rootdir(), file); if (path == NULL) { prop_object_iterator_release(iter); rv = errno; @@ -225,7 +225,8 @@ xbps_check_pkg_integrity(const char *pkgname) } while ((obj = prop_object_iterator_next(iter))) { prop_dictionary_get_cstring_nocopy(obj, "file", &file); - path = xbps_xasprintf("%s/%s", rootdir, file); + path = xbps_xasprintf("%s/%s", + xbps_get_rootdir(), file); if (path == NULL) { prop_object_iterator_release(iter); rv = ENOMEM; diff --git a/bin/xbps-bin/show-deps.c b/bin/xbps-bin/show-deps.c index 9d176dc0..427b2651 100644 --- a/bin/xbps-bin/show-deps.c +++ b/bin/xbps-bin/show-deps.c @@ -60,13 +60,11 @@ int xbps_show_pkg_deps(const char *pkgname) { prop_dictionary_t pkgd, propsd; - const char *rootdir; char *path; int rv = 0; assert(pkgname != NULL); - rootdir = xbps_get_rootdir(); pkgd = xbps_find_pkg_installed_from_plist(pkgname); if (pkgd == NULL) { printf("Package %s is not installed.\n", pkgname); @@ -76,7 +74,7 @@ xbps_show_pkg_deps(const char *pkgname) /* * Check for props.plist metadata file. */ - path = xbps_xasprintf("%s/%s/metadata/%s/%s", rootdir, + path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, pkgname, XBPS_PKGPROPS); if (path == NULL) return errno; diff --git a/bin/xbps-repo/util.c b/bin/xbps-repo/util.c index 48058d82..dc57139f 100644 --- a/bin/xbps-repo/util.c +++ b/bin/xbps-repo/util.c @@ -155,11 +155,9 @@ int show_pkg_info_from_metadir(const char *pkgname) { prop_dictionary_t pkgd; - const char *rootdir; char *plist; - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/metadata/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, pkgname, XBPS_PKGPROPS); if (plist == NULL) return EINVAL; @@ -184,12 +182,11 @@ show_pkg_files_from_metadir(const char *pkgname) prop_array_t array; prop_object_iterator_t iter = NULL; prop_object_t obj; - const char *destdir, *file; + const char *file; char *plist, *array_str = "files"; int i, rv = 0; - destdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/metadata/%s/%s", destdir, + plist = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, pkgname, XBPS_PKGFILES); if (plist == NULL) return EINVAL; diff --git a/lib/findpkg.c b/lib/findpkg.c index 8a307739..7f7fdd43 100644 --- a/lib/findpkg.c +++ b/lib/findpkg.c @@ -101,7 +101,6 @@ xbps_prepare_repolist_data(void) prop_object_t obj; prop_object_iterator_t iter; struct repository_data *rdata; - const char *rootdir; char *plist; int rv = 0; static bool repodata_initialized; @@ -111,11 +110,7 @@ xbps_prepare_repolist_data(void) SIMPLEQ_INIT(&repodata_queue); - rootdir = xbps_get_rootdir(); - if (rootdir == NULL) - rootdir = ""; - - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REPOLIST); if (plist == NULL) { rv = EINVAL; diff --git a/lib/plist.c b/lib/plist.c index b27f887f..3dd355bb 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -71,14 +71,12 @@ xbps_callback_array_iter_in_repolist(int (*fn)(prop_object_t, void *, bool *), void *arg) { prop_dictionary_t repolistd; - const char *rootdir; char *plist; int rv = 0; assert(fn != NULL); - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REPOLIST); if (plist == NULL) return EINVAL; @@ -244,12 +242,10 @@ xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key, prop_dictionary_t SYMEXPORT xbps_prepare_regpkgdb_dict(void) { - const char *rootdir; char *plist; if (regpkgdb_initialized == false) { - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) return NULL; diff --git a/lib/purge.c b/lib/purge.c index e2735010..f69bcec7 100644 --- a/lib/purge.c +++ b/lib/purge.c @@ -78,13 +78,12 @@ xbps_purge_pkg(const char *pkgname, bool check_state) prop_array_t array; prop_object_t obj; prop_object_iterator_t iter; - const char *rootdir, *file, *sha256; + const char *file, *sha256; char *path; int rv = 0, flags; pkg_state_t state = 0; assert(pkgname != NULL); - rootdir = xbps_get_rootdir(); flags = xbps_get_flags(); if (check_state) { @@ -102,8 +101,8 @@ xbps_purge_pkg(const char *pkgname, bool check_state) * Iterate over the pkg file list dictionary and remove all * unmodified configuration files. */ - path = xbps_xasprintf("%s/%s/metadata/%s/%s", - rootdir, XBPS_META_PATH, pkgname, XBPS_PKGFILES); + path = xbps_xasprintf("%s/%s/metadata/%s/%s", xbps_get_rootdir(), + XBPS_META_PATH, pkgname, XBPS_PKGFILES); if (path == NULL) return errno; @@ -134,7 +133,7 @@ xbps_purge_pkg(const char *pkgname, bool check_state) prop_object_release(dict); return EINVAL; } - path = xbps_xasprintf("%s/%s", rootdir, file); + path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file); if (path == NULL) { prop_object_iterator_release(iter); prop_object_release(dict); @@ -191,16 +190,14 @@ remove_pkg_metadata(const char *pkgname) { struct dirent *dp; DIR *dirp; - const char *rootdir; char *metadir, *path; int flags = 0, rv = 0; assert(pkgname != NULL); - rootdir = xbps_get_rootdir(); flags = xbps_get_flags(); - metadir = xbps_xasprintf("%s/%s/metadata/%s", rootdir, + metadir = xbps_xasprintf("%s/%s/metadata/%s", xbps_get_rootdir(), XBPS_META_PATH, pkgname); if (metadir == NULL) return errno; diff --git a/lib/register.c b/lib/register.c index 0a15d246..996dd25e 100644 --- a/lib/register.c +++ b/lib/register.c @@ -35,12 +35,11 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) { prop_dictionary_t dict, pkgd; prop_array_t array; - const char *pkgname, *version, *desc, *rootdir; + const char *pkgname, *version, *desc; char *plist; int rv = 0; - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) return EINVAL; @@ -95,14 +94,12 @@ out: int SYMEXPORT xbps_unregister_pkg(const char *pkgname) { - const char *rootdir; char *plist; int rv = 0; assert(pkgname != NULL); - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) return EINVAL; diff --git a/lib/remove.c b/lib/remove.c index bdeef61c..ecaa1c09 100644 --- a/lib/remove.c +++ b/lib/remove.c @@ -41,11 +41,10 @@ remove_pkg_files(prop_dictionary_t dict) prop_object_iterator_t iter; prop_object_t obj; prop_bool_t bobj; - const char *file, *rootdir, *sha256; + const char *file, *sha256; char *path = NULL; int flags = 0, rv = 0; - rootdir = xbps_get_rootdir(); flags = xbps_get_flags(); /* Links */ @@ -62,7 +61,7 @@ remove_pkg_files(prop_dictionary_t dict) prop_object_iterator_release(iter); return EINVAL; } - path = xbps_xasprintf("%s/%s", rootdir, file); + path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file); if (path == NULL) { prop_object_iterator_release(iter); return EINVAL; @@ -97,7 +96,7 @@ files: prop_object_iterator_release(iter); return EINVAL; } - path = xbps_xasprintf("%s/%s", rootdir, file); + path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file); if (path == NULL) { prop_object_iterator_release(iter); return EINVAL; @@ -155,7 +154,7 @@ dirs: prop_object_iterator_release(iter); return EINVAL; } - path = xbps_xasprintf("%s/%s", rootdir, file); + path = xbps_xasprintf("%s/%s", xbps_get_rootdir(), file); if (path == NULL) { prop_object_iterator_release(iter); return EINVAL; diff --git a/lib/repository.c b/lib/repository.c index 32492fa1..267b61c6 100644 --- a/lib/repository.c +++ b/lib/repository.c @@ -36,14 +36,12 @@ xbps_register_repository(const char *uri) prop_dictionary_t dict; prop_array_t array; prop_object_t obj = NULL; - const char *rootdir; char *plist; int rv = 0; assert(uri != NULL); - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REPOLIST); if (plist == NULL) return errno; @@ -113,14 +111,12 @@ xbps_unregister_repository(const char *uri) { prop_dictionary_t dict; prop_array_t array; - const char *rootdir; char *plist; int rv = 0; assert(uri != NULL); - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REPOLIST); if (plist == NULL) return errno; diff --git a/lib/requiredby.c b/lib/requiredby.c index 6e5377d8..43d51012 100644 --- a/lib/requiredby.c +++ b/lib/requiredby.c @@ -120,12 +120,10 @@ int SYMEXPORT xbps_requiredby_pkg_remove(const char *pkgname) { prop_dictionary_t dict; - const char *rootdir; char *plist; int rv = 0; - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) return EINVAL; diff --git a/lib/state.c b/lib/state.c index 25a571e0..66e8a5cf 100644 --- a/lib/state.c +++ b/lib/state.c @@ -96,12 +96,10 @@ int SYMEXPORT xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state) { prop_dictionary_t dict, pkgd; - const char *rootdir; char *plist; assert(pkgname != NULL); - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) return errno; @@ -152,13 +150,11 @@ xbps_set_pkg_state_installed(const char *pkgname, pkg_state_t state) { prop_dictionary_t dict, pkgd; prop_array_t array; - const char *rootdir; char *plist; int rv = 0; bool newpkg = false; - rootdir = xbps_get_rootdir(); - plist = xbps_xasprintf("%s/%s/%s", rootdir, + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) return EINVAL;