/* Right now this is laid out to show up properly on standard B&W iPods. * this will probably need to be updated to look prettier on other iPod * generations later. */ static void draw_transfer_widget(PzWidget *wid, ttk_surface srf) { int posmod, i = 0; unsigned long percent; char sbuf[128]; if (rip_status==STATUS_TRANSFERRING) { if (cur_file->src_track) { char *s = ipod_string_new(); s = ipod_track_get_text(cur_file->src_track, IPOD_ARTIST, s); pp_place_text(wid, srf, s, 1); s = ipod_track_get_text(cur_file->src_track, IPOD_TITLE, s); pp_place_text(wid, srf, s, 2); ipod_string_free(s); } else { sprintf(sbuf, "From: %s", cur_file->src_filename); pp_place_text(wid, srf, sbuf, 1); sprintf(sbuf, "To: %s", cur_file->dst_filename); pp_place_text(wid, srf, sbuf, 2); } sprintf(sbuf, "%s / ", humanize_size(file_bytes_transferred)); //sprintf(sbuf, "%s%s", sbuf, humanize_size(cur_file->filesize)); strcat(sbuf, humanize_size(cur_file->filesize)); pp_place_text(wid, srf, sbuf, 3); percent = file_bytes_transferred * 100 / cur_file->filesize; } else { if (cur_file) pp_place_text(wid, srf, "Transfer Aborted", 1); else pp_place_text(wid, srf, "Transfer Completed", 1); pp_place_text(wid, srf, "Press [menu] to return", 2); percent = 100; } fill_copied_percent(wid, srf, percent, 46); if (total_files > 1) { sprintf(sbuf, "File %i of %i\n", total_files_transferred + (cur_file ? 1 : 0), total_files); pp_place_text(wid, srf, sbuf, 6); sprintf(sbuf, "%s / ", humanize_size(total_bytes_transferred)); sprintf(sbuf, "%s%s total", sbuf, humanize_size(total_bytes)); pp_place_text(wid, srf, sbuf, 7); unsigned long tpercent; tpercent = total_bytes_transferred * 100 / total_bytes; //sprintf(sbuf, "%i%% Completed", tpercent); //pp_place_text(wid, srf, sbuf, 5); fill_copied_percent(wid, srf, tpercent, 97); } }
static void print_total_dl_stats(int count, double duration, off_t total_xfer) { const char *rate_label, *xfered_label; double rate, xfered_human, rate_human; int width; rate = total_xfer / duration; xfered_human = humanize_size(total_xfer, '\0', -1, &xfered_label); rate_human = humanize_size(rate, '\0', -1, &rate_label); width = printf(":: download complete in %.2fs", duration); printf("%*s<", 42 - width, ""); print_rate(xfered_human, xfered_label, rate_human, rate_label[0]); printf(" %2d file%c >\n", count, count == 1 ? ' ' : 's'); }
/* returns package info as list of strings */ static alpm_list_t *create_verbose_row(pm_target_t *target) { char *str; off_t size = 0; double human_size; const char *label; alpm_list_t *ret = NULL; /* a row consists of the package name, */ if(target->install) { const alpm_db_t *db = alpm_pkg_get_db(target->install); if(db) { pm_asprintf(&str, "%s/%s", alpm_db_get_name(db), alpm_pkg_get_name(target->install)); } else { pm_asprintf(&str, "%s", alpm_pkg_get_name(target->install)); } } else { pm_asprintf(&str, "%s", alpm_pkg_get_name(target->remove)); } ret = alpm_list_add(ret, str); /* old and new versions */ pm_asprintf(&str, "%s", target->remove != NULL ? alpm_pkg_get_version(target->remove) : ""); ret = alpm_list_add(ret, str); pm_asprintf(&str, "%s", target->install != NULL ? alpm_pkg_get_version(target->install) : ""); ret = alpm_list_add(ret, str); /* and size */ size -= target->remove ? alpm_pkg_get_isize(target->remove) : 0; size += target->install ? alpm_pkg_get_isize(target->install) : 0; human_size = humanize_size(size, 'M', 2, &label); pm_asprintf(&str, "%.2f %s", human_size, label); ret = alpm_list_add(ret, str); size = target->install ? alpm_pkg_download_size(target->install) : 0; if(size != 0) { human_size = humanize_size(size, 'M', 2, &label); pm_asprintf(&str, "%.2f %s", human_size, label); } else { str = NULL; } ret = alpm_list_add(ret, str); return ret; }
void transfer_alt_stat_draw (PzWidget *wid, ttk_surface srf) { char buf[128]; stat_data *stats = (stat_data *)wid->data; int y = wid->y + 5; ttk_color color = ttk_ap_getx ("window.fg")->color; ttk_text (srf, ttk_textfont, wid->x + 5, y, color, _("Selected:")); y += ttk_text_height (ttk_textfont) + 1; sprintf(buf, "%i tracks.", stats->num_files); ttk_text (srf, ttk_textfont, wid->x + 5, y, color, buf); /* ttk_text (srf, ttk_textfont, wid->x + 5, y, color, _("Tracks:")); sprintf(buf, "%i", stats->num_tracks); printf("textwid: %i\n", ttk_text_width(ttk_textfont, buf)); ttk_text (srf, ttk_textfont, wid->w - ttk_text_width(ttk_textfont, buf) - 6, y, color, buf); */ y += ttk_text_height (ttk_textfont) + 1; sprintf(buf, "%s bytes.", humanize_size(stats->total_bytes)); ttk_text (srf, ttk_textfont, wid->x + 5, y, color, buf); y += ttk_text_height (ttk_textfont) + 1; }
static void print_download_success(struct repo_t *repo, int remaining) { const char *rate_label, *xfered_label; double rate, xfered_human; int width; rate = repo->tmpfile.size / (now() - repo->dl_time_start); xfered_human = humanize_size(repo->tmpfile.size, '\0', -1, &xfered_label); printf(" download complete: %-20s [", repo->name); if (fabs(rate - INFINITY) < DBL_EPSILON) { width = printf(" [%6.1f %3s %7s ", xfered_human, xfered_label, "----"); } else { double rate_human = humanize_size(rate, '\0', -1, &rate_label); width = print_rate(xfered_human, xfered_label, rate_human, rate_label[0]); } printf(" %*d remaining]\n", 23 - width, remaining); }
static char *size_to_string(off_t pkgsize) { static char out[64]; if(opt_humansize == 'B') { snprintf(out, sizeof(out), "%jd", (intmax_t)pkgsize); } else { snprintf(out, sizeof(out), "%.2f %ciB", humanize_size(pkgsize, opt_humansize, NULL), opt_humansize); } return out; }
static void add_transaction_sizes_row(alpm_list_t **rows, char *label, int size) { alpm_list_t *row = NULL; char *str; const char *units; double s = humanize_size(size, 'M', 2, &units); pm_asprintf(&str, "%.2f %s", s, units); add_table_cell(&row, label, CELL_TITLE); add_table_cell(&row, str, CELL_RIGHT_ALIGN | CELL_FREE); *rows = alpm_list_add(*rows, row); }
/* callback to handle display of download progress */ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) { static double rate_last; static off_t xfered_last; static int64_t initial_time = 0; int infolen; int filenamelen; char *fname, *p; /* used for wide character width determination and printing */ int len, wclen, wcwid, padwid; wchar_t *wcfname; int totaldownload = 0; off_t xfered, total; double rate = 0.0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0; double rate_human, xfered_human; const char *rate_label, *xfered_label; int file_percent = 0, total_percent = 0; const unsigned short cols = getcols(); if(config->noprogressbar || cols == 0 || file_total == -1) { if(file_xfered == 0) { printf(_("downloading %s...\n"), filename); fflush(stdout); } return; } infolen = cols * 6 / 10; if(infolen < 50) { infolen = 50; } /* only use TotalDownload if enabled and we have a callback value */ if(config->totaldownload && list_total) { /* sanity check */ if(list_xfered + file_total <= list_total) { totaldownload = 1; } else { /* bogus values : don't enable totaldownload and reset */ list_xfered = 0; list_total = 0; } } if(totaldownload) { xfered = list_xfered + file_xfered; total = list_total; } else { xfered = file_xfered; total = file_total; } /* bogus values : stop here */ if(xfered > total || xfered < 0) { return; } /* this is basically a switch on xfered: 0, total, and * anything else */ if(file_xfered == 0) { /* set default starting values, ensure we only call this once * if TotalDownload is enabled */ if(!totaldownload || (totaldownload && list_xfered == 0)) { initial_time = get_time_ms(); xfered_last = (off_t)0; rate_last = 0.0; get_update_timediff(1); } } else if(file_xfered == file_total) { /* compute final values */ int64_t timediff = get_time_ms() - initial_time; if(timediff > 0) { rate = (double)xfered / (timediff / 1000.0); /* round elapsed time (in ms) to the nearest second */ eta_s = (unsigned int)(timediff + 500) / 1000; } else { eta_s = 0; } } else { /* compute current average values */ int64_t timediff = get_update_timediff(0); if(timediff < UPDATE_SPEED_MS) { /* return if the calling interval was too short */ return; } rate = (double)(xfered - xfered_last) / (timediff / 1000.0); /* average rate to reduce jumpiness */ rate = (rate + 2 * rate_last) / 3; if(rate > 0.0) { eta_s = (total - xfered) / rate; } else { eta_s = UINT_MAX; } rate_last = rate; xfered_last = xfered; } if(file_total) { file_percent = (file_xfered * 100) / file_total; } else { file_percent = 100; } if(totaldownload) { total_percent = ((list_xfered + file_xfered) * 100) / list_total; /* if we are at the end, add the completed file to list_xfered */ if(file_xfered == file_total) { list_xfered += file_total; } } /* fix up time for display */ eta_h = eta_s / 3600; eta_s -= eta_h * 3600; eta_m = eta_s / 60; eta_s -= eta_m * 60; len = strlen(filename); fname = malloc(len + 1); memcpy(fname, filename, len); /* strip package or DB extension for cleaner look */ if((p = strstr(fname, ".pkg")) || (p = strstr(fname, ".db")) || (p = strstr(fname, ".files"))) { /* tack on a .sig suffix for signatures */ if(memcmp(&filename[len - 4], ".sig", 4) == 0) { memcpy(p, ".sig", 4); /* adjust length for later calculations */ len = p - fname + 4; } else { len = p - fname; } } fname[len] = '\0'; /* 1 space + filenamelen + 1 space + 6 for size + 1 space + 3 for label + * + 2 spaces + 4 for rate + 1 for label + 2 for /s + 1 space + * 8 for eta, gives us the magic 30 */ filenamelen = infolen - 30; /* see printf() code, we omit 'HH:' in these conditions */ if(eta_h == 0 || eta_h >= 100) { filenamelen += 3; } /* In order to deal with characters from all locales, we have to worry * about wide characters and their column widths. A lot of stuff is * done here to figure out the actual number of screen columns used * by the output, and then pad it accordingly so we fill the terminal. */ /* len = filename len + null */ wcfname = calloc(len + 1, sizeof(wchar_t)); wclen = mbstowcs(wcfname, fname, len); wcwid = wcswidth(wcfname, wclen); padwid = filenamelen - wcwid; /* if padwid is < 0, we need to trim the string so padwid = 0 */ if(padwid < 0) { int i = filenamelen - 3; wchar_t *wcp = wcfname; /* grab the max number of char columns we can fill */ while(i > 0 && wcwidth(*wcp) < i) { i -= wcwidth(*wcp); wcp++; } /* then add the ellipsis and fill out any extra padding */ wcscpy(wcp, L"..."); padwid = i; } rate_human = humanize_size((off_t)rate, '\0', -1, &rate_label); xfered_human = humanize_size(xfered, '\0', -1, &xfered_label); printf(" %ls%-*s ", wcfname, padwid, ""); /* We will show 1.62M/s, 11.6M/s, but 116K/s and 1116K/s */ if(rate_human < 9.995) { printf("%6.1f %3s %4.2f%c/s ", xfered_human, xfered_label, rate_human, rate_label[0]); } else if(rate_human < 99.95) { printf("%6.1f %3s %4.1f%c/s ", xfered_human, xfered_label, rate_human, rate_label[0]); } else { printf("%6.1f %3s %4.f%c/s ", xfered_human, xfered_label, rate_human, rate_label[0]); } if(eta_h == 0) { printf("%02u:%02u", eta_m, eta_s); } else if(eta_h < 100) { printf("%02u:%02u:%02u", eta_h, eta_m, eta_s); } else { fputs("--:--", stdout); } free(fname); free(wcfname); if(totaldownload) { fill_progress(file_percent, total_percent, cols - infolen); } else { fill_progress(file_percent, file_percent, cols - infolen); } return; }
/* prepare a list of pkgs to display */ static void _display_targets(alpm_list_t *targets, int verbose) { char *str; const char *label; double size; off_t isize = 0, rsize = 0, dlsize = 0; unsigned short cols; alpm_list_t *i, *rows = NULL, *names = NULL; if(!targets) { return; } /* gather package info */ for(i = targets; i; i = alpm_list_next(i)) { pm_target_t *target = i->data; if(target->install) { dlsize += alpm_pkg_download_size(target->install); isize += alpm_pkg_get_isize(target->install); } if(target->remove) { /* add up size of all removed packages */ rsize += alpm_pkg_get_isize(target->remove); } } /* form data for both verbose and non-verbose display */ for(i = targets; i; i = alpm_list_next(i)) { pm_target_t *target = i->data; rows = alpm_list_add(rows, create_verbose_row(target)); if(target->install) { pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install), alpm_pkg_get_version(target->install)); } else if(isize == 0) { pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->remove), alpm_pkg_get_version(target->remove)); } else { pm_asprintf(&str, "%s-%s [removal]", alpm_pkg_get_name(target->remove), alpm_pkg_get_version(target->remove)); } names = alpm_list_add(names, str); } /* print to screen */ pm_asprintf(&str, _("Packages (%d):"), alpm_list_count(targets)); printf("\n"); cols = getcols(fileno(stdout)); if(verbose) { alpm_list_t *header = create_verbose_header(); if(table_display(str, header, rows, cols) != 0) { /* fallback to list display if table wouldn't fit */ list_display(str, names, cols); } alpm_list_free(header); } else { list_display(str, names, cols); } printf("\n"); /* rows is a list of lists of strings, free inner lists here */ for(i = rows; i; i = alpm_list_next(i)) { alpm_list_t *lp = i->data; FREELIST(lp); } alpm_list_free(rows); FREELIST(names); free(str); if(dlsize > 0 || config->op_s_downloadonly) { size = humanize_size(dlsize, 'M', 2, &label); printf(_("Total Download Size: %.2f %s\n"), size, label); } if(!config->op_s_downloadonly) { if(isize > 0) { size = humanize_size(isize, 'M', 2, &label); printf(_("Total Installed Size: %.2f %s\n"), size, label); } if(rsize > 0 && isize == 0) { size = humanize_size(rsize, 'M', 2, &label); printf(_("Total Removed Size: %.2f %s\n"), size, label); } /* only show this net value if different from raw installed size */ if(isize > 0 && rsize > 0) { size = humanize_size(isize - rsize, 'M', 2, &label); printf(_("Net Upgrade Size: %.2f %s\n"), size, label); } } }
/* callback to handle display of download progress */ void cb_dl_progress(const char *filename, off_t file_xfered, off_t file_total) { int infolen; int filenamelen; char *fname, *p; /* used for wide character width determination and printing */ int len, wclen, wcwid, padwid; wchar_t *wcfname; int totaldownload = 0; off_t xfered, total; double rate = 0.0, timediff = 0.0; unsigned int eta_h = 0, eta_m = 0, eta_s = 0; double rate_human, xfered_human; const char *rate_label, *xfered_label; int file_percent = 0, total_percent = 0; const int cols = getcols(); if(config->noprogressbar || cols == 0 || file_total == -1) { if(file_xfered == 0) { printf(_("downloading %s...\n"), filename); fflush(stdout); } return; } infolen = cols * 6 / 10; if(infolen < 50) { infolen = 50; } /* explanation of magic 28 number at the end */ filenamelen = infolen - 28; /* only use TotalDownload if enabled and we have a callback value */ if(config->totaldownload && list_total) { /* sanity check */ if(list_xfered + file_total <= list_total) { totaldownload = 1; } else { /* bogus values : don't enable totaldownload and reset */ list_xfered = 0; list_total = 0; } } if(totaldownload) { xfered = list_xfered + file_xfered; total = list_total; } else { xfered = file_xfered; total = file_total; } /* bogus values : stop here */ if(xfered > total) { return; } /* this is basically a switch on xfered: 0, total, and * anything else */ if(file_xfered == 0) { /* set default starting values, ensure we only call this once * if TotalDownload is enabled */ if(!totaldownload || (totaldownload && list_xfered == 0)) { gettimeofday(&initial_time, NULL); xfered_last = (off_t)0; rate_last = 0.0; get_update_timediff(1); } } else if(file_xfered == file_total) { /* compute final values */ struct timeval current_time; double diff_sec, diff_usec; gettimeofday(¤t_time, NULL); diff_sec = current_time.tv_sec - initial_time.tv_sec; diff_usec = current_time.tv_usec - initial_time.tv_usec; timediff = diff_sec + (diff_usec / 1000000.0); rate = xfered / timediff; /* round elapsed time to the nearest second */ eta_s = (int)(timediff + 0.5); } else { /* compute current average values */ timediff = get_update_timediff(0); if(timediff < UPDATE_SPEED_SEC) { /* return if the calling interval was too short */ return; } rate = (xfered - xfered_last) / timediff; /* average rate to reduce jumpiness */ rate = (rate + 2 * rate_last) / 3; eta_s = (total - xfered) / rate; rate_last = rate; xfered_last = xfered; } file_percent = (file_xfered * 100) / file_total; if(totaldownload) { total_percent = ((list_xfered + file_xfered) * 100) / list_total; /* if we are at the end, add the completed file to list_xfered */ if(file_xfered == file_total) { list_xfered += file_total; } } /* fix up time for display */ eta_h = eta_s / 3600; eta_s -= eta_h * 3600; eta_m = eta_s / 60; eta_s -= eta_m * 60; fname = strdup(filename); /* strip package or DB extension for cleaner look */ if((p = strstr(fname, ".pkg")) || (p = strstr(fname, ".db"))) { *p = '\0'; } /* In order to deal with characters from all locales, we have to worry * about wide characters and their column widths. A lot of stuff is * done here to figure out the actual number of screen columns used * by the output, and then pad it accordingly so we fill the terminal. */ /* len = filename len + null */ len = strlen(filename) + 1; wcfname = calloc(len, sizeof(wchar_t)); wclen = mbstowcs(wcfname, fname, len); wcwid = wcswidth(wcfname, wclen); padwid = filenamelen - wcwid; /* if padwid is < 0, we need to trim the string so padwid = 0 */ if(padwid < 0) { int i = filenamelen - 3; wchar_t *wcp = wcfname; /* grab the max number of char columns we can fill */ while(i > 0 && wcwidth(*wcp) < i) { i -= wcwidth(*wcp); wcp++; } /* then add the ellipsis and fill out any extra padding */ wcscpy(wcp, L"..."); padwid = i; } rate_human = humanize_size((off_t)rate, '\0', 0, &rate_label); xfered_human = humanize_size(xfered, '\0', 0, &xfered_label); /* 1 space + filenamelen + 1 space + 7 for size + 1 + 7 for rate + 2 for /s + 1 space + 8 for eta */ printf(" %ls%-*s %6.1f%s %#6.1f%s/s %02u:%02u:%02u", wcfname, padwid, "", xfered_human, xfered_label, rate_human, rate_label, eta_h, eta_m, eta_s); free(fname); free(wcfname); if(totaldownload) { fill_progress(file_percent, total_percent, cols - infolen); } else { fill_progress(file_percent, file_percent, cols - infolen); } return; }
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); }
/** * Display the details of a package. * Extra information entails 'required by' info for sync packages and backup * files info for local packages. * @param pkg package to display information for * @param from the type of package we are dealing with * @param extra should we show extra information */ void dump_pkg_full(alpm_pkg_t *pkg, int extra) { unsigned short cols; time_t bdate, idate; alpm_pkgfrom_t from; double size; char bdatestr[50] = "", idatestr[50] = ""; const char *label, *reason; alpm_list_t *validation = NULL, *requiredby = NULL, *optionalfor = NULL; from = alpm_pkg_get_origin(pkg); /* set variables here, do all output below */ bdate = (time_t)alpm_pkg_get_builddate(pkg); if(bdate) { strftime(bdatestr, 50, "%c", localtime(&bdate)); } idate = (time_t)alpm_pkg_get_installdate(pkg); if(idate) { strftime(idatestr, 50, "%c", localtime(&idate)); } switch(alpm_pkg_get_reason(pkg)) { case ALPM_PKG_REASON_EXPLICIT: reason = _("Explicitly installed"); break; case ALPM_PKG_REASON_DEPEND: reason = _("Installed as a dependency for another package"); break; default: reason = _("Unknown"); break; } alpm_pkgvalidation_t v = alpm_pkg_get_validation(pkg); if(v) { if(v & ALPM_PKG_VALIDATION_NONE) { validation = alpm_list_add(validation, _("None")); } else { if(v & ALPM_PKG_VALIDATION_MD5SUM) { validation = alpm_list_add(validation, _("MD5 Sum")); } if(v & ALPM_PKG_VALIDATION_SHA256SUM) { validation = alpm_list_add(validation, _("SHA256 Sum")); } if(v & ALPM_PKG_VALIDATION_SIGNATURE) { validation = alpm_list_add(validation, _("Signature")); } } } else { validation = alpm_list_add(validation, _("Unknown")); } if(extra || from == ALPM_PKG_FROM_LOCALDB) { /* compute this here so we don't get a pause in the middle of output */ requiredby = alpm_pkg_compute_requiredby(pkg); optionalfor = alpm_pkg_compute_optionalfor(pkg); } cols = getcols(fileno(stdout)); /* actual output */ if(from == ALPM_PKG_FROM_SYNCDB) { string_display(_("Repository :"), alpm_db_get_name(alpm_pkg_get_db(pkg)), cols); } string_display(_("Name :"), alpm_pkg_get_name(pkg), cols); string_display(_("Version :"), alpm_pkg_get_version(pkg), cols); string_display(_("Description :"), alpm_pkg_get_desc(pkg), cols); string_display(_("Architecture :"), alpm_pkg_get_arch(pkg), cols); string_display(_("URL :"), alpm_pkg_get_url(pkg), cols); list_display(_("Licenses :"), alpm_pkg_get_licenses(pkg), cols); list_display(_("Groups :"), alpm_pkg_get_groups(pkg), cols); deplist_display(_("Provides :"), alpm_pkg_get_provides(pkg), cols); deplist_display(_("Depends On :"), alpm_pkg_get_depends(pkg), cols); optdeplist_display(pkg, cols); if(extra || from == ALPM_PKG_FROM_LOCALDB) { list_display(_("Required By :"), requiredby, cols); list_display(_("Optional For :"), optionalfor, cols); } deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols); size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); } else if(from == ALPM_PKG_FROM_FILE) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Compressed Size:"), config->colstr.nocolor, size, label); } else { // autodetect size for "Installed Size" label = "\0"; } size = humanize_size(alpm_pkg_get_isize(pkg), label[0], 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label); string_display(_("Packager :"), alpm_pkg_get_packager(pkg), cols); string_display(_("Build Date :"), bdatestr, cols); if(from == ALPM_PKG_FROM_LOCALDB) { string_display(_("Install Date :"), idatestr, cols); string_display(_("Install Reason :"), reason, cols); } if(from == ALPM_PKG_FROM_FILE || from == ALPM_PKG_FROM_LOCALDB) { string_display(_("Install Script :"), alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"), cols); } if(from == ALPM_PKG_FROM_SYNCDB && extra) { const char *base64_sig = alpm_pkg_get_base64_sig(pkg); alpm_list_t *keys = NULL; if(base64_sig) { unsigned char *decoded_sigdata = NULL; size_t data_len; alpm_decode_signature(base64_sig, &decoded_sigdata, &data_len); alpm_extract_keyid(config->handle, alpm_pkg_get_name(pkg), decoded_sigdata, data_len, &keys); } else { keys = alpm_list_add(keys, _("None")); } string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg), cols); string_display(_("SHA256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); list_display(_("Signatures :"), keys, cols); } else { list_display(_("Validated By :"), validation, cols); } if(from == ALPM_PKG_FROM_FILE) { alpm_siglist_t siglist; int err = alpm_pkg_check_pgp_signature(pkg, &siglist); if(err && alpm_errno(config->handle) == ALPM_ERR_SIG_MISSING) { string_display(_("Signatures :"), _("None"), cols); } else if(err) { string_display(_("Signatures :"), alpm_strerror(alpm_errno(config->handle)), cols); } else { signature_display(_("Signatures :"), &siglist, cols); } alpm_siglist_cleanup(&siglist); } /* Print additional package info if info flag passed more than once */ if(from == ALPM_PKG_FROM_LOCALDB && extra) { dump_pkg_backups(pkg); } /* final newline to separate packages */ printf("\n"); FREELIST(requiredby); alpm_list_free(validation); }