On Fri, 31 May 2002, Miguel Beccari wrote:

> I builded a RPM from scratch of an application of mine.
> 
> The SRC rpm works: it builds 2 i586 architecture packages, it has got 
> good controls, it check dependecies and so on.
> 
> My trouble is this: how to force the user to answer some questions 
> before install the package ?
> 
> I wrote down theese lines:
> 
> 
> %pre
> 
> echo "Bla bla bla.....";
> echo -n "Answer (yes | no | later)";
> read chiave
> while ( test -z $chiave ); do
>         read chiave
> done;
> 
> 
> that produce a  /var/tmp/rpm-tmp.19101 as follow:
> 
> echo "Bla bla bla.....";
> echo -n "Answer (yes | no | later)";
> read chiave
> while ( test -z $chiave ); do
>         read chiave
> done;
> 
> 
> 
> The problem is that $chiave is NEVER != zero.
> 
> 
> Some one can help me ?
> 

Are you saying the script behave differently in the RPM than if you just
run it?  I would do something a little more bulletproof, which would force
them to answer one of your choices, unless they ctrl-C out of it:

#!/bin/sh
echo "Bla bla bla.....";

GoodAnswer () {
    # do something now
    echo "You answered $chiave"
}

GetInput () {
    echo -n "Answer (yes | no | later)";
    read chiave

    while [ -z "$chiave" ]; do
        GetInput
    done;
}

GetInput

case $chiave in
    yes | no | later)
        GoodAnswer
        ;;
    *)
        GetInput
        ;;
    esac

Of course if they install with rpmdrake or whatever, you need to call up a
terminal window. Others may have even better suggestions.

Stew Benedict

-- 
MandrakeSoft    
PPC FAQ: http://www.linux-mandrake.com/en/ppcFAQ.php3
IRC: irc.openproject.net #cooker-ppc


Reply via email to