You are not logged in.

#1 2007-08-04 08:11:24

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

pacman --ask, how it works? Do someone know?

I was writing an wiki article and I needed the reader to install a couple of packages:
E.g.,
pacman -Sy first second

I use -y so pacman database will be updated, I'd also like that pacman answers 'n' to the question xxx: local is up to date upgrade anyway? automatically... is it possible?

Thanks

Offline

#2 2007-08-04 09:04:48

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: pacman --ask, how it works? Do someone know?

Read man pacman. The details of the --ask option are, uhm, enlightening. smile

For your purposes, you need the --noconfirm option.

Offline

#3 2007-08-04 16:12:24

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: pacman --ask, how it works? Do someone know?

--noconfirm answers `yes' to the question, not `no'...
And... man pacman about --ask is *really* well done. Yes... Patching time?

Offline

#4 2007-08-04 19:19:05

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: pacman --ask, how it works? Do someone know?

ezzetabi wrote:

--noconfirm answers `yes' to the question, not `no'...
And... man pacman about --ask is *really* well done. Yes... Patching time?

Indeed, it's quite funny wink
I had a quick look at src/pacman/callback.c , and just setting --ask=0 will answer no to several questions, including the one you want.
Read the code for more details.

The ask value is just a flag, corresponding to this :

/* Transaction Conversations (ie, questions) */
typedef enum _pmtransconv_t {
    PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01,
    PM_TRANS_CONV_REPLACE_PKG = 0x02,
    PM_TRANS_CONV_CONFLICT_PKG = 0x04,
    PM_TRANS_CONV_CORRUPTED_PKG = 0x08,
    PM_TRANS_CONV_LOCAL_NEWER = 0x10,
    PM_TRANS_CONV_LOCAL_UPTODATE = 0x20,
    PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
} pmtransconv_t;

So if you want to answer no to local uptodate and yes to these other questions, you need the following binary value :
1011111
which is 95 in decimal, so you can use --ask=95 .


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#5 2007-08-04 19:53:15

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: pacman --ask, how it works? Do someone know?

As an alternative that doesn't require binary math, try the yes command. It continuously writes the string you give it to stdout, so something like this should work:

yes n | pacman -Sy first second

If you know in advance what questions it will ask and the answers you want, you can do something like this:

(sleep 10 ; echo y ; sleep 5 ; echo n) | pacman -Sy first second

For anything more advanced, you'll need a tool like expect. Or the --ask option.

Offline

#6 2007-08-05 08:19:26

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: pacman --ask, how it works? Do someone know?

@shinning
Excellent and well done. This is exactly what I was expecting from --ask a simple set of answer where you can answer `no' with `zero' or `yes' with `one'.
Why not put that table in the manual?

Offline

#7 2007-08-05 08:26:33

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: pacman --ask, how it works? Do someone know?

Ehh.. the manual already says:

It is doubtful whether this option even works, so I would not recommend using it.

That's more than enough info for me....

Offline

#8 2007-08-05 16:48:30

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: pacman --ask, how it works? Do someone know?

I get the impression that --ask was inspired by the SysV 'pkgask'. I'm not sure that anybody uses that either wink

Offline

#9 2007-08-20 20:27:43

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: pacman --ask, how it works? Do someone know?

I brought up this issue on the ML :
http://www.archlinux.org/pipermail/pacm … 09111.html

and we are actually considering dropping this option, because it's too complicated, undocumented, and has a limited purpose.

I suppose you could still use skymt's workaround, or just let the user answer pacman's questions ?


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#10 2007-08-21 13:44:52

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

Re: pacman --ask, how it works? Do someone know?

Why do you say it is complicated?
Using binary digit for making a set of positive answers is a nice idea!
About implementing better I can only ask you can put directly the binary number on the command line saving some binary calculus.
And of course copying the enum _pmtransconv_t idea in the man.

Of course you can let the user answer, but I often like giving answers in the command like directly...

Offline

#11 2007-08-21 13:54:18

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: pacman --ask, how it works? Do someone know?

ezzetabi wrote:

Of course you can let the user answer, but I often like giving answers in the command like directly...

These questions asked by pacman might change, the pmtransconv_t might change as well.
This would break all your pacman commands using --ask, and would require you to update them every time.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

Board footer

Powered by FluxBB