LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Can I just generate doinst.sh with package? (https://www.linuxquestions.org/questions/slackware-14/can-i-just-generate-doinst-sh-with-package-596716/)

binarybob0001 11-02-2007 06:17 PM

Can I just generate doinst.sh with package?
 
There are some cases where I would just love to generate a doinst.sh without actually packaging anything. Is this possible?

Alien Bob 11-02-2007 06:39 PM

Quote:

Originally Posted by binarybob0001 (Post 2946259)
There are some cases where I would just love to generate a doinst.sh with actually packaging anything. Is this possible?

I have no clue about what your words mean, really. What exactly do you want to achieve?

Eric

binarybob0001 11-02-2007 07:06 PM

Change with to without. Does that make it easier to understand?

Alien Bob 11-02-2007 08:20 PM

No.
This "generate a doinst.sh without actually packaging anything" - it does not make any sense at all. Explain what you want with a clear example.

A doinst.sh script is just something that runs at the end of a package install... usually updating configuration files and such. It is a shell script, and if you want to write a piece of shell script without adding it to a package no one is going to stop you.

Eric

binarybob0001 11-02-2007 08:34 PM

OK here's and example. You download the ALSA lib tarball. You run
./configure
make
make DESTDIR=/usr/src/build
You cd into the /usr/src/build and you remove the links and make a doinst.sh without actually making a .tgz. That's what I want to do.

Stroker 11-02-2007 09:16 PM

Quote:

Originally Posted by binarybob0001 (Post 2946355)
OK here's and example. You download the ALSA lib tarball. You run
./configure
make
make DESTDIR=/usr/src/build
You cd into the /usr/src/build and you remove the links and make a doinst.sh without actually making a .tgz. That's what I want to do.

Sure just call the famous mkdoinst command

Contents of /usr/local/sbin/mkdoinst :

#!/bin/sh
#
# Strokers world famous mkdoinst script
# copyleft no rites reserved

makepkg foo.tgz
tar -xvvzf foo.tgz
rm foo.tgz

exit 0

binarybob0001 11-02-2007 11:46 PM

Thanks a bunch, sorry I was unclear. Writing is not my specialty.

binarybob0001 11-02-2007 11:49 PM

I don't have that command and google didn't turn up any results. It can't be that famous. Were you being sarcastic.

drumz 11-03-2007 12:44 AM

Code:

#!/bin/sh
#
# Strokers world famous mkdoinst script
# copyleft no rites reserved

makepkg foo.tgz
tar -xvvzf foo.tgz
rm foo.tgz

exit 0

That was it. You could try looking at /sbin/makepkg to try seeing how it makes the links for you when you make the package.

MS3FGX 11-03-2007 01:48 AM

I still don't see what you actually want to do here.

All makepkg does when creating your doinst.sh is remove the symbolic links from the directory structure, and make a Bash script that will recreate them on the destination machine. Is that what you are looking to do?

Anything else done in a doinst.sh is custom written by the person who packaged the software, and does not follow any preset rules or requirements. It is no different from a normal Bash script, and you can do whatever you please in it.

gnashley 11-03-2007 02:58 AM

src2pkg includes some of the dame code used in makepkg which creates the doinst.sh script, when applicable. As mentioned, all it does is search the contents of the package tree for links and creates a script which will create those links when the package is installed using installpkg. It then removes the actual links from the package tree and inserts the doinst.sh into the package tree before creating the final package by tarring and compressing the contents of the package tree.
drumz method is much simpler, but if you want to see what it does it goes like this:

# make_link_script
make_install_script() {
COUNT=1
LINE="$(sed -n "$COUNT p" $1)"
while [ ! "$LINE" = "" ]; do
LINKGOESIN="$(echo "$LINE" | cut -f 1 -d " ")"
LINKGOESIN="$(dirname $LINKGOESIN)"
LINKNAMEIS="$(echo "$LINE" | cut -f 1 -d ' ')"
LINKNAMEIS="$(basename "$LINKNAMEIS")"
LINKPOINTSTO="$(echo "$LINE" | cut -f 3 -d ' ')"
echo "( cd $LINKGOESIN ; rm -rf $LINKNAMEIS )"
echo "( cd $LINKGOESIN ; ln -sf $LINKPOINTSTO $LINKNAMEIS )"
COUNT=$(expr $COUNT + 1)
LINE="$(sed -n "$COUNT p" $1)"
done
}

#search for links and make link creation script if necessary
make_doinst_links() {
cd $PKG_DIR ;
TMP=/tmp
echo -n $BLUE"Searching for links in the PKG_DIR - "$NORMAL
INST=$(mktemp $TMP/src2pkg.XXXXXX)
# This requires the ls from coreutils-5.0 (or newer):
find . -type l -exec ls -l --time-style=long-iso {} \; | white_out | cut -f 8- -d ' ' | cut -b3- | tee $INST 1> /dev/null
if [ ! "$(cat $INST)" = "" ]; then
echo $GREEN"Done"$NORMAL
# echo -n $BLUE"Making link creation script - "$NORMAL
make_install_script $INST | tee $CWD/doinst.links 1> /dev/null
# echo $GREEN"Done"$NORMAL
else
echo "None found"
fi
rm -f $INST
}

binarybob0001 11-03-2007 01:07 PM

Thanks guys, I did what you all seemed to be leaning towards, I made my own script. Here it is for anyone who wants my crappy code. It's not well tested but so far it gets the job done.
Code:

GetDir()
{
  i=1
  tmp=`echo $1 | cut -c1 `
  if [ $tmp = "/" ]
  then
    i=2
  fi
  tmp=`echo $1 | cut -f $i -d '/' `
  while [ ! $tmp = " " ]
  do
    dir=$tmp
    i=`expr $i + 1 `
    tmp=`echo $1 | cut -f $i -d '/' `
  done
  name=$dir
  dir=`echo $1 | awk -F"/$dir" ' { print $1 }' `
  return
}

mkdir install
find . -type l -exec ls -l {} \; | while read var
do
  pertanent=`echo $var | cut -f 8- -d ' ' | cut -b3-`
  linkpath=`echo $pertanent | awk -F" -> " ' { print $1 }' `
  targpath=`echo $pertanent | awk -F" -> " ' { print $2 }' `
  GetDir $linkpath
  rm $linkpath
  echo "( cd $dir ; rm -rf $name )" | tee -a install/doinst.sh
  echo "( cd $dir ; ln -sf $targpath $name)" | tee -a install/doinst.sh
done

Finally, I get the chance to give something back. Thanks again.


All times are GMT -5. The time now is 12:11 PM.