void setarch(Pool *pool) { struct utsname un; if (uname(&un)) { perror("uname"); exit(1); } pool_setarch(pool, un.machine); }
static int setarch(HySack sack, const char *req_arch) { int ret = 0; Pool *pool = sack_pool(sack); const char *arch = req_arch; char *detected = NULL; if (arch == NULL) { ret = hy_detect_arch(&detected); if (ret) { HY_LOG_ERROR("hy_detect_arch() failed: %d", ret); return ret; } arch = detected; } HY_LOG_INFO("Architecture is: %s", arch); pool_setarch(pool, arch); if (!strcmp(arch, "noarch")) // noarch never fails goto done; /* pool_setarch() doesn't tell us when it defaulted to 'noarch' but we consider it a failure. the only way to find out is count the architectures known to the Pool. */ int count = 0; for (Id id = 0; id <= pool->lastarch; ++id) if (pool->id2arch[id]) count++; if (count < 2) ret = HY_E_FAILED; done: solv_free(detected); return ret; }