summaryrefslogtreecommitdiff
path: root/src/pacman/package.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman/package.c')
-rw-r--r--src/pacman/package.c76
1 files changed, 56 insertions, 20 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 97d89688..6e091d58 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -1,7 +1,7 @@
/*
* package.c
*
- * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2012 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -18,14 +18,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
+#include <time.h>
#include <alpm.h>
#include <alpm_list.h>
@@ -39,20 +38,34 @@
/** Turn a depends list into a text list.
* @param deps a list with items of type alpm_depend_t
- * @return a string list, must be freed
*/
static void deplist_display(const char *title,
alpm_list_t *deps)
{
alpm_list_t *i, *text = NULL;
for(i = deps; i; i = alpm_list_next(i)) {
- alpm_depend_t *dep = alpm_list_getdata(i);
+ alpm_depend_t *dep = i->data;
text = alpm_list_add(text, alpm_dep_compute_string(dep));
}
list_display(title, text);
FREELIST(text);
}
+/** Turn a optdepends list into a text list.
+ * @param optdeps a list with items of type alpm_optdepend_t
+ */
+static void optdeplist_display(const char *title,
+ alpm_list_t *optdeps)
+{
+ alpm_list_t *i, *text = NULL;
+ for(i = optdeps; i; i = alpm_list_next(i)) {
+ alpm_depend_t *optdep = i->data;
+ text = alpm_list_add(text, alpm_dep_compute_string(optdep));
+ }
+ list_display_linebreak(title, text);
+ FREELIST(text);
+}
+
/**
* Display the details of a package.
* Extra information entails 'required by' info for sync packages and backup
@@ -64,6 +77,7 @@ static void deplist_display(const char *title,
void dump_pkg_full(alpm_pkg_t *pkg, int extra)
{
const char *reason;
+ alpm_list_t *validation = NULL;
time_t bdate, idate;
char bdatestr[50] = "", idatestr[50] = "";
const char *label;
@@ -74,11 +88,11 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
from = alpm_pkg_get_origin(pkg);
/* set variables here, do all output below */
- bdate = alpm_pkg_get_builddate(pkg);
+ bdate = (time_t)alpm_pkg_get_builddate(pkg);
if(bdate) {
strftime(bdatestr, 50, "%c", localtime(&bdate));
}
- idate = alpm_pkg_get_installdate(pkg);
+ idate = (time_t)alpm_pkg_get_installdate(pkg);
if(idate) {
strftime(idatestr, 50, "%c", localtime(&idate));
}
@@ -95,6 +109,25 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
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 == PKG_FROM_LOCALDB) {
/* compute this here so we don't get a pause in the middle of output */
requiredby = alpm_pkg_compute_requiredby(pkg);
@@ -112,7 +145,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
deplist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
deplist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
- list_display_linebreak(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
+ optdeplist_display(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
if(extra || from == PKG_FROM_LOCALDB) {
list_display(_("Required By :"), requiredby);
}
@@ -141,12 +174,8 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
}
- if(from == PKG_FROM_SYNCDB) {
- string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg));
- string_display(_("SHA256 Sum :"), alpm_pkg_get_sha256sum(pkg));
- string_display(_("Signatures :"),
- alpm_pkg_get_base64_sig(pkg) ? _("Yes") : _("None"));
- }
+ list_display(_("Validated By :"), validation);
+
if(from == PKG_FROM_FILE) {
alpm_siglist_t siglist;
int err = alpm_pkg_check_pgp_signature(pkg, &siglist);
@@ -160,6 +189,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
}
alpm_siglist_cleanup(&siglist);
}
+
string_display(_("Description :"), alpm_pkg_get_desc(pkg));
/* Print additional package info if info flag passed more than once */
@@ -171,6 +201,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
printf("\n");
FREELIST(requiredby);
+ alpm_list_free(validation);
}
static const char *get_backup_file_status(const char *root,
@@ -223,7 +254,7 @@ void dump_pkg_backups(alpm_pkg_t *pkg)
if(alpm_pkg_get_backup(pkg)) {
/* package has backup files, so print them */
for(i = alpm_pkg_get_backup(pkg); i; i = alpm_list_next(i)) {
- const alpm_backup_t *backup = alpm_list_getdata(i);
+ const alpm_backup_t *backup = i->data;
const char *value;
if(!backup->hash) {
continue;
@@ -251,11 +282,16 @@ void dump_pkg_files(alpm_pkg_t *pkg, int quiet)
for(i = 0; i < pkgfiles->count; i++) {
const alpm_file_t *file = pkgfiles->files + i;
+ /* Regular: '<pkgname> <root><filepath>\n'
+ * Quiet : '<root><filepath>\n'
+ */
if(!quiet) {
- printf("%s %s%s\n", pkgname, root, file->name);
- } else {
- printf("%s%s\n", root, file->name);
+ fputs(pkgname, stdout);
+ putchar(' ');
}
+ fputs(root, stdout);
+ fputs(file->name, stdout);
+ putchar('\n');
}
fflush(stdout);
@@ -280,10 +316,10 @@ void dump_pkg_changelog(alpm_pkg_t *pkg)
/* if we hit the end of the file, we need to add a null terminator */
*(buf + ret) = '\0';
}
- printf("%s", buf);
+ fputs(buf, stdout);
}
alpm_pkg_changelog_close(pkg, fp);
- printf("\n");
+ putchar('\n');
}
}