mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
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 <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
cb9f046945
commit
80237630af
@ -85,6 +85,10 @@ Log action messages through \fBsyslog()\fP. This will insert log entries into
|
||||
.TP
|
||||
.B LogFile = \fI/path/to/file\fP
|
||||
Log actions directly to a file. Default is \fI/var/log/pacman.log\fP.
|
||||
.TP
|
||||
.B ShowSize
|
||||
Display the size of individual packages for \fB--sync\fP and \fB--query\fP
|
||||
modes.
|
||||
|
||||
.SH REPOSITORY SECTIONS
|
||||
Each repository section defines a section name and at least one location where
|
||||
|
@ -958,6 +958,9 @@ int SYMEXPORT alpm_parse_config(char *file, alpm_cb_db_register callback, const
|
||||
} else if(strcmp(origkey, "UseColor") == 0 || strcmp(key, "USECOLOR") == 0) {
|
||||
alpm_option_set_usecolor(1);
|
||||
_alpm_log(PM_LOG_DEBUG, _("config: usecolor"));
|
||||
} else if(strcmp(origkey, "ShowSize") == 0 || strcmp(key, "SHOWSIZE") == 0) {
|
||||
alpm_option_set_showsize(1);
|
||||
_alpm_log(PM_LOG_DEBUG, _("config: showsize"));
|
||||
} else {
|
||||
RET_ERR(PM_ERR_CONF_BAD_SYNTAX, -1);
|
||||
}
|
||||
|
@ -147,6 +147,9 @@ void alpm_option_set_needles(alpm_list_t *needles);
|
||||
unsigned short alpm_option_get_usecolor();
|
||||
void alpm_option_set_usecolor(unsigned short usecolor);
|
||||
|
||||
unsigned short alpm_option_get_showsize();
|
||||
void alpm_option_set_showsize(unsigned short showsize);
|
||||
|
||||
pmdb_t *alpm_option_get_localdb();
|
||||
alpm_list_t *alpm_option_get_syncdbs();
|
||||
|
||||
|
@ -140,6 +140,7 @@ const char *alpm_option_get_xfercommand() { return handle->xfercommand; }
|
||||
unsigned short alpm_option_get_nopassiveftp() { return handle->nopassiveftp; }
|
||||
unsigned short SYMEXPORT alpm_option_get_chomp() { return handle->chomp; }
|
||||
unsigned short alpm_option_get_usecolor() { return handle->use_color; }
|
||||
unsigned short SYMEXPORT alpm_option_get_showsize() { return handle->showsize; }
|
||||
|
||||
pmdb_t SYMEXPORT *alpm_option_get_localdb() { return handle->db_local; }
|
||||
alpm_list_t SYMEXPORT *alpm_option_get_syncdbs()
|
||||
@ -308,4 +309,9 @@ void alpm_option_set_usecolor(unsigned short usecolor)
|
||||
handle->use_color = usecolor;
|
||||
}
|
||||
|
||||
void alpm_option_set_showsize(unsigned short showsize)
|
||||
{
|
||||
handle->showsize = showsize;
|
||||
}
|
||||
|
||||
/* vim: set ts=2 sw=2 noet: */
|
||||
|
@ -66,6 +66,7 @@ typedef struct _pmhandle_t {
|
||||
unsigned short nopassiveftp; /* Don't use PASV ftp connections */
|
||||
unsigned short chomp; /* I Love Candy! */
|
||||
unsigned short use_color; /* enable colorful output */
|
||||
unsigned short showsize; /* Show individual package sizes */
|
||||
} pmhandle_t;
|
||||
|
||||
extern pmhandle_t *handle;
|
||||
|
@ -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);
|
||||
|
@ -131,7 +131,6 @@ static void usage(int op, char *myname)
|
||||
printf(_(" -p, --file <package> query a package file instead of the database\n"));
|
||||
printf(_(" -s, --search <regex> 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 <pkg> ignore a package upgrade (can be used more than once)\n"));
|
||||
}
|
||||
printf(_(" --config <path> 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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user