37 #include <sys/utsname.h>
42 #include "xbps_api_impl.h"
54 if ((strncmp(uri,
"https://", 8) == 0) ||
55 (strncmp(uri,
"http://", 7) == 0) ||
56 (strncmp(uri,
"ftp://", 6) == 0))
65 prop_dictionary_t dict;
80 if (state != XBPS_PKG_STATE_INSTALLED)
91 if ((p = strrchr(pkg,
'-')) == NULL)
94 if (strrchr(p,
'_') == NULL)
108 if ((p = strrchr(pkg,
'_')) == NULL)
121 if ((p = strrchr(pkg,
'-')) == NULL)
124 if (strrchr(p,
'_') == NULL)
127 len = strlen(pkg) - strlen(p) + 1;
131 memcpy(buf, pkg, len-1);
145 if ((res = strpbrk(pkg,
"><*?[]")) == NULL)
148 len = strlen(pkg) - strlen(res) + 1;
149 if (pkg[len-2] ==
'-')
152 pkgname = malloc(len);
153 assert(pkgname != NULL);
155 memcpy(pkgname, pkg, len-1);
156 pkgname[len-1] =
'\0';
166 return strpbrk(pkg,
"><*?[]");
170 get_pkg_index_remote_plist(
struct xbps_handle *xhp,
174 char *uri_fixed, *repodir;
178 uri_fixed = xbps_get_remote_repo_string(uri);
179 if (uri_fixed == NULL)
183 uri_fixed, xhp->un_machine, plistf);
195 return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX);
197 return xbps_xasprintf(
"%s/%s-%s", uri, xhp->un_machine, XBPS_PKGINDEX);
207 return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX_FILES);
210 xhp->un_machine, XBPS_PKGINDEX_FILES);
214 xbps_repository_pkg_path(
struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
216 const char *filen, *repoloc;
217 char *lbinpkg = NULL;
220 assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
222 if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
225 if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
226 "repository", &repoloc))
234 if (access(lbinpkg, R_OK) == 0)
250 assert(prop_object_type(pkgd) == PROP_TYPE_DICTIONARY);
252 array = prop_dictionary_get(pkgd,
"run_depends");
253 if ((prop_object_type(array) == PROP_TYPE_ARRAY) &&
254 prop_array_count(array) > 0)
265 if (target == NULL) {
266 if ((strcmp(orig,
"noarch") == 0) ||
267 (strcmp(orig, xhp->un_machine) == 0))
270 if ((strcmp(orig,
"noarch") == 0) ||
271 (strcmp(orig, target) == 0))
284 if (vasprintf(&buf, fmt, ap) == -1) {
301 if (strcmp(pattern, pkg) == 0)
305 if (strpbrk(pattern,
"<>") != NULL)
306 return dewey_match(pattern, pkg);
309 if (strpbrk(pattern,
"*?[]") != NULL)
310 if (fnmatch(pattern, pkg, FNM_PERIOD) == 0)
326 return humanize_number(buf, 7, bytes,
"B",
327 HN_AUTOSCALE, HN_DECIMAL|HN_NOSPACE);