summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNagy Gabor <ngaba@bibl.u-szeged.hu>2007-11-23 22:32:40 +0100
committerDan McGee <dan@archlinux.org>2007-12-01 11:58:07 -0600
commitc15f7710deafe1b4fe9411381bd07cd0dbe8da48 (patch)
tree657ef0053d35f7310b1fb26584a9c7780cc5f9e3
parentf19820cba8c4da8d6b7c84c694f3d327e94095a4 (diff)
downloadpacman-c15f7710deafe1b4fe9411381bd07cd0dbe8da48.tar.xz
Unify dump_pkg_full in pacman [-Si, -Qip, -Qi and -Qii]
dump_pkg_sync is now a trivial wrapper for dump_pkg_full Some smaller changes: * string_display function added to util.c [prints None in case of empty string] * Filename field added to -Qip * rename License to Licenses * 'Compressed Size' used instead of 'Download Size' for -Qip Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Dan: fix whitespace errors, spacing issues, const modifiers] Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--src/pacman/package.c106
-rw-r--r--src/pacman/sync.c3
-rw-r--r--src/pacman/util.c10
-rw-r--r--src/pacman/util.h1
4 files changed, 58 insertions, 62 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 7b10bf28..ac3f8207 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -34,17 +34,18 @@
#include "package.h"
#include "util.h"
-/* Display the content of an installed package
+/* Display the content of a package
*
- * level: <1 - omits N/A info for file query (-Qp)
- * 1 - normal level
- * >1 - extra information (backup files)
+ * level: <0 - sync package [-Si]
+ * =0 - file query [-Qip]
+ * 1 - localdb query, normal level [-Qi]
+ * >1 - localdb query, extra information (backup files) [-Qii]
*/
void dump_pkg_full(pmpkg_t *pkg, int level)
{
const char *reason, *descheader;
time_t bdate, idate;
- char bdatestr[50], idatestr[50];
+ char bdatestr[50] = "", idatestr[50] = "";
const alpm_list_t *i;
alpm_list_t *requiredby = NULL, *depstrings = NULL;
@@ -54,9 +55,13 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
/* set variables here, do all output below */
bdate = alpm_pkg_get_builddate(pkg);
- strftime(bdatestr, 50, "%c", localtime(&bdate));
+ if(bdate) {
+ strftime(bdatestr, 50, "%c", localtime(&bdate));
+ }
idate = alpm_pkg_get_installdate(pkg);
- strftime(idatestr, 50, "%c", localtime(&idate));
+ if(idate) {
+ strftime(idatestr, 50, "%c", localtime(&idate));
+ }
switch((long)alpm_pkg_get_reason(pkg)) {
case PM_PKG_REASON_EXPLICIT:
@@ -84,10 +89,13 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
descheader = _("Description : ");
/* actual output */
- printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
- printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
- printf(_("URL : %s\n"), (char *)alpm_pkg_get_url(pkg));
- list_display(_("License :"), alpm_pkg_get_licenses(pkg));
+ if(level == 0) {
+ string_display(_("Filename :"), alpm_pkg_get_filename(pkg));
+ }
+ string_display(_("Name :"), alpm_pkg_get_name(pkg));
+ string_display(_("Version :"), alpm_pkg_get_version(pkg));
+ string_display(_("URL :"), alpm_pkg_get_url(pkg));
+ list_display(_("Licenses :"), alpm_pkg_get_licenses(pkg));
list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
list_display(_("Depends On :"), depstrings);
@@ -99,30 +107,44 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
}
list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
list_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
+ if(level < 0) {
+ printf(_("Download Size : %6.2f K\n"),
+ (float)alpm_pkg_get_size(pkg) / 1024.0);
+ }
+ if(level == 0) {
+ printf(_("Compressed Size: %6.2f K\n"),
+ (float)alpm_pkg_get_size(pkg) / 1024.0);
+ }
+
printf(_("Installed Size : %6.2f K\n"),
(float)alpm_pkg_get_isize(pkg) / 1024.0);
- printf(_("Packager : %s\n"), (char *)alpm_pkg_get_packager(pkg));
- printf(_("Architecture : %s\n"), (char *)alpm_pkg_get_arch(pkg));
- printf(_("Build Date : %s\n"), bdatestr);
+ string_display(_("Packager :"), alpm_pkg_get_packager(pkg));
+ string_display(_("Architecture :"), alpm_pkg_get_arch(pkg));
+ string_display(_("Build Date :"), bdatestr);
if(level > 0) {
- printf(_("Install Date : %s\n"), idatestr);
- printf(_("Install Reason : %s\n"), reason);
+ string_display(_("Install Date :"), idatestr);
+ string_display(_("Install Reason :"), reason);
+ }
+ if(level >= 0) {
+ string_display(_("Install Script :"),
+ alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
+ }
+
+ /* MD5 Sum for sync package */
+ if(level < 0) {
+ string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg));
}
- printf(_("Install Script : %s\n"),
- alpm_pkg_has_scriptlet(pkg) ? _("Yes") : _("No"));
/* printed using a variable to make i18n safe */
printf("%s", descheader);
indentprint(alpm_pkg_get_desc(pkg), mbstowcs(NULL, descheader, 0));
- printf("\n");
+ printf("\n\n");
/* Print additional package info if info flag passed more than once */
if(level > 1) {
- /* call new backup function */
- printf("\n");
dump_pkg_backups(pkg);
+ printf("\n");
}
- printf("\n");
FREELIST(depstrings);
}
@@ -131,45 +153,11 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
*/
void dump_pkg_sync(pmpkg_t *pkg, const char *treename)
{
- const char *descheader, *md5sum;
- const alpm_list_t *i;
- alpm_list_t *depstrings = NULL;
if(pkg == NULL) {
return;
}
-
- /* turn depends list into a text list */
- for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) {
- pmdepend_t *dep = (pmdepend_t*)alpm_list_getdata(i);
- depstrings = alpm_list_add(depstrings, alpm_dep_get_string(dep));
- }
-
- descheader = _("Description : ");
-
- md5sum = alpm_pkg_get_md5sum(pkg);
-
- printf(_("Repository : %s\n"), treename);
- printf(_("Name : %s\n"), (char *)alpm_pkg_get_name(pkg));
- printf(_("Version : %s\n"), (char *)alpm_pkg_get_version(pkg));
- list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
- list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
- list_display(_("Depends On :"), depstrings);
- list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
- list_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
- printf(_("Download Size : %6.2f K\n"), (float)alpm_pkg_get_size(pkg) / 1024.0);
- printf(_("Installed Size : %6.2f K\n"), (float)alpm_pkg_get_isize(pkg) / 1024.0);
-
- /* printed using a variable to make i18n safe */
- printf("%s", descheader);
- indentprint(alpm_pkg_get_desc(pkg), mbstowcs(NULL, descheader, 0));
- printf("\n");
-
- if (md5sum != NULL && md5sum[0] != '\0') {
- printf(_("MD5 Sum : %s"), md5sum);
- }
- printf("\n");
-
- FREELIST(depstrings);
+ string_display(_("Repository :"), treename);
+ dump_pkg_full(pkg, -1);
}
/* Display list of backup files and their modification states
@@ -199,7 +187,7 @@ void dump_pkg_backups(pmpkg_t *pkg)
if(md5sum == NULL) {
fprintf(stderr, _("error: could not calculate checksums for %s\n"),
- path);
+ path);
free(str);
continue;
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 58e616e7..77939623 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -372,7 +372,6 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
dump_pkg_sync(pkg, alpm_db_get_name(db));
- printf("\n");
foundpkg = 1;
break;
}
@@ -393,7 +392,6 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
dump_pkg_sync(pkg, alpm_db_get_name(db));
- printf("\n");
foundpkg = 1;
break;
}
@@ -411,7 +409,6 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db));
- printf("\n");
}
}
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index a925be36..89313c83 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -349,6 +349,16 @@ alpm_list_t *strsplit(const char *str, const char splitchar)
return(list);
}
+void string_display(const char *title, const char *string)
+{
+ printf("%s ", title);
+ if(string == NULL || string[0] == '\0') {
+ printf(_("None\n"));
+ } else {
+ printf("%s\n", string);
+ }
+}
+
void list_display(const char *title, const alpm_list_t *list)
{
const alpm_list_t *i;
diff --git a/src/pacman/util.h b/src/pacman/util.h
index e46555e0..0295d7e5 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -48,6 +48,7 @@ char *strtoupper(char *str);
char *strtrim(char *str);
char *strreplace(const char *str, const char *needle, const char *replace);
alpm_list_t *strsplit(const char *str, const char splitchar);
+void string_display(const char *title, const char *string);
void list_display(const char *title, const alpm_list_t *list);
void display_targets(const alpm_list_t *syncpkgs, pmdb_t *db_local);
int yesno(char *fmt, ...);