int
-yesno(const char *str)
+yesno(const char *str, int other)
{
char inbuf[128], *ip;
printf("Abort.\n");
exit(1);
}
- if (*ip == 'y' || *ip == 'n')
- return *ip == 'y' ? 1 : 0;
+ if (*ip == 'y' || *ip == 'n' || *ip == other)
+ return *ip == 'n' ? 0 : *ip;
}
}
int forcebest = 0;
char *rootdir = 0;
char *keyname = 0;
+ int keyname_depstr = 0;
int debuglevel = 0;
+ int answer, acnt = 0;
argc--;
argv++;
argc--;
argv++;
}
- if (argc > 2 && !strcmp(argv[1], "--keyname"))
+ else if (argc > 1 && !strcmp(argv[1], "--depstr"))
+ {
+ keyname_depstr = 1;
+ argc--;
+ argv++;
+ }
+ else if (argc > 2 && !strcmp(argv[1], "--keyname"))
{
keyname = argv[2];
argc -= 2;
if (!keyname)
rflags = selection_make(pool, &job2, argv[i], flags);
else
- rflags = selection_make_matchdeps(pool, &job2, argv[i], flags, pool_str2id(pool, keyname, 1), 0);
+ {
+ if (keyname_depstr)
+ flags |= SELECTION_MATCH_DEPSTR;
+ rflags = selection_make_matchdeps(pool, &job2, argv[i], flags, pool_str2id(pool, keyname, 1), 0);
+ }
if (repofilter.count)
selection_filter(pool, &job2, &repofilter);
if (archfilter.count)
queue_push2(&job, SOLVER_ERASE|SOLVER_CLEANDEPS|SOLVER_SOLVABLE_PROVIDES, pool_rel2id(pool, NAMESPACE_LANGUAGE, 0, REL_NAMESPACE, 1));
#endif
-#if defined(ENABLE_RPMDB) && (defined(SUSE) || defined(FEDORA))
rerunsolver:
-#endif
solv = solver_create(pool);
solver_set_flag(solv, SOLVER_FLAG_SPLITPROVIDES, 1);
#ifdef FEDORA
printf("install size change: %d K\n", transaction_calc_installsizechange(trans));
printf("\n");
- if (!yesno("OK to continue (y/n)? "))
+ acnt = solver_alternatives_count(solv);
+ if (acnt)
+ {
+ if (acnt == 1)
+ printf("Have one alternative:\n");
+ else
+ printf("Have %d alternatives:\n", acnt);
+ for (i = 1; i <= acnt; i++)
+ {
+ Id id, from;
+ int atype = solver_get_alternative(solv, i, &id, &from, 0, 0, 0);
+ printf(" - %s\n", solver_alternative2str(solv, atype, id, from));
+ }
+ printf("\n");
+ answer = yesno("OK to continue (y/n/a)? ", 'a');
+ }
+ else
+ answer = yesno("OK to continue (y/n)? ", 0);
+ if (answer == 'a')
+ {
+ Queue choicesq;
+ Queue answerq;
+ Id id, from, chosen;
+ int j;
+
+ queue_init(&choicesq);
+ queue_init(&answerq);
+ for (i = 1; i <= acnt; i++)
+ {
+ int atype = solver_get_alternative(solv, i, &id, &from, &chosen, &choicesq, 0);
+ printf("\n%s\n", solver_alternative2str(solv, atype, id, from));
+ for (j = 0; j < choicesq.count; j++)
+ {
+ Id p = choicesq.elements[j];
+ if (p < 0)
+ p = -p;
+ queue_push(&answerq, p);
+ printf("%6d: %s\n", answerq.count, pool_solvid2str(pool, p));
+ }
+ }
+ queue_free(&choicesq);
+ printf("\n");
+ for (;;)
+ {
+ char inbuf[128], *ip;
+ int neg = 0;
+ printf("OK to continue (y/n), or number to change alternative: ");
+ fflush(stdout);
+ *inbuf = 0;
+ if (!(ip = fgets(inbuf, sizeof(inbuf), stdin)))
+ {
+ printf("Abort.\n");
+ exit(1);
+ }
+ while (*ip == ' ' || *ip == '\t')
+ ip++;
+ if (*ip == '-' && ip[1] >= '0' && ip[1] <= '9')
+ {
+ neg = 1;
+ ip++;
+ }
+ if (*ip >= '0' && *ip <= '9')
+ {
+ int take = atoi(ip);
+ if (take > 0 && take <= answerq.count)
+ {
+ Id p = answerq.elements[take - 1];
+ queue_free(&answerq);
+ queue_push2(&job, (neg ? SOLVER_DISFAVOR : SOLVER_FAVOR) | SOLVER_SOLVABLE_NAME, pool->solvables[p].name);
+ solver_free(solv);
+ solv = 0;
+ goto rerunsolver;
+ break;
+ }
+ }
+ if (*ip == 'n' || *ip == 'y')
+ {
+ answer = *ip == 'n' ? 0 : *ip;
+ break;
+ }
+ }
+ queue_free(&answerq);
+ }
+ if (!answer)
{
printf("Abort.\n");
transaction_free(trans);
queue_init(&conflicts);
if (checkfileconflicts(pool, &checkq, newpkgs, newpkgsfps, &conflicts))
{
- if (yesno("Re-run solver (y/n/q)? "))
+ if (yesno("Re-run solver (y/n/q)? ", 0))
{
for (i = 0; i < newpkgs; i++)
if (newpkgsfps[i])