LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   doinst.sh syntax (help please) (https://www.linuxquestions.org/questions/slackware-14/doinst-sh-syntax-help-please-522655/)

Dark Carnival 01-25-2007 06:21 AM

doinst.sh syntax (help please)
 
I'm currently adding packages to my slackware install cd's and I've finally come to a point where I do need to write a doinst.sh script to sort a few things out after the installation..

I need the packages to install and word inside the slackware installer.. so I suppose they should be ash-compatible.

I've seen a few scripts inside packages such as:
( cd /path/to/program; ln -s link sourcefile )
( cd /path/to/program; ln -s link2 sourcefile2 )

Now.. that hardly look like my average bash script..

Is it not possible for me to just omit parenthesises and handle the same action like so:

cd /path/to/program
ln -s link sourcefile
ln -s link2 sourcefile2

And can't I just use if-blocks, for-loops and so on like I usually do with bash scripts ?

The reason I ask is because the tutorial on linuxpackages.net show regular sh syntax but the scripts I've seen in doinst.sh files so far show the other syntax...

Please help :)

wjevans_7d1@yahoo.co 01-25-2007 07:24 AM

The effect of the parentheses is to fire off a subshell to do the work within those parentheses, and then come back to your original shell.

In the example you cite, this aspect is important. When you come back to the main shell, your current directory is as it was before you did the work. Try this at your shell prompt:

pwd
(cd /; pwd)
pwd
cd ;/ pwd
pwd

.. and you'll see what the parentheses buy for you.

Alien Bob 01-25-2007 07:49 AM

The doinst.sh is just a shell script. You have to take into account though that when you have a package on the install CD, the shell it runs in is not bash but the less powerful "ash" (which does not have all of the functionality of the bigger bash). So you should check your script against the ash manual perhaps.
Most standard shell scripting commands will be handled properly by ash, so I expect no real problems here.

An important thing to know is that you should not use absolute paths in the doinst.sh script. That is why you'll see lines like
Code:

config etc/rc.d/rc.httpd.new
instead of
Code:

config /etc/rc.d/rc.httpd.new
. The reason is that you can instruct installpkg to install a package somewhere else than to "/" (your root filesystem), and that is exactly how the install CD works (the partition that Slackware is being installed to is mounted somewhere under /var IIRC).

Eric

Dark Carnival 01-25-2007 09:08 AM

Thanks a lot to both of you :)

I'll keep both things in mind and hopefully my packages won't blow up during installation or anything :rolleyes:


All times are GMT -5. The time now is 05:10 AM.