LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Script that changes the install location of SlackBuilds (https://www.linuxquestions.org/questions/slackware-14/script-that-changes-the-install-location-of-slackbuilds-777863/)

affinity 12-24-2009 06:33 AM

Script that changes the install location of SlackBuilds
 
I prefer installing third party software in the /usr/local directory so that I can keep it separate from the official install. This is purely personal preference, but I find it easier to backup just the /usr/local directory rather than the entire /usr directory. So I wrote a simple script that changes the install location of a SlackBuild to the /usr/local directory, I figured I'd share it in case anyone else was interested since I get a lot of information out of these forums.

Code:

#!/bin/sh
SOURCE=$(cat file.txt)
TARGET=$SOURCE.new
WORKDIR=/home/frank/Documents/SlackBuilds
CWD=$(pwd)

if [ $CWD != $WORKDIR ]; then
        cd $WORKDIR
fi

ls|grep SlackBuild > file.txt
sed -e 's:/usr:/usr/local:g' $SOURCE > $TARGET
mv $TARGET $SOURCE
exit

This will only work if there is only one SlackBuild in the directory since I have it automatically finding the name of the SlackBuild in the directory. If there is a better way of doing this by all means share, it doesn't look fancy but it gets the job done so I'm happy with it.

TSquaredF 12-24-2009 11:04 AM

Everyone programs differently. If I used a script, I would tend to use one like this
Code:

#!/bin/sh
SOURCE=$1.SlackBuild
TARGET=$SOURCE.new
WORKDIR=/home/bill/slackbuilds
if [ $CWD != $WORKDIR ]; then
        cd $WORKDIR
fi
sed -e 's:/usr:/usr/local:g' $SOURCE > $TARGET
mv $TARGET $SOURCE
exit

Then I could have a whole directory full of SlackBuilds & just feed the script the package name, as in
Code:

convert.sh numlockx
However, for something like this, I would just open it in an editor & use Search & Replace.
Regards,
Bill

affinity 12-24-2009 11:23 AM

Quote:

Then I could have a whole directory full of SlackBuilds & just feed the script the package name, as in
Code:

convert.sh numlockx
Bill
That's a very useful idea, thanks for the tip.


All times are GMT -5. The time now is 09:44 PM.