/** * Fetch repository calalogues. */ int pkgcli_update(bool force) { const char *packagesite = NULL; const char *repo_name; bool multi_repos = false; struct pkg_config_kv *repokv = NULL; int retcode = EPKG_FATAL; char name[MAXPATHLEN]; if (!quiet) printf("Updating repository catalogue\n"); pkg_config_bool(PKG_CONFIG_MULTIREPOS, &multi_repos); /* single repository */ if (!multi_repos) { /* * Single remote database */ pkg_config_string(PKG_CONFIG_REPO, &packagesite); if (packagesite == NULL) { warnx("PACKAGESITE is not defined."); return (1); } retcode = pkg_update("repo", packagesite, force); if (retcode == EPKG_UPTODATE) { if (!quiet) printf("Repository catalogue is up-to-date, " "no need to fetch fresh copy\n"); retcode = EPKG_OK; } } else { /* multiple repositories */ while (pkg_config_kvlist(PKG_CONFIG_REPOS, &repokv) == EPKG_OK) { repo_name = pkg_config_kv_get(repokv, PKG_CONFIG_KV_KEY); packagesite = pkg_config_kv_get(repokv, PKG_CONFIG_KV_VALUE); snprintf(name, MAXPATHLEN, "repo-%s", repo_name); retcode = pkg_update(name, packagesite, force); if (retcode == EPKG_UPTODATE) { if (!quiet) printf("%s repository catalogue is " "up-to-date, no need to fetch " "fresh copy\n", repo_name); retcode = EPKG_OK; } if (retcode != EPKG_OK) break; } } return (retcode); }
/** * 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); }