/* Lists detailed information about targets */ static int sync_info(CURL *curl, alpm_list_t *targets) { int found, ret, pkgcount; alpm_list_t *i, *j, *results; alpm_list_t *free_list = NULL; alpm_list_t *syncdbs = alpm_option_get_syncdbs(config->handle); alpm_pkg_t *spkg; char cwd[PATH_MAX]; char filename[PATH_MAX]; char url[PATH_MAX]; FILE *fp = NULL; int fd; struct aurpkg_t *pkg; if (!getcwd(cwd, PATH_MAX)) { return error(PW_ERR_GETCWD); } if (chdir(powaur_dir)) { return error(PW_ERR_CHDIR, powaur_dir); } found = ret = pkgcount = 0; for (i = targets; i; i = i->next, ++pkgcount) { /* Search sync dbs first */ spkg = search_syncdbs(syncdbs, i->data); if (spkg) { if (found++){ printf("\n"); } pacman_pkgdump(spkg, PKG_FROM_SYNC); spkg = NULL; continue; } results = query_aur(curl, i->data, AUR_QUERY_INFO); if (alpm_list_count(results) != 1) { if (pkgcount > 0) { printf("\n"); } pw_printf(PW_LOG_ERROR, "package %s not found\n", i->data); goto garbage_collect; } snprintf(filename, PATH_MAX, "%s.PKGBUILDXXXXXX", i->data); fd = mkstemp(filename); if (fd < 0) { error(PW_ERR_FOPEN, filename); goto garbage_collect; } fp = fdopen(fd, "w+"); if (!fp) { printf("NO\n"); error(PW_ERR_FOPEN, filename); goto garbage_collect; } snprintf(url, PATH_MAX, AUR_PKGBUILD_URL, i->data); /* Download the PKGBUILD and parse it */ ret = download_single_file(curl, url, fp); if (ret) { goto destroy_remnants; } /* Parse PKGBUILD and get detailed info */ fseek(fp, 0L, SEEK_SET); pkg = results->data; parse_pkgbuild(pkg, fp); if (found++) { printf("\n"); } printf("%s%s %saur%s\n", color.bold, REPO, color.bmag, color.nocolor); printf("%s%s %s%s\n", color.bold, NAME, pkg->name, color.nocolor); printf("%s%s %s%s%s\n", color.bold, VERSION, color.bgreen, pkg->version, color.nocolor); printf("%s%s %s%s%s\n", color.bold, URL, color.bcyan, pkg->url, color.nocolor); printf("%s%s%s ", color.bold, A_URL, color.bcyan); printf(AUR_PKG_URL, pkg->id); printf("%s\n", color.nocolor); printf("%s%s %s%s\n", color.bold, LICENSES, color.nocolor, pkg->license); printf("%s%s %s%d\n", color.bold, A_VOTES, color.nocolor, pkg->votes); printf("%s%s ", color.bold, A_OUTOFDATE); if (pkg->outofdate) { printf("%s%s", color.bred, "Yes"); } else { printf("%s%s", color.nocolor, "No"); } printf("%s\n", color.nocolor); print_list_prefix(pkg->provides, PROVIDES); print_list_prefix(pkg->depends, DEPS); print_list_prefix(pkg->optdepends, OPTDEPS); print_list_prefix(pkg->conflicts, CONFLICTS); print_list_prefix(pkg->replaces, REPLACES); print_list_prefix(pkg->arch, ARCH); printf("%s%s%s %s\n", color.bold, DESC, color.nocolor, pkg->desc); destroy_remnants: fclose(fp); fp = NULL; unlink(filename); garbage_collect: free_list = alpm_list_add(free_list, results); } cleanup: for (i = free_list; i; i = i->next) { alpm_list_free_inner(i->data, (alpm_list_fn_free) aurpkg_free); alpm_list_free(i->data); } alpm_list_free(free_list); if (chdir(cwd)) { return error(PW_ERR_RESTORECWD); } return found ? 0 : -1; }
void pacman_pkgdump(pmpkg_t *pkg, enum pkgfrom_t from) { static const char *datefmt = "%a %d %b %Y %I:%M:%S %p %Z"; alpm_list_t *i, *results = NULL; pmdb_t *db; pmdepend_t *dep; pmpkgreason_t reason; int has_script; time_t inst_time; struct tm tm_st; char installdate[60]; char builddate[60]; db = alpm_pkg_get_db(pkg); if (!db) { return; } memset(&tm_st, 0, sizeof(struct tm)); inst_time = alpm_pkg_get_builddate(pkg); localtime_r(&inst_time, &tm_st); strftime(builddate, 60, datefmt, &tm_st); /* Local pkg specific */ if (from == PKG_FROM_LOCAL) { has_script = alpm_pkg_has_scriptlet(pkg); reason = alpm_pkg_get_reason(pkg); memset(&tm_st, 0, sizeof(struct tm)); inst_time = alpm_pkg_get_installdate(pkg); localtime_r(&inst_time, &tm_st); strftime(installdate, 60, datefmt, &tm_st); } if (from == PKG_FROM_SYNC) { printf("%s%s ", color.bold, REPO); const char *repo = alpm_db_get_name(db); if (!strcmp(repo, "core")) { printf("%s", color.bred); } else if (!strcmp(repo, "extra")) { printf("%s", color.bgreen); } else { printf("%s", color.bmag); } printf("%s%s\n", repo, color.nocolor); } printf("%s%s%s %s%s%s\n", color.bold, NAME, color.nocolor, color.bold, alpm_pkg_get_name(pkg), color.nocolor); printf("%s%s %s%s%s\n", color.bold, VERSION, color.bgreen, alpm_pkg_get_version(pkg), color.nocolor); printf("%s%s %s%s%s\n", color.bold, URL, color.bcyan, alpm_pkg_get_url(pkg), color.nocolor); print_list_prefix(alpm_pkg_get_licenses(pkg), LICENSES); print_list_prefix(alpm_pkg_get_groups(pkg), GROUPS); print_list_prefix(alpm_pkg_get_provides(pkg), PROVIDES); print_list_deps(alpm_pkg_get_depends(pkg), DEPS); print_list_break(alpm_pkg_get_optdepends(pkg), OPTDEPS); if (from == PKG_FROM_LOCAL) { results = alpm_pkg_compute_requiredby(pkg); print_list_prefix(results, REQBY); } print_list_prefix(alpm_pkg_get_conflicts(pkg), CONFLICTS); print_list_prefix(alpm_pkg_get_replaces(pkg), REPLACES); if (from == PKG_FROM_SYNC) { humanize_size(alpm_pkg_get_size(pkg), DLSZ); } humanize_size(alpm_pkg_get_isize(pkg), INSTSZ); printf("%s%s%s %s\n", color.bold, PKGER, color.nocolor, alpm_pkg_get_packager(pkg)); printf("%s%s%s %s\n", color.bold, ARCH, color.nocolor, alpm_pkg_get_arch(pkg)); printf("%s%s%s %s\n", color.bold, BDATE, color.nocolor, builddate); if (from == PKG_FROM_LOCAL) { printf("%s%s%s %s\n", color.bold, IDATE, color.nocolor, installdate); printf("%s%s%s ", color.bold, REASON, color.nocolor); switch (reason) { case PM_PKG_REASON_EXPLICIT: printf("Explicitly installed"); break; case PM_PKG_REASON_DEPEND: printf("Installed as a dependency for another package"); break; default: printf("Unknown"); break; } printf("\n"); printf("%s%s%s %s\n", color.bold, SCRIPT, color.nocolor, has_script ? "Yes" : "No"); } if (from == PKG_FROM_SYNC) { printf("%s%s%s %s\n", color.bold, MD5SUM, color.nocolor, alpm_pkg_get_md5sum(pkg)); } printf("%s%s%s %s\n", color.bold, DESC, color.nocolor, alpm_pkg_get_desc(pkg)); FREELIST(results); }