Add new --needed option for -S.

During a pacman operation such as a group install, pacman can ask several
questions such as "local version is up to date. Upgrade anyway?". They are
usually all answered either by yes or by no:
* yes when you want to reinstall all the targets.
* no when you only want to install the missing ones (either because you are
installing a group, or because you are copying a pacman -S line from wiki or
whatever).

So instead of asking this question for each target, it is now now configured
with a flag.  Yes will be the default -S behavior, No will be achieved with
the --needed flag.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Chantry Xavier 2007-11-22 21:01:45 +01:00 committed by Dan McGee
parent c15f7710de
commit 250331a636
6 changed files with 23 additions and 27 deletions

View File

@ -270,6 +270,7 @@ _pacman ()
-u --sysupgrade \ -u --sysupgrade \
-w --downloadonly \ -w --downloadonly \
-y --refresh \ -y --refresh \
--needed \
--ignore \ --ignore \
--config \ --config \
--logfile \ --logfile \

View File

@ -261,6 +261,9 @@ Sync Options[[SO]]
'\--sysupgrade' or '-u'. Passing two '\--refresh' or '-y' flags will force '\--sysupgrade' or '-u'. Passing two '\--refresh' or '-y' flags will force
a refresh of all package lists even if they are thought to be up to date. a refresh of all package lists even if they are thought to be up to date.
*\--needed*::
Only install the targets that are not already installed and up-to-date.
*\--ignore* <'package'>:: *\--ignore* <'package'>::
Directs pacman to ignore upgrades of package even if there is one Directs pacman to ignore upgrades of package even if there is one
available. Multiple packages can be specified by separating them available. Multiple packages can be specified by separating them

View File

@ -280,7 +280,8 @@ typedef enum _pmtransflag_t {
PM_TRANS_FLAG_DOWNLOADONLY = 0x200, PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
PM_TRANS_FLAG_NOSCRIPTLET = 0x400, PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
PM_TRANS_FLAG_NOCONFLICTS = 0x800, PM_TRANS_FLAG_NOCONFLICTS = 0x800,
PM_TRANS_FLAG_PRINTURIS = 0x1000 PM_TRANS_FLAG_PRINTURIS = 0x1000,
PM_TRANS_FLAG_NEEDED = 0x2000
} pmtransflag_t; } pmtransflag_t;
/* Transaction Events */ /* Transaction Events */
@ -321,7 +322,7 @@ typedef enum _pmtransconv_t {
PM_TRANS_CONV_CONFLICT_PKG = 0x04, PM_TRANS_CONV_CONFLICT_PKG = 0x04,
PM_TRANS_CONV_CORRUPTED_PKG = 0x08, PM_TRANS_CONV_CORRUPTED_PKG = 0x08,
PM_TRANS_CONV_LOCAL_NEWER = 0x10, PM_TRANS_CONV_LOCAL_NEWER = 0x10,
PM_TRANS_CONV_LOCAL_UPTODATE = 0x20, /* 0x20 flag can go here */
PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40 PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
} pmtransconv_t; } pmtransconv_t;

View File

@ -349,15 +349,14 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
local = _alpm_db_get_pkgfromcache(db_local, alpm_pkg_get_name(spkg)); local = _alpm_db_get_pkgfromcache(db_local, alpm_pkg_get_name(spkg));
if(local) { if(local) {
if(alpm_pkg_compare_versions(local, spkg) == 0) { if(alpm_pkg_compare_versions(local, spkg) == 0) {
/* spkg is NOT an upgrade, get confirmation before adding */ /* spkg is NOT an upgrade */
if(!(trans->flags & PM_TRANS_FLAG_PRINTURIS)) { if(trans->flags & PM_TRANS_FLAG_NEEDED) {
int resp = 0; _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"),
QUESTION(trans, PM_TRANS_CONV_LOCAL_UPTODATE, local, NULL, NULL, &resp); alpm_pkg_get_name(local), alpm_pkg_get_version(local));
if(!resp) { return(0);
_alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- skipping\n"), } else {
alpm_pkg_get_name(local), alpm_pkg_get_version(local)); _alpm_log(PM_LOG_WARNING, _("%s-%s is up to date -- reinstalling\n"),
return(0); alpm_pkg_get_name(local), alpm_pkg_get_version(local));
}
} }
} }
} }

View File

@ -305,7 +305,6 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
*response = yesno(str); *response = yesno(str);
break; break;
case PM_TRANS_CONV_LOCAL_NEWER: case PM_TRANS_CONV_LOCAL_NEWER:
if(!config->op_s_downloadonly) { if(!config->op_s_downloadonly) {
snprintf(str, LOG_STR_LEN, _(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] "), snprintf(str, LOG_STR_LEN, _(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] "),
alpm_pkg_get_name(data1), alpm_pkg_get_name(data1),
@ -315,16 +314,6 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
*response = 1; *response = 1;
} }
break; break;
case PM_TRANS_CONV_LOCAL_UPTODATE:
if(!config->op_s_downloadonly) {
snprintf(str, LOG_STR_LEN, _(":: %s-%s: local version is up to date. Upgrade anyway? [Y/n] "),
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
*response = yesno(str);
} else {
*response = 1;
}
break;
case PM_TRANS_CONV_CORRUPTED_PKG: case PM_TRANS_CONV_CORRUPTED_PKG:
if(!config->noconfirm) { if(!config->noconfirm) {
snprintf(str, LOG_STR_LEN, _(":: File %s is corrupted. Do you want to delete it? [Y/n] "), snprintf(str, LOG_STR_LEN, _(":: File %s is corrupted. Do you want to delete it? [Y/n] "),

View File

@ -129,6 +129,7 @@ static void usage(int op, const char * const myname)
printf(_(" -u, --sysupgrade upgrade all packages that are out of date\n")); 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(_(" -w, --downloadonly download packages but do not install/upgrade anything\n"));
printf(_(" -y, --refresh download fresh package databases from the server\n")); printf(_(" -y, --refresh download fresh package databases from the server\n"));
printf(_(" --needed only install outdated or not yet installed packages\n"));
printf(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n")); printf(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n"));
printf(_(" --ignoregroup <grp>\n" printf(_(" --ignoregroup <grp>\n"
" ignore a group upgrade (can be used more than once)\n")); " ignore a group upgrade (can be used more than once)\n"));
@ -261,8 +262,8 @@ static int parseargs(int argc, char *argv[])
{"info", no_argument, 0, 'i'}, {"info", no_argument, 0, 'i'},
{"dbonly", no_argument, 0, 'k'}, {"dbonly", no_argument, 0, 'k'},
{"list", no_argument, 0, 'l'}, {"list", no_argument, 0, 'l'},
{"nosave", no_argument, 0, 'n'},
{"foreign", no_argument, 0, 'm'}, {"foreign", no_argument, 0, 'm'},
{"nosave", no_argument, 0, 'n'},
{"owns", no_argument, 0, 'o'}, {"owns", no_argument, 0, 'o'},
{"file", no_argument, 0, 'p'}, {"file", no_argument, 0, 'p'},
{"print-uris", no_argument, 0, 'p'}, {"print-uris", no_argument, 0, 'p'},
@ -286,10 +287,11 @@ static int parseargs(int argc, char *argv[])
{"asdeps", no_argument, 0, 1008}, {"asdeps", no_argument, 0, 1008},
{"logfile", required_argument, 0, 1009}, {"logfile", required_argument, 0, 1009},
{"ignoregroup", required_argument, 0, 1010}, {"ignoregroup", required_argument, 0, 1010},
{"needed", no_argument, 0, 1011},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepituwygzq", opts, &option_index))) { while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepqituwygz", opts, &option_index))) {
alpm_list_t *list = NULL, *item = NULL; /* lists for splitting strings */ alpm_list_t *list = NULL, *item = NULL; /* lists for splitting strings */
if(opt < 0) { if(opt < 0) {
@ -361,6 +363,7 @@ static int parseargs(int argc, char *argv[])
} }
FREELIST(list); FREELIST(list);
break; break;
case 1011: config->flags |= PM_TRANS_FLAG_NEEDED; break;
case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break; case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break; case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break;
case 'R': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break; case 'R': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break;
@ -402,6 +405,9 @@ static int parseargs(int argc, char *argv[])
config->op_q_isfile = 1; config->op_q_isfile = 1;
config->flags |= PM_TRANS_FLAG_PRINTURIS; config->flags |= PM_TRANS_FLAG_PRINTURIS;
break; break;
case 'q':
config->quiet = 1;
break;
case 'r': case 'r':
if(alpm_option_set_root(optarg) != 0) { if(alpm_option_set_root(optarg) != 0) {
pm_printf(PM_LOG_ERROR, _("problem setting root '%s' (%s)\n"), pm_printf(PM_LOG_ERROR, _("problem setting root '%s' (%s)\n"),
@ -429,9 +435,6 @@ static int parseargs(int argc, char *argv[])
config->flags |= PM_TRANS_FLAG_NOCONFLICTS; config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
break; break;
case 'y': (config->op_s_sync)++; break; case 'y': (config->op_s_sync)++; break;
case 'q':
config->quiet = 1;
break;
case '?': return(1); case '?': return(1);
default: return(1); default: return(1);
} }