Esempio n. 1
0
static PyObject *
detect_arch(PyObject *unused, PyObject *args)
{
    char *arch;

    if (ret2e(hy_detect_arch(&arch), "Failed detecting architecture."))
	return NULL;
    return PyString_FromString(arch);
}
Esempio n. 2
0
File: sack.c Progetto: Tojaj/hawkey
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;
}