Slackware This Forum is for the discussion of Slackware Linux.
|
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-01-2012, 05:41 AM
|
#1
|
|
Member
Registered: Jul 2006
Location: Tübingen, Germany
Distribution: Slackware64-13.37
Posts: 726
Rep:
|
on SlackBuild scripting
Hello,
I am writing a SlackBuild script for an application. The odd thing is that the configure script of the application at some point prompts the user to enter a number from the terminal
and then goes on. Until one enters a number, it just hangs and waits. My question is, is there a way to provide the number (the answer) to the configure call in the SlackBuild script itself, so that it doesn't prompt and the package building runs smoothly?
Any suggestions will be appreciated.
|
|
|
|
05-01-2012, 05:53 AM
|
#2
|
|
Member
Registered: Aug 2011
Distribution: Slackware
Posts: 237
Rep:
|
Of course you can.
The method you should use depends in the quality of the random number you need.
For cryptographic software, you want the best randomness you can get. You can surely obtain it by the clever use of openssl's "rand" and some scripting abilities.
If you don't need crypto-geek randomness, the Bash shell has a built in function to generate numbers between 0 and 32767. There is plenty of information about the $RANDOM function in search engines.
Please, tell us what software are you dealing with so we can decide upon facts.
|
|
|
|
05-01-2012, 06:11 AM
|
#3
|
|
Member
Registered: Jul 2006
Location: Tübingen, Germany
Distribution: Slackware64-13.37
Posts: 726
Original Poster
Rep:
|
Quote:
Originally Posted by BlackRider
Of course you can.
The method you should use depends in the quality of the random number you need.
For cryptographic software, you want the best randomness you can get. You can surely obtain it by the clever use of openssl's "rand" and some scripting abilities.
If you don't need crypto-geek randomness, the Bash shell has a built in function to generate numbers between 0 and 32767. There is plenty of information about the $RANDOM function in search engines.
Please, tell us what software are you dealing with so we can decide upon facts.
|
Oh, no it has nothing to do with random numbers, actually it is a fixed number (25) that I must type from the console during the configure. Can I
provide that number in the script, so that no prompt comes? This number gives the architecture that the sources will be configured for, and in my case 25 means Linux 64 bit with gfortran and gcc.
|
|
|
|
05-01-2012, 06:46 AM
|
#4
|
|
Member
Registered: Aug 2011
Distribution: Slackware
Posts: 237
Rep:
|
If the configure script accepts the number as an option (i.e: you could use "./configure --number=25") or variable (i.e: you could use "NUMBER=25 ./configure"), then it is as easy as setting the variable from the start of the SlackBuild script. If you are using the classical template, you should find something like this somewhere:
Code:
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) ARCH=$( uname -m ) ;;
esac
fi
You can modify this so it looks like:
Code:
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 && NUMBER=whatever1;;
arm*) ARCH=arm && NUMBER=whatever2;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) ARCH=$( uname -m ) && NUMBER=whatever3;;
esac
fi
When running configure, you would just pass it the NUMBER variable by the means accepted by the script. It would look like this, where the "number" option is the option that parses your 25:
Code:
./configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/man \
--docdir=/usr/doc/$PRGNAM-$VERSION \
--build=$ARCH-slackware-linux \
--number=$NUMBER
Other tweaks may be needed, but I hope you get the idea.
If the configure script does not accept the number as an input, and supports only interactive prompting, then you are supposed to patch the ./configure script so it behaves like explained above. You can do this by having the ./configure script accept non-interactive modes or by making it figure the number by itself.
Last edited by BlackRider; 05-01-2012 at 06:56 AM.
|
|
|
|
05-01-2012, 06:50 AM
|
#5
|
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian Squeeze (server), Slackware 13.37 (netbook), Slackware64 14.0 (desktop),
Posts: 8,357
|
Edit pkgname.SlackBuild's running of the configure command, something like echo 25 | ./configure ...
If that works you could implement it to use a variable value instead of 25 and set that variable before running pkgname.SlackBuild.
|
|
|
1 members found this post helpful.
|
05-01-2012, 08:15 AM
|
#6
|
|
Member
Registered: Apr 2011
Posts: 178
Rep:
|
Two ideas:
1) check to see if the install script that you are running has a help flag which might tell you a way to pass this number as an argument or an environment variable. For example, ./configure -h could tell you that calling ./configure --arch=25 is equivalent to providing the number during the script.
2) Patch the script so that instead of asking it just uses 25. Many SlackBuilds patch the source code or the Makefiles to fix problems, and in this case it shouldn't be too hard to remove the prompt and assign 25 to the variable in question.
Last edited by bosth; 05-01-2012 at 08:19 AM.
|
|
|
1 members found this post helpful.
|
05-01-2012, 08:42 AM
|
#7
|
|
Member
Registered: Jul 2008
Distribution: Slackware 13.1
Posts: 277
Rep:
|
Quote:
Originally Posted by catkin
Edit pkgname.SlackBuild's running of the configure command, something like echo 25 | ./configure ...
|
This is how I have dealt with this issue in the past. It allows the slackbuild to continue uninterrupted.
Last edited by larryhaja; 05-01-2012 at 08:43 AM.
|
|
|
|
05-01-2012, 09:18 AM
|
#8
|
|
Member
Registered: Jul 2006
Location: Tübingen, Germany
Distribution: Slackware64-13.37
Posts: 726
Original Poster
Rep:
|
Quote:
Originally Posted by catkin
Edit pkgname.SlackBuild's running of the configure command, something like echo 25 | ./configure ...
If that works you could implement it to use a variable value instead of 25 and set that variable before running pkgname.SlackBuild.
|
Thank you very much for your reply, it worked like a charm.
The configure script does not allow a parameter for this option, and the prompt actually comes from a perl script, so hacking it would not be easy for me.
But the echo-pipe thing worked perfectly, many thanks!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 07:02 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|