Exemplo n.º 1
0
/**
 * Fetch repository calalogues.
 */
int
pkgcli_update(bool force, bool strict, const char *reponame)
{
	int retcode = EPKG_FATAL, update_count = 0, total_count = 0;
	struct pkg_repo *r = NULL;

	/* Only auto update if the user has write access. */
	if (pkgdb_access(PKGDB_MODE_READ|PKGDB_MODE_WRITE|PKGDB_MODE_CREATE,
	    PKGDB_DB_REPO) == EPKG_ENOACCESS)
		return (EPKG_OK);

	if (pkg_repos_total_count() == 0) {
		fprintf(stderr, "No valid repository found.\n");
		return (EPKG_FATAL);
	}

	while (pkg_repos(&r) == EPKG_OK) {
		if (reponame != NULL) {
			if (strcmp(pkg_repo_name(r), reponame) != 0)
				continue;
		} else {
			if (!pkg_repo_enabled(r))
				continue;
		}

		if (!quiet)
			printf("Updating %s repository catalogue...\n",
			    pkg_repo_name(r));
		retcode = pkg_update(r, force);
		if (retcode == EPKG_UPTODATE) {
			if (!quiet)
				printf("%s repository is up-to-date.\n",
				    pkg_repo_name(r));
		}
		else if (retcode != EPKG_OK && strict)
			retcode = EPKG_FATAL;

		total_count ++;
		if (retcode != EPKG_OK)
			continue;

		update_count ++;
	}

	if (!strict || retcode == EPKG_UPTODATE)
		retcode = EPKG_OK;

	if (total_count == 0) {
		if (!quiet)
			printf("No repositories are enabled.\n");
		retcode = EPKG_FATAL;
	}
	else if (update_count == 0) {
		if (!quiet)
			if (retcode == EPKG_OK)
				printf("All repositories are up-to-date.\n");
	}

	return (retcode);
}
Exemplo n.º 2
0
/**
 * Fetch repository calalogues.
 */
int
pkgcli_update(bool force) {
	int retcode = EPKG_FATAL;
	struct pkg_repo *r = NULL;

	/* Only auto update if the user has write access. */
	if (pkgdb_access(PKGDB_MODE_READ|PKGDB_MODE_WRITE|PKGDB_MODE_CREATE,
	    PKGDB_DB_REPO) == EPKG_ENOACCESS)
		return (EPKG_OK);

	if (!quiet)
		printf("Updating repository catalogue\n");

	while (pkg_repos(&r) == EPKG_OK) {
		if (!pkg_repo_enabled(r))
			continue;
		retcode = pkg_update(r, force);
		if (retcode == EPKG_UPTODATE) {
			if (!quiet)
				printf("%s repository catalogue is "
				       "up-to-date, no need to fetch "
				       "fresh copy\n", pkg_repo_ident(r));
				retcode = EPKG_OK;
		}
		if (retcode != EPKG_OK)
			break;
	}

	return (retcode);
}
Exemplo n.º 3
0
/*
 * Finds the type of the given PackageKit repository name.
 * 
 * This function checks remote repositories to ensure they match actually
 * configured repositories, and instead returns 'REPO_INVALID' when they
 * don't. A separate function 'repo_type_no_remote_check' does not do this
 * and can thus be unit tested.
 */
enum repo_type
repo_type(const char *name)
{
	enum repo_type	type;

	/* 'name' may be NULL.  This implies REPO_ANY. */

	type = repo_type_no_remote_check(name);

	if (type == REPO_REMOTE) {
		struct pkg_repo *repo;
		repo = pkg_repo_find_name(name);

		if (repo == NULL) {
			type = REPO_INVALID;
		} else if (!pkg_repo_enabled(repo)) {
			type = REPO_DISABLED;
		}
	}
	return type;
}
Exemplo n.º 4
0
/**
 * Fetch repository calalogues.
 */
int
pkgcli_update(bool force) {
	int retcode = EPKG_FATAL, update_count = 0;
	struct pkg_repo *r = NULL;

	/* Only auto update if the user has write access. */
	if (pkgdb_access(PKGDB_MODE_READ|PKGDB_MODE_WRITE|PKGDB_MODE_CREATE,
	    PKGDB_DB_REPO) == EPKG_ENOACCESS)
		return (EPKG_OK);

	if (!quiet)
		printf("Updating repository catalogue\n");

	if (pkg_repos_total_count() == 0) {
		fprintf(stderr, "No valid repository found.\n");
		return (EPKG_FATAL);
	}

	while (pkg_repos(&r) == EPKG_OK) {
		if (!pkg_repo_enabled(r))
			continue;
		retcode = pkg_update(r, force);
		if (retcode == EPKG_UPTODATE) {
			if (!quiet)
				printf("%s repository catalogue is "
				       "up-to-date, no need to fetch "
				       "fresh copy\n", pkg_repo_ident(r));
				retcode = EPKG_OK;
		}
		if (retcode != EPKG_OK)
			break;
		update_count ++;
	}

	if (!quiet && update_count == 0)
		printf("No repositories are enabled\n");

	return (retcode);
}