[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Debconf, package.config script and subst+multiselect



Please reply to the list, not just to me personally.

On 04/05/15 22:41, Yurkao wrote:
> 4 мая 2015 г., в 23:43, Christopher Baines <chris@cbaines.net
> <mailto:chris@cbaines.net>> написал(а):
> 
>> On 04/05/15 20:51, Yurkao wrote:
>>> Dear mentors,
>>> As I've understood from debconf(7):
>>> - package config script runs twice during the deb installation
>>> As a result:
>>> - package config script must be idempotent and must not/should not
>>> ask questions twice.
>>>
>>> As I understand,I should control not asking question twice by
>>> checking if return value of db_input equals to 30.
>>
>> That is the return status you will get from db_input if it is not going
>> to show that question. If that is returned, the question will not be
>> shown.
>>
>> "Debconf decides if the question is actually displayed, based on its
>> priority, and whether the user has seen it before, and which frontend is
>> being used. If the question will not be displayed,
>> debconf replies with code 30." (from the debconf-devel manpage)
>>
>> There are also some more undocumented reasons, e.g. for select
>> questions, you will get this response if there are < 2 choices.
>>
>>> If so, what if I should "render" multiselect choices of template with
>>> db_subst?
>>
>> I don't understand what you mean here.
> For example I have following template:
> 
> Template: /packagename///something/ 
> 
> Type: /multiselect/
> 
> Choices: /${defchoices}/
> 
> Description: Blah blah blah? 
> 
>  Blah blah blah. Blah blah. Blah blah blah. Blah blah? Blah
> 
> How do I prevent asking question twice in config script?
> 
> Option #1:
> 
> db_fget packagename/something seen|| return 0 

This line seems redundant, you do not use $RET?

> db_subst packagename/something defchoices "Xxx, yyy"
> 
> db_input $priority packagename/something || return 0
> 
> db_go 
> 
> Or option #2:
> 
> db_subst packagename/something defchoices "Xxx, yyy"
> 
> db_input $priority packagename/something || return 0 # assume 0/30 only
> return values
> 
> db_go 
> 
> Or the above two options are totally equivalent?

If you are referring to it being shown twice because the script is run
twice, I believe I am right in what I said previously:

"Debconf will manage this for you, as the seen flag. This will be set to
true when the question is seen, and therefore the question will not be
shown again unless the flag is explicitly set to false (or probably for
other reasons also...)."

When you test this, is the question showing to the user twice?

>>> How do I avoid calling db_subst on second config run ? Should I avoid
>>> calling db_subst on second run?
>>
>> If the question is not shown, calling db_subst should do nothing, and
>> not be a problem?
>>
>>> What is the best way to avoid asking questions twice? By checking
>>> result of db_input=30 or by calling 'db_fget question seen'?
>>
>> Debconf will manage this for you, as the seen flag. This will be set to
>> true when the question is seen, and therefore the question will not be
>> shown again unless the flag is explicitly set to false (or probably for
>> other reasons also...).
> What other reasons could be ?

>From the debconf-devel manpage, the seen flag is ignored when the
package is being reconfigured. I also thought that input priority might
also affect the effect of the seen flag, although I can't find a reference.




Reply to: