mirror of
https://github.com/void-linux/void-packages.git
synced 2025-07-31 01:42:56 +02:00
Fix some issues in repo handling.
--HG-- extra : convert_revision : 5ec7488c8967f50b7e2dce93276accd829c541b3
This commit is contained in:
parent
b13563dbfd
commit
3f7c353356
3 changed files with 40 additions and 19 deletions
|
@ -114,9 +114,9 @@ getrepolist_dict(void)
|
||||||
static const char *
|
static const char *
|
||||||
sanitize_localpath(const char *path)
|
sanitize_localpath(const char *path)
|
||||||
{
|
{
|
||||||
const char *res;
|
static char strtmp[PATH_MAX];
|
||||||
char strtmp[PATH_MAX];
|
|
||||||
char *dirnp, *basenp, *dir, *base;
|
char *dirnp, *basenp, *dir, *base;
|
||||||
|
const char *res;
|
||||||
|
|
||||||
dir = strdup(path);
|
dir = strdup(path);
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
|
@ -124,15 +124,15 @@ sanitize_localpath(const char *path)
|
||||||
|
|
||||||
base = strdup(path);
|
base = strdup(path);
|
||||||
if (base == NULL)
|
if (base == NULL)
|
||||||
goto fail;
|
goto fail2;
|
||||||
|
|
||||||
dirnp = dirname(dir);
|
dirnp = dirname(dir);
|
||||||
if (strcmp(dirnp, ".") == 0)
|
if (strcmp(dirnp, ".") == 0)
|
||||||
goto fail2;
|
goto fail;
|
||||||
|
|
||||||
basenp = basename(base);
|
basenp = basename(base);
|
||||||
if (strcmp(basenp, base) == 0)
|
if (strcmp(basenp, base) == 0)
|
||||||
goto fail2;
|
goto fail;
|
||||||
|
|
||||||
strncpy(strtmp, dirnp, sizeof(strtmp) - 1);
|
strncpy(strtmp, dirnp, sizeof(strtmp) - 1);
|
||||||
strtmp[sizeof(strtmp) - 1] = '\0';
|
strtmp[sizeof(strtmp) - 1] = '\0';
|
||||||
|
@ -143,11 +143,12 @@ sanitize_localpath(const char *path)
|
||||||
free(dir);
|
free(dir);
|
||||||
free(base);
|
free(base);
|
||||||
res = strtmp;
|
res = strtmp;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
fail:
|
fail:
|
||||||
free(dir);
|
|
||||||
fail2:
|
|
||||||
free(base);
|
free(base);
|
||||||
|
fail2:
|
||||||
|
free(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +157,8 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
prop_dictionary_t dict;
|
prop_dictionary_t dict;
|
||||||
repo_info_t *rinfo = NULL;
|
repo_info_t *rinfo = NULL;
|
||||||
const char *dpkgidx, *repolist;
|
const char *dpkgidx;
|
||||||
|
char *repolist;
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
usage();
|
usage();
|
||||||
|
@ -179,19 +181,25 @@ main(int argc, char **argv)
|
||||||
if (dict == NULL) {
|
if (dict == NULL) {
|
||||||
printf("Directory %s does not contain any "
|
printf("Directory %s does not contain any "
|
||||||
"xbps pkgindex file.\n", dpkgidx);
|
"xbps pkgindex file.\n", dpkgidx);
|
||||||
|
free(repolist);
|
||||||
exit(EINVAL);
|
exit(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
rinfo = malloc(sizeof(*rinfo));
|
rinfo = malloc(sizeof(*rinfo));
|
||||||
if (rinfo == NULL)
|
if (rinfo == NULL) {
|
||||||
|
free(repolist);
|
||||||
exit(ENOMEM);
|
exit(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
if (!pkgindex_getinfo(dict, rinfo)) {
|
if (!pkgindex_getinfo(dict, rinfo)) {
|
||||||
printf("'%s' is incomplete.\n", repolist);
|
printf("'%s' is incomplete.\n", repolist);
|
||||||
free(rinfo);
|
free(rinfo);
|
||||||
|
free(repolist);
|
||||||
exit(EINVAL);
|
exit(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(repolist);
|
||||||
|
|
||||||
if (!xbps_register_repository(dpkgidx)) {
|
if (!xbps_register_repository(dpkgidx)) {
|
||||||
printf("ERROR: couldn't register repository (%s)\n",
|
printf("ERROR: couldn't register repository (%s)\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
|
|
@ -147,6 +147,6 @@ bool xbps_remove_string_from_array(prop_object_t, void *, bool *);
|
||||||
bool xbps_show_pkg_info_from_repolist(prop_object_t obj, void *, bool *);
|
bool xbps_show_pkg_info_from_repolist(prop_object_t obj, void *, bool *);
|
||||||
bool xbps_show_pkg_namedesc(prop_object_t, void *, bool *);
|
bool xbps_show_pkg_namedesc(prop_object_t, void *, bool *);
|
||||||
bool xbps_search_string_in_pkgs(prop_object_t, void *, bool *);
|
bool xbps_search_string_in_pkgs(prop_object_t, void *, bool *);
|
||||||
const char *xbps_get_pkgidx_string(const char *);
|
char *xbps_get_pkgidx_string(const char *);
|
||||||
|
|
||||||
#endif /* !_XBPS_PLIST_H_ */
|
#endif /* !_XBPS_PLIST_H_ */
|
||||||
|
|
31
lib/plist.c
31
lib/plist.c
|
@ -155,11 +155,10 @@ xbps_get_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
||||||
return prop_array_iterator(array);
|
return prop_array_iterator(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
char *
|
||||||
xbps_get_pkgidx_string(const char *repofile)
|
xbps_get_pkgidx_string(const char *repofile)
|
||||||
{
|
{
|
||||||
const char *res;
|
char plist[PATH_MAX], *len, *result;
|
||||||
char plist[PATH_MAX], *len;
|
|
||||||
|
|
||||||
assert(repofile != NULL);
|
assert(repofile != NULL);
|
||||||
|
|
||||||
|
@ -171,9 +170,13 @@ xbps_get_pkgidx_string(const char *repofile)
|
||||||
plist[sizeof(plist) - 1] = '\0';
|
plist[sizeof(plist) - 1] = '\0';
|
||||||
strncat(plist, "/", sizeof(plist) - strlen(plist) - 1);
|
strncat(plist, "/", sizeof(plist) - strlen(plist) - 1);
|
||||||
strncat(plist, XBPS_PKGINDEX, sizeof(plist) - strlen(plist) - 1);
|
strncat(plist, XBPS_PKGINDEX, sizeof(plist) - strlen(plist) - 1);
|
||||||
res = plist;
|
|
||||||
|
|
||||||
return res;
|
result = malloc(strlen(plist));
|
||||||
|
if (result == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
strncpy(result, plist, strlen(plist));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -459,7 +462,8 @@ bool
|
||||||
xbps_search_string_in_pkgs(prop_object_t obj, void *arg, bool *loop_done)
|
xbps_search_string_in_pkgs(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
{
|
{
|
||||||
prop_dictionary_t dict;
|
prop_dictionary_t dict;
|
||||||
const char *repofile, *plist;
|
const char *repofile;
|
||||||
|
char *plist;
|
||||||
|
|
||||||
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
||||||
|
|
||||||
|
@ -473,13 +477,17 @@ xbps_search_string_in_pkgs(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dict = prop_dictionary_internalize_from_file(plist);
|
dict = prop_dictionary_internalize_from_file(plist);
|
||||||
if (dict == NULL || prop_dictionary_count(dict) == 0)
|
if (dict == NULL || prop_dictionary_count(dict) == 0) {
|
||||||
|
free(plist);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
printf("From %s repository ...\n", repofile);
|
printf("From %s repository ...\n", repofile);
|
||||||
xbps_callback_array_iter_in_dict(dict, "packages",
|
xbps_callback_array_iter_in_dict(dict, "packages",
|
||||||
xbps_show_pkg_namedesc, arg);
|
xbps_show_pkg_namedesc, arg);
|
||||||
|
|
||||||
|
free(plist);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +496,8 @@ xbps_show_pkg_info_from_repolist(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
{
|
{
|
||||||
prop_dictionary_t dict, pkgdict;
|
prop_dictionary_t dict, pkgdict;
|
||||||
prop_string_t oloc;
|
prop_string_t oloc;
|
||||||
const char *repofile, *repoloc, *plist;
|
const char *repofile, *repoloc;
|
||||||
|
char *plist;
|
||||||
|
|
||||||
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
||||||
|
|
||||||
|
@ -501,8 +510,12 @@ xbps_show_pkg_info_from_repolist(prop_object_t obj, void *arg, bool *loop_done)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
dict = prop_dictionary_internalize_from_file(plist);
|
dict = prop_dictionary_internalize_from_file(plist);
|
||||||
if (dict == NULL || prop_dictionary_count(dict) == 0)
|
if (dict == NULL || prop_dictionary_count(dict) == 0) {
|
||||||
|
free(plist);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(plist);
|
||||||
pkgdict = xbps_find_pkg_in_dict(dict, arg);
|
pkgdict = xbps_find_pkg_in_dict(dict, arg);
|
||||||
if (pkgdict == NULL)
|
if (pkgdict == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue