/** * 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); }
/** * 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); }
/** * 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); }