LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   About creating symlinks in .SlackBuild and doinst.sh (https://www.linuxquestions.org/questions/slackware-14/about-creating-symlinks-in-slackbuild-and-doinst-sh-921180/)

cigerma 12-30-2011 02:10 AM

About creating symlinks in .SlackBuild and doinst.sh
 
Hi guys,
I'm a Slack noob, but I really enjoy Slackware's simplicity and stability. I'm trying
to build a system based on Slackware these days, I'm now able to write .SlackBuild myself,
but I have some problems with creating symlinks in .SlackBuild and doinst.sh. Yesterday I
wrote a .SlackBuild, and then made the package, installed it in the chroot environment, but
it finally damaged my system. I wrote the following two lines in the doinst.sh file because I thought it would be called from the chroot environment, not from the host:
Code:

(rm -rf /bin)
(ln -sf /usr/bin /bin)

I know this is really stupid! And of course I know where I'm wrong, then I looked at some official SlackBuild scripts, and I found Pat sometimes made symlinks using "relative path" and using "obsolute path" in other times.
So my question is:
1. Never use "obsolute path" with the "rm" command in the build script, right?
2. Is it always safer to use "relative path" in the build script and the post-install doinst.sh script ?
3. What should I pay attention to when install a package using "--root /someplace" compared to just install it in the host?

P.S.: Sorry for my poor english, I wish you will understand what I'm saying.:)

bobzilla 12-30-2011 08:42 PM

Why would you want to remove /bin? :) Not wise thing to do. Your scripts shouldn't try to do tricks like that.

1. You can use absolute path, but you shouldn't (in most cases) have to remove anything. Not safe thing to do.
2. If you're operating on a chroot system, run the installpkg inside the chroot (you'll need shell and basic utilites and of course pkgtools inside your chroot). Or if you are using "installpkg --root" outside of chroot use the absolute path to the chroot location.
3. Not to do things as those? :) I personally wouldn't recommend putting something like that inside the SlackBuild/doinst.sh. But if you must, see #2. ;)

bobzilla 12-30-2011 08:48 PM

Btw, I haven't used relative path in my scripts. :) So, I can't answer that part of the question. Well, I didn't try to remove /bin either. Take a look at FHS for more info about /bin and what it serves for. :)

dive 12-30-2011 09:13 PM

I'm gussing what he really wanted to do was rm -r $PKG/bin and then symlink

bobzilla 12-30-2011 09:30 PM

You're most likely right. Haven't thought about that.

cigerma 12-30-2011 11:13 PM

hi, look at this:
https://fedoraproject.org/wiki/Features/UsrMove
this is where my idea come from.

dive 12-31-2011 05:37 AM

If that does eventually happen in slackware, wait for it to happen before building packages based on it.

bobzilla 12-31-2011 06:31 AM

Maybe he's building a custom system based on Slack.

You're pretty much on your own with that. Try the relative paths if you want to reuse those packages again. Otherwise absolute path will work. Just be carefull what you do in you slackbuilds. As dive noted, always check if your SlackBuild is operating on $PKG/ not /. As doinst.sh is concerned, already answered that. ;)


All times are GMT -5. The time now is 05:59 PM.