From 80237630af0b2241a8a756d7ed7d2be3f80cfec5 Mon Sep 17 00:00:00 2001 From: Nathan Jones Date: Fri, 1 Jun 2007 11:00:39 -0400 Subject: Change -z|--showsize flag to ShowSize pacman.conf option Also cleaned up some duplicate printf lines related to the ShowSize option. Signed-off-by: Nathan Jones Signed-off-by: Dan McGee --- src/pacman/conf.h | 1 - src/pacman/pacman.c | 4 ---- src/pacman/query.c | 12 +++++------- src/pacman/sync.c | 15 ++++++--------- src/pacman/util.c | 3 ++- 5 files changed, 13 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 11aa41be..4fff0abb 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -54,7 +54,6 @@ typedef struct __config_t { pmtransflag_t flags; unsigned short noask; unsigned int ask; - unsigned short showsize; } config_t; config_t *config_new(void); diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index e3656830..f0ae3287 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -131,7 +131,6 @@ static void usage(int op, char *myname) printf(_(" -p, --file query a package file instead of the database\n")); printf(_(" -s, --search search locally-installed packages for matching strings\n")); printf(_(" -u, --upgrades list all packages that can be upgraded\n")); - printf(_(" -z, --showsize display installed size of each package\n")); } else if(op == PM_OP_SYNC) { printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg); printf("%s:\n", str_opt); @@ -147,7 +146,6 @@ static void usage(int op, char *myname) printf(_(" -u, --sysupgrade upgrade all packages that are out of date\n")); printf(_(" -w, --downloadonly download packages but do not install/upgrade anything\n")); printf(_(" -y, --refresh download fresh package databases from the server\n")); - printf(_(" -z, --showsize display download size of each package\n")); printf(_(" --ignore ignore a package upgrade (can be used more than once)\n")); } printf(_(" --config set an alternate configuration file\n")); @@ -294,7 +292,6 @@ static int parseargs(int argc, char *argv[]) {"verbose", no_argument, 0, 'v'}, {"downloadonly", no_argument, 0, 'w'}, {"refresh", no_argument, 0, 'y'}, - {"showsize", no_argument, 0, 'z'}, {"noconfirm", no_argument, 0, 1000}, {"config", required_argument, 0, 1001}, {"ignore", required_argument, 0, 1002}, @@ -431,7 +428,6 @@ static int parseargs(int argc, char *argv[]) config->flags |= PM_TRANS_FLAG_NOCONFLICTS; break; case 'y': (config->op_s_sync)++; break; - case 'z': config->showsize = 1; break; case '?': return(1); default: return(1); } diff --git a/src/pacman/query.c b/src/pacman/query.c index a4a42075..fde093a4 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -132,16 +132,14 @@ int pacman_query(alpm_list_t *targets) alpm_list_t *grp; pmpkg_t *pkg = alpm_list_getdata(i); - /* print the package size with the output if -z option passed */ - if(config->showsize) { + printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); + + /* print the package size with the output if ShowSize option set */ + if(alpm_option_get_showsize()) { /* Convert byte size to MB */ double mbsize = alpm_pkg_get_size(pkg) / (1024.0 * 1024.0); - printf("local/%s %s [%.2f MB]", alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg), mbsize); - } else { - printf("local/%s %s", alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg)); + printf(" [%.2f MB]", mbsize); } if((grp = alpm_pkg_get_groups(pkg)) != NULL) { diff --git a/src/pacman/sync.c b/src/pacman/sync.c index d04c7da9..8626393e 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -245,18 +245,15 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) alpm_list_t *grp; pmpkg_t *pkg = alpm_list_getdata(j); - /* print the package size with the output if -z option passed */ - if(config->showsize) { + printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg), + alpm_pkg_get_version(pkg)); + + /* print the package size with the output if ShowSize option set */ + if(alpm_option_get_showsize()) { /* Convert byte size to MB */ double mbsize = alpm_pkg_get_size(pkg) / (1024.0 * 1024.0); - printf("%s/%s %s [%.2f MB]", alpm_db_get_name(db), - alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg), mbsize); - } else { - printf("%s/%s %s", alpm_db_get_name(db), - alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg)); + printf(" [%.2f MB]", mbsize); } if((grp = alpm_pkg_get_groups(pkg)) != NULL) { diff --git a/src/pacman/util.c b/src/pacman/util.c index e48ea10f..a5876122 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -294,7 +294,8 @@ void display_targets(alpm_list_t *syncpkgs) size += dispsize; isize += alpm_pkg_get_isize(pkg); - if(config->showsize) { + /* print the package size with the output if ShowSize option set */ + if(alpm_option_get_showsize()) { /* Convert byte size to MB */ mbdispsize = dispsize / (1024.0 * 1024.0); -- cgit v1.2.3-24-g4f1b