LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-01-2012, 05:41 AM   #1
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Rep: Reputation: 55
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.
 
Old 05-01-2012, 05:53 AM   #2
BlackRider
Member
 
Registered: Aug 2011
Posts: 295

Rep: Reputation: 101Reputation: 101
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.
 
Old 05-01-2012, 06:11 AM   #3
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by BlackRider View Post
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.
 
Old 05-01-2012, 06:46 AM   #4
BlackRider
Member
 
Registered: Aug 2011
Posts: 295

Rep: Reputation: 101Reputation: 101
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.
 
Old 05-01-2012, 06:50 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.
Old 05-01-2012, 08:15 AM   #6
bosth
Member
 
Registered: Apr 2011
Location: British Columbia, Canada
Posts: 304

Rep: Reputation: 127Reputation: 127
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.
Old 05-01-2012, 08:42 AM   #7
larryhaja
Member
 
Registered: Jul 2008
Distribution: Slackware 13.1
Posts: 305

Rep: Reputation: 80
Quote:
Originally Posted by catkin View Post
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.
 
Old 05-01-2012, 09:18 AM   #8
tramni1980
Member
 
Registered: Jul 2006
Location: Köln, Germany
Distribution: Slackware64-14.2 & -current, DragonFly BSD, OpenBSD
Posts: 819

Original Poster
Rep: Reputation: 55
Thumbs up

Quote:
Originally Posted by catkin View Post
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 04:02 AM
Firefox Scripting Add-on (Scripting HTML / Javascript inside Firefox) linuxbeatswindows Programming 1 09-18-2009 10:09 PM
OO 3.01 slackbuild ? brodo Slackware 4 02-01-2009 04:06 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
SlackBuild CrEsPo Slackware 2 03-19-2006 01:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration