You are not logged in.

#1 2004-06-15 15:38:45

vor_lord
Member
From: Fort Collins, Colorado, USA
Registered: 2004-06-10
Posts: 52

Proper way to make softlinks in a package?

I've searched everywhere I could think of, but couldn't find anything on how I should handle this.

I've made a pacman package for Bitkeeper.  I love makepkg--it makes everything so simple.

The problem I"m having is that in order to use bitkeeper, a link in /usr/bin is need to point to the bk executable (which I've chosen to install in /opt/bitkeeper).

I have it working fine for my needs by doing:

# arg 1:  the new package version
post_install() {
  cd /usr/bin
  ln -s /opt/bitkeeper/bk bk
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  /bin/true
}

# arg 1:  the old package version
pre_remove() {
  cd /usr/bin
  rm -f bk
}

# arg 1:  the old package version
post_remove() {
  /bin/true
}

This works fine, but should someone use pacman --root, this would break.

It brings up a general question--how should I handle links?  I also tried it as part of the build() function, but the real problem is the symbolic nature of links--I don't know in advance where things are going to be put.

Is there a variable I can access in the install script to indicate a root, which is a full path?

I tried using a relative link, but that didn't work for bitkeeper's needs:

[root@strongbad bitkeeper]# ll /usr/bin/b*
-rwxr-xr-x  1 root root  13056 Mar 14 23:54 /usr/bin/basename
-rwxr-xr-x  1 root root    114 Mar 20 16:18 /usr/bin/bdftops
-rwxr-xr-x  1 root root 130928 Apr 11 12:06 /usr/bin/bibtex
-rwxr-xr-x  1 root root 197460 Jan  3 12:30 /usr/bin/bison
lrwxrwxrwx  1 root root     22 Jun 15 09:11 /usr/bin/bk -> ../../opt/bitkeeper/bk
-rwxr-xr-x  1 root root  15878 Jan  4 16:52 /usr/bin/bsetbg
-rwxr-xr-x  1 root root  72640 Jan  4 16:52 /usr/bin/bsetroot
[root@strongbad bitkeeper]# bk help
Error, link "/usr/bin/bk->../../opt/bitkeeper/bk" must be a full path name

Offline

#2 2004-06-15 15:42:54

sarah31
Member
From: Middle of Canada
Registered: 2002-08-20
Posts: 2,975
Website

Re: Proper way to make softlinks in a package?

well in many instance you should not have to make any symlinks at all as you can direct where things get installed in package through configure options. put your PKGBUILD up for people to view and/or build their own package with and then they can give you feedback.

the symlinking may not be necessary.


AKA uknowme

I am not your friend

Offline

#3 2004-06-15 16:21:14

vor_lord
Member
From: Fort Collins, Colorado, USA
Registered: 2004-06-10
Posts: 52

Re: Proper way to make softlinks in a package?

sarah31 wrote:

well in many instance you should not have to make any symlinks at all as you can direct where things get installed in package through configure options. put your PKGBUILD up for people to view and/or build their own package with and then they can give you feedback.

the symlinking may not be necessary.

I realize in many cases that this is true.  However, bitkeeper is not an open source product.  You simply get an install script to run, and the only options it supports are 'upgrade' and the installation directory.

Due to the nature of bk using a noninteractive ssh shell when cloning a remote repository, the bk executable must be on the path which is a compile time option for openssh.  It isn't something that can be fixed via environment.  You'd either need to recompile openssh, or create a symlink somewhere (such as /usr/bin) that anyone would have put into the path.

Here is an example of what I mean--notice the paths are different depending on the build
of openssh.  I have an HPUX machine, a Fedora Core machine, and my arch linux machine:

vor-lord:home/brettw> ssh lathe uname -a
HP-UX lathe B.11.00 A 9000/785 2000978003 two-user license
vor-lord:home/brettw> ssh lathe 'echo $PATH'
/bin:/usr/bin:/sbin:/usr/sbin:/opt/TWWfsw/openssh292/bin

vor-lord:home/brettw> ssh vor-lord uname -a
Linux vor-lord 2.4.22-1.2188.nptl #1 Wed Apr 21 20:36:05 EDT 2004 i686 i686 i386 GNU/Linux
vor-lord:home/brettw> ssh vor-lord 'echo $PATH'
/usr/local/bin:/bin:/usr/bin

vor-lord:home/brettw> ssh $homebox uname -a
Linux strongbad 2.6.6 #1 SMP Mon May 10 00:12:20 PDT 2004 i686 unknown unknown GNU/Linux
vor-lord:home/brettw> ssh $homebox 'echo $PATH' 
/usr/bin:/bin:/usr/sbin:/sbin

There are other situations where symlinking might be useful, even if not strictly necessary.  It is a general question.

Am I to infer that there is no established way to handle such a thing as this?  If so that's fine (as you point out it is usually not needed), I just wanted to know.

This is my first package, and I wanted to get my package building habits formed properly  smile

Offline

#4 2004-06-15 17:58:32

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: Proper way to make softlinks in a package?

You can also just put a short message in the install script (post_install) describing what should be done manually by root after installation of this package.

Offline

#5 2004-06-15 20:35:35

sarah31
Member
From: Middle of Canada
Registered: 2002-08-20
Posts: 2,975
Website

Re: Proper way to make softlinks in a package?

ok your logic sounds fine to me. if you had expanded your initial question i could have been more clear. there is no firm way to set the soft links. you can with some success set them in the build or in a .install file. you could take a look at a few of the packages in abs that use soft links (i can't think of any off the top of my head but i remember maintaining or building a few in my time as a dev).  i think the flash package had a soft link in it and i  know of a few others set in the build{} as well.


AKA uknowme

I am not your friend

Offline

#6 2004-06-15 21:46:42

vor_lord
Member
From: Fort Collins, Colorado, USA
Registered: 2004-06-10
Posts: 52

Re: Proper way to make softlinks in a package?

sarah31 wrote:

ok your logic sounds fine to me. if you had expanded your initial question i could have been more clear. there is no firm way to set the soft links. you can with some success set them in the build or in a .install file. you could take a look at a few of the packages in abs that use soft links (i can't think of any off the top of my head but i remember maintaining or building a few in my time as a dev).  i think the flash package had a soft link in it and i  know of a few others set in the build{} as well.

There are a lot of soft links, but most of them are relative.  In my sync of the ABS tree, I only see the following absolute links:

strongbad:var/abs> find . -name PKGBUILD -exec grep -Hn 'ln -s /' {} ;
./extra/devel/gprolog/PKGBUILD:20:   ln -s /usr/share/gprolog/bin/fd2c
./extra/devel/gprolog/PKGBUILD:21:   ln -s /usr/share/gprolog/bin/gplc
./extra/devel/gprolog/PKGBUILD:22:   ln -s /usr/share/gprolog/bin/gprolog
./extra/devel/gprolog/PKGBUILD:23:   ln -s /usr/share/gprolog/bin/hexgplc
./extra/devel/gprolog/PKGBUILD:24:   ln -s /usr/share/gprolog/bin/ma2asm
./extra/devel/gprolog/PKGBUILD:25:   ln -s /usr/share/gprolog/bin/pl2wam
./extra/devel/gprolog/PKGBUILD:26:   ln -s /usr/share/gprolog/bin/wam2ma
./extra/devel/j2sdk/PKGBUILD:27:  ln -s /opt/j2re $startdir/pkg/opt/j2sdk/jre
./extra/lib/pwlib/PKGBUILD:22:#  ln -s /usr/bin/ptlib-config $startdir/pkg/usr/share/pwlib/make
./extra/multimedia/mplayer-plugin/PKGBUILD:26:    ln -s /opt/$pkgname/mplayerplug-in.so $i/
./extra/multimedia/mplayer-plugin/PKGBUILD:31:    ln -s /opt/$pkgname/mplayerplug-in.xpt $i/
./extra/multimedia/panorama-tools/PKGBUILD:70:  ln -s /usr/bin/PTStereo $startdir/pkg/usr/share/$pkgname/Helpers/
./extra/multimedia/panorama-tools/PKGBUILD:71:  ln -s /usr/bin/PTInterpolate $startdir/pkg/usr/share/$pkgname/Helpers/
./extra/multimedia/panorama-tools/PKGBUILD:72:  ln -s /usr/bin/PTMorpher $startdir/pkg/usr/share/$pkgname/Helpers/
./extra/multimedia/panorama-tools/PKGBUILD:73:  ln -s /usr/bin/PTOptimizer $startdir/pkg/usr/share/$pkgname/Helpers/
./extra/multimedia/panorama-tools/PKGBUILD:74:  ln -s /usr/bin/PTStripe $startdir/pkg/usr/share/$pkgname/Helpers/
./extra/multimedia/panorama-tools/PKGBUILD:75:  ln -s /usr/bin/PTAverage $startdir/pkg/usr/share/$pkgname/Helpers/
./extra/multimedia/panorama-tools/PKGBUILD:76:  ln -s /usr/bin/PTStitcher $startdir/pkg/usr/share/$pkgname/Helpers/
./extra/network/zope/PKGBUILD:28:  ln -s /usr/bin/python $startdir/pkg/opt/zope/bin/python
./extra/system/j2re/PKGBUILD:28:  ln -s /opt/j2re/plugin/i386/ns610-gcc32/libjavaplugin_oji.so $startdir/pkg/opt/mozilla-plugins
./extra/system/mgm/PKGBUILD:17:   ln -s /opt/mgm/mgm $startdir/pkg/usr/bin/mgm

There is one or two in install files (like mine) as well, but just a couple.

So they don't seem widespread, yet any one of these packages would not install correctly with pacman --root.  It's not a problem for me since I don't anticipate having to do that, but it's good to know that this is the state of things.

Thanks for clearing it all up.

Offline

#7 2004-06-15 21:51:07

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: Proper way to make softlinks in a package?

I can understand the concern about using an absolute path but think about it like this.

If you're using pacman -r it's because you eventually want to run the program from within a different root.  So having the symlink point to / isn't that bad.

Just make sure, in these cases, that you're storing the symlink inside the package instead of creating it in the post install script.  Post install scripts are icky for most of the things people try to use them for.


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

#8 2004-06-15 23:02:41

vor_lord
Member
From: Fort Collins, Colorado, USA
Registered: 2004-06-10
Posts: 52

Re: Proper way to make softlinks in a package?

Xentac wrote:

I can understand the concern about using an absolute path but think about it like this.

If you're using pacman -r it's because you eventually want to run the program from within a different root.  So having the symlink point to / isn't that bad.

Just make sure, in these cases, that you're storing the symlink inside the package instead of creating it in the post install script.  Post install scripts are icky for most of the things people try to use them for.

That's a good point!  The link would probably work for what --root is intended for.  I didn't think about it that way.... the symbolic nature ends up doing what is intended.

I'll change my package to put it in the package instead of using a post-install.

Offline

#9 2004-08-27 14:18:02

thegnu
Member
From: Brooklyn, NY
Registered: 2004-05-04
Posts: 280
Website

Re: Proper way to make softlinks in a package?

I have a similar concern.  I'm trying to make a PKGBUILD for rosegarden.  It looks for /usr/lib/libreadline.so.4, which doesn't exist because I have v.5

If I create a symlink in the post_install, libreadline.so.4 --> libreadline.so, it works, but I can't remove it in pre_remove in case someone actually has v.4 installed for whatever reason.

I suppose the longer I wait the less of an issue this becomes.


fffft!

Offline

#10 2004-08-27 18:04:59

Xentac
Forum Fellow
From: Victoria, BC
Registered: 2003-01-17
Posts: 1,797
Website

Re: Proper way to make softlinks in a package?

That link to libreadline.so.4 is only because some lib that rosegarden is linked to links to an older version of readline.  It needs to be found and rebuilt.


I have discovered that all of mans unhappiness derives from only one source, not being able to sit quietly in a room
- Blaise Pascal

Offline

Board footer

Powered by FluxBB