Ejemplo n.º 1
0
Archivo: sack.c Proyecto: Tojaj/hawkey
static void
log_cb(Pool *pool, void *cb_data, int level, const char *buf)
{
    HySack sack = cb_data;

    if (sack->log_out == NULL) {
	const char *fn = pool_tmpjoin(pool, sack->cache_dir, "/hawkey.log", NULL);

	sack->log_out = fopen(fn, "a");
	if (sack->log_out)
	    HY_LOG_INFO("Started hawkey-%d.%d.%d.", HY_VERSION_MAJOR,
			HY_VERSION_MINOR, HY_VERSION_PATCH);
    }
    if (!sack->log_out)
	return;

    time_t t = time(NULL);
    struct tm tm;
    char timestr[26];

    localtime_r(&t, &tm);
    strftime(timestr, 26, "%b-%d %H:%M:%S ", &tm);
    const char *pref = pool_tmpjoin(pool, ll_name(level), " ", timestr);
    pref = pool_tmpjoin(pool, pref, buf, NULL);

    fwrite(pref, strlen(pref), 1, sack->log_out);
    fflush(sack->log_out);
}
Ejemplo n.º 2
0
static HySack
create_ut_sack(void)
{
    HySack sack = hy_sack_create(test_globals.tmpdir, TEST_FIXED_ARCH, NULL,
				 NULL, HY_MAKE_CACHE_DIR);
    test_globals.sack = sack;
    HY_LOG_INFO("HySack for UT created: %p", sack);
    return sack;
}
Ejemplo n.º 3
0
END_TEST

START_TEST(test_goal_log_decisions)
{
    HySack sack = test_globals.sack;
    HyPackage pkg = get_latest_pkg(sack, "hello");
    HyGoal goal = hy_goal_create(sack);

    hy_goal_install(goal, pkg);
    HY_LOG_INFO("--- decisions below --->");
    const int origsize = logfile_size(sack);
    hy_goal_run(goal);
    hy_goal_log_decisions(goal);
    const int newsize = logfile_size(sack);
    // check something substantial was added to the logfile:
    fail_unless(newsize - origsize > 3000);

    hy_package_free(pkg);
    hy_goal_free(goal);
}
Ejemplo n.º 4
0
Archivo: sack.c Proyecto: 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;
}