xbps-bin: implemented (WIP) "autoupdate" target.

Some parts in the library related to findings pkgs in repositories
has been improved vastly by caching the dictionary once.

Duplicated code has been added in xbps-bin/install.c, but will
be fixed soon.

--HG--
extra : convert_revision : 2924012a8589a2a6ecaa3863b5091049006c0ef3
This commit is contained in:
Juan RP
2009-05-17 04:09:26 +02:00
parent 951a775432
commit 9f108b4cd2
9 changed files with 506 additions and 225 deletions

View File

@@ -33,6 +33,8 @@
#include <xbps_api.h>
static prop_dictionary_t regpkgdb_dict;
bool
xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
const char *key)
@@ -160,18 +162,14 @@ xbps_find_pkg_from_plist(const char *plist, const char *pkgname)
prop_dictionary_t
xbps_find_pkg_installed_from_plist(const char *pkgname)
{
prop_dictionary_t pkgd;
const char *rootdir;
char *plist;
prop_dictionary_t instd, pkgd;
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
instd = xbps_get_regpkgdb_dict();
if (instd == NULL)
return NULL;
pkgd = xbps_find_pkg_from_plist(plist, pkgname);
free(plist);
pkgd = xbps_find_pkg_in_dict(instd, "packages", pkgname);
xbps_release_regpkgdb_dict();
return pkgd;
}
@@ -202,6 +200,37 @@ xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *key,
return obj;
}
prop_dictionary_t
xbps_get_regpkgdb_dict(void)
{
const char *rootdir;
char *plist;
if (regpkgdb_dict == NULL) {
rootdir = xbps_get_rootdir();
plist = xbps_xasprintf("%s/%s/%s", rootdir,
XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL)
return NULL;
regpkgdb_dict = prop_dictionary_internalize_from_file(plist);
if (regpkgdb_dict == NULL)
return NULL;
}
return prop_dictionary_copy(regpkgdb_dict);
}
void
xbps_release_regpkgdb_dict(void)
{
if (regpkgdb_dict == NULL)
return;
prop_object_release(regpkgdb_dict);
regpkgdb_dict = NULL;
}
bool
xbps_find_string_in_array(prop_array_t array, const char *val)
{