LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Tip for scripting installs and package management (https://www.linuxquestions.org/questions/linux-from-scratch-13/tip-for-scripting-installs-and-package-management-4175558453/)

ReaperX7 11-09-2015 11:42 PM

Tip for scripting installs and package management
 
Just a little tip I learned recently that paid off after reading other distributions build scripts to start creating my own.

When and if you need to create a symlink for a package, such as using pkgtools which will be used for example here:

Create the symlink as such:

If the same directory:
Code:

( cd $tmp/path/to
  ln -s /lib/library.so library.so.1
)

If between different directories:
Code:

ln -s /lib/library.so $tmp/usr/lib/library.so
Some packagers like pkgtools, for example, take all symlinks and rework them in post install if they exist. Even if the /path/to points to a real location on the drive, don't worry, the packager will pick this up and restore the symlink as intended, and if it doesn't, you still have an active symlink waiting for the actual package, when installed.

And make sure the directory is created within the package as well, or it may have issues.

Happy building.

Keith Hedger 11-10-2015 10:23 AM

must admit could never understand why pkgtools did that, it just removes the links then restores them, seems pountless, using make install DESTDIR=/path/to/pkg which is what slackbuild scripts ( for instance ) do the links will be correct in the first place, or am I missing something?

ReaperX7 11-14-2015 04:33 AM

Pkgtools isn't perfect but it has problems due to tar. Tar will destroy a symlink outright and replace it with a real directory or a bad symlink back to the temp install. Which is why tar-1.13 is used, and why a doinst.sh script is used to restore all symlinks post installation.

I'm still working out the bugs in my build scripts though.

Keith Hedger 11-14-2015 06:11 AM

So thats why they use the doinstall script, should have realized as I had a similar problem with my package manager overwriting symlinks to folder, I had to do some jiggling with the temp package before taring it up.

ReaperX7 11-18-2015 07:16 PM

Yeah, and it's still far from perfect, but it works well enough to keep the noise levels of complaints to a minimum.

I was curious if libarchive's bsdtar was symlink friendly as packagers like pacman and pkgutils seem to want to use it.

Yeah makepkg is doing this with doinst.sh:

Collect all symlinks to a file
destroy all symlinks in package
install package
recreate symlinks post-install

It's crude but effective in keeping sanity in the tree.

kcirick 11-19-2015 09:11 AM

I'm using a "package manager" (just a tool to keep track of versions and installed files) that is basically a stripped version of Slackware's pkgtool (which is exactly what you guys are discussing), and also Arch's PKGBUILD script. I have not been very careful with symlinks, but so far I haven't had much trouble. I guess I should look into doinst.sh script to see how that's done before I get into too much trouble.


All times are GMT -5. The time now is 10:19 PM.