static int repo_find_best_pkg_cb(struct xbps_handle *xhp, struct xbps_rpool_index *rpi, void *arg, bool *done) { struct repo_pool_fpkg *rpf = arg; const char *repopkgver; prop_dictionary_t pkgd; (void)done; (void)xhp; if (rpf->bypattern) { pkgd = xbps_find_pkg_in_array_by_pattern(xhp, rpi->repo, rpf->pattern, NULL); } else { pkgd = xbps_find_pkg_in_array_by_name(xhp, rpi->repo, rpf->pattern, NULL); } if (pkgd == NULL) { if (errno && errno != ENOENT) return errno; xbps_dbg_printf(xhp, "[rpool] Package '%s' not found in repository " "'%s'.\n", rpf->pattern, rpi->uri); return 0; } prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &repopkgver); if (rpf->bestpkgver == NULL) { xbps_dbg_printf(xhp, "[rpool] Found best match '%s' (%s).\n", repopkgver, rpi->uri); rpf->pkgd = pkgd; prop_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", rpi->uri); rpf->bestpkgver = repopkgver; return 0; } /* * Compare current stored version against new * version from current package in repository. */ if (xbps_cmpver(repopkgver, rpf->bestpkgver) == 1) { xbps_dbg_printf(xhp, "[rpool] Found best match '%s' (%s).\n", repopkgver, rpi->uri); rpf->pkgd = pkgd; prop_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", rpi->uri); rpf->bestpkgver = repopkgver; } return 0; }
int show_pkg_info_from_metadir(struct xbps_handle *xhp, const char *pkgname, const char *option) { prop_dictionary_t d, pkgdb_d; const char *instdate, *pname; bool autoinst; d = xbps_dictionary_from_metadata_plist(xhp, pkgname, XBPS_PKGPROPS); if (d == NULL) return EINVAL; prop_dictionary_get_cstring_nocopy(d, "pkgname", &pname); pkgdb_d = xbps_pkgdb_get_pkgd(xhp, pname, false); if (pkgdb_d == NULL) { prop_object_release(d); return EINVAL; } if (prop_dictionary_get_cstring_nocopy(pkgdb_d, "install-date", &instdate)) prop_dictionary_set_cstring_nocopy(d, "install-date", instdate); if (prop_dictionary_get_bool(pkgdb_d, "automatic-install", &autoinst)) prop_dictionary_set_bool(d, "automatic-install", autoinst); if (option == NULL) show_pkg_info(d); else show_pkg_info_one(d, option); prop_object_release(d); return 0; }
static int repo_find_virtualpkg_conf_cb(struct xbps_handle *xhp, struct xbps_rpool_index *rpi, void *arg, bool *done) { struct repo_pool_fpkg *rpf = arg; if (rpf->bypattern) { rpf->pkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(xhp, rpi->repo, rpf->pattern); } else { rpf->pkgd = xbps_find_virtualpkg_conf_in_array_by_name(xhp, rpi->repo, rpf->pattern); } if (rpf->pkgd) { prop_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", rpi->uri); *done = true; return 0; } /* not found */ return 0; }
gboolean drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties) { prop_dictionary_t command_dict; prop_dictionary_t args_dict; prop_dictionary_t results_dict; int err; command_dict = prop_dictionary_create (); args_dict = prop_dictionary_create (); prop_dictionary_set_cstring_nocopy (command_dict, "drvctl-command", "get-properties"); prop_dictionary_set_cstring_nocopy (args_dict, "device-name", devnode); prop_dictionary_set (command_dict, "drvctl-arguments", args_dict); prop_object_release (args_dict); err = prop_dictionary_sendrecv_ioctl (command_dict, drvctl_fd, DRVCTLCOMMAND, &results_dict); prop_object_release (command_dict); if (err) return FALSE; if (prop_dictionary_get_int8 (results_dict, "drvctl-error", &err) == false || err != 0) { prop_object_release (results_dict); return FALSE; } if (properties) { prop_dictionary_t result_data; result_data = prop_dictionary_get (results_dict, "drvctl-result-data"); if (result_data) *properties = prop_dictionary_copy (result_data); } prop_object_release (results_dict); return TRUE; }
static int repo_find_pkg_cb(struct xbps_handle *xhp, struct xbps_rpool_index *rpi, void *arg, bool *done) { struct repo_pool_fpkg *rpf = arg; (void)xhp; if (rpf->exact) { /* exact match by pkgver */ rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(xhp, rpi->repo, rpf->pattern, NULL); } else if (rpf->bypattern) { /* match by pkgpattern in pkgver*/ rpf->pkgd = xbps_find_pkg_in_array_by_pattern(xhp, rpi->repo, rpf->pattern, NULL); } else { /* match by pkgname */ rpf->pkgd = xbps_find_pkg_in_array_by_name(xhp, rpi->repo, rpf->pattern, NULL); } if (rpf->pkgd) { /* * Package dictionary found, add the "repository" * object with the URI. */ prop_dictionary_set_cstring_nocopy(rpf->pkgd, "repository", rpi->uri); *done = true; return 0; } /* Not found */ return 0; }
void disk_set_info(device_t dev, struct disk *dk, const char *type) { struct disk_geom *dg = &dk->dk_geom; if (dg->dg_secsize == 0) { #ifdef DIAGNOSTIC printf("%s: fixing 0 sector size\n", dk->dk_name); #endif dg->dg_secsize = DEV_BSIZE; } dk->dk_blkshift = DK_BSIZE2BLKSHIFT(dg->dg_secsize); dk->dk_byteshift = DK_BSIZE2BYTESHIFT(dg->dg_secsize); if (dg->dg_secperunit == 0 && dg->dg_ncylinders == 0) { #ifdef DIAGNOSTIC printf("%s: secperunit and ncylinders are zero\n", dk->dk_name); #endif return; } if (dg->dg_secperunit == 0) { if (dg->dg_nsectors == 0 || dg->dg_ntracks == 0) { #ifdef DIAGNOSTIC printf("%s: secperunit and (sectors or tracks) " "are zero\n", dk->dk_name); #endif return; } dg->dg_secperunit = (int64_t) dg->dg_nsectors * dg->dg_ntracks * dg->dg_ncylinders; } if (dg->dg_ncylinders == 0) { if (dg->dg_ntracks && dg->dg_nsectors) dg->dg_ncylinders = dg->dg_secperunit / (dg->dg_ntracks * dg->dg_nsectors); } prop_dictionary_t disk_info, odisk_info, geom; disk_info = prop_dictionary_create(); geom = prop_dictionary_create(); prop_dictionary_set_uint64(geom, "sectors-per-unit", dg->dg_secperunit); prop_dictionary_set_uint32(geom, "sector-size", dg->dg_secsize); if (dg->dg_nsectors) prop_dictionary_set_uint16(geom, "sectors-per-track", dg->dg_nsectors); if (dg->dg_ntracks) prop_dictionary_set_uint16(geom, "tracks-per-cylinder", dg->dg_ntracks); if (dg->dg_ncylinders) prop_dictionary_set_uint64(geom, "cylinders-per-unit", dg->dg_ncylinders); prop_dictionary_set(disk_info, "geometry", geom); if (type) prop_dictionary_set_cstring_nocopy(disk_info, "type", type); prop_object_release(geom); odisk_info = dk->dk_info; dk->dk_info = disk_info; if (dev) prop_dictionary_set(device_properties(dev), "disk-info", disk_info); /* * Don't release disk_info here; we keep a reference to it. * disk_detach() will release it when we go away. */ if (odisk_info) prop_object_release(odisk_info); }