Use xbps_get_root() directly where appropiate.
--HG-- extra : convert_revision : xtraeme%40gmail.com-20091027111547-tb38qz51ejakn3jc
This commit is contained in:
parent
ac897c8383
commit
dc258f4e20
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
13
lib/purge.c
13
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user