diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-02-16 18:05:10 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2019-02-16 18:05:10 +0000 |
commit | 2d5e6106c29d15c1c176405dd723e633c77d68b0 (patch) | |
tree | 5cdef8c44d4fe09cbf9a5a01208962529af7d2a3 | |
parent | c07539b1f8e185b1353449eb167d671488096c03 (diff) | |
download | netpbm-mirror-2d5e6106c29d15c1c176405dd723e633c77d68b0.tar.gz netpbm-mirror-2d5e6106c29d15c1c176405dd723e633c77d68b0.tar.xz netpbm-mirror-2d5e6106c29d15c1c176405dd723e633c77d68b0.zip |
Handle libnetpbm.so symlink in package and install better
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3548 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rwxr-xr-x | buildtools/installnetpbm.pl | 209 | ||||
-rw-r--r-- | common.mk | 2 | ||||
-rw-r--r-- | doc/HISTORY | 7 | ||||
-rw-r--r-- | lib/Makefile | 15 |
4 files changed, 217 insertions, 16 deletions
diff --git a/buildtools/installnetpbm.pl b/buildtools/installnetpbm.pl index e9bcd231..d29fda1a 100755 --- a/buildtools/installnetpbm.pl +++ b/buildtools/installnetpbm.pl @@ -8,6 +8,7 @@ use strict; use English; use Fcntl; use File::Basename; +use Cwd qw(getcwd); my ($TRUE, $FALSE) = (1,0); @@ -621,9 +622,194 @@ sub installSharedLib($$$) { -sub getLinkDir($) { +sub getSharedLinkDir($) { #----------------------------------------------------------------------------- -# Find out from the user where he wants the link-edit libraries installed and +# Find out from the user where he wants the shared library stubs installed +# and return that. +#----------------------------------------------------------------------------- + my ($prefix) = @_; + + print("Where do you want the shared library stub (used to link-edit\n" . + "programs to use the shared lirary) installed?\n"); + print("\n"); + + my $linkDir; + + while (!$linkDir) { + my $default = "$prefix/lib"; + + my $response = fsObjPrompt("shared library stub directory", $default); + + if (-d($response)) { + $linkDir = $response; + } else { + my $succeeded = mkdir($response, 0777); + + if (!$succeeded) { + print("Unable to create directory '$response'. " . + "Error=$ERRNO\n"); + } else { + $linkDir = $response; + } + } + } + print("\n"); + + return $linkDir; +} + + + +sub removeDotDirs($) { + + my ($readDirResultR) = @_; + + my @dirContents; + + foreach (@{$readDirResultR}) { + if ($_ ne '.' && $_ ne '..') { + push(@dirContents, $_); + } + } + + return \@dirContents; +} + + + +sub readDirContents($$$) { + my ($dirName, $contentsRR, $errorR) = @_; +#----------------------------------------------------------------------------- +# Return the contents of the directory named $dirName, excluding the +# fake . and .. entries. +#----------------------------------------------------------------------------- + my $dirContentsR; + my $error; + + my $success = opendir(DIR, $dirName); + + if (!$success) { + $error = "Unable to open directory '$dirName' with opendir()"; + } else { + my @readDirResult = readdir(DIR); + + $dirContentsR = removeDotDirs(\@readDirResult); + + closedir(DIR); + } + + $$contentsRR = $dirContentsR; + + if ($errorR) { + $$errorR = $error; + } +} + + + +sub dirContents($) { + my ($dirName) = @_; +#----------------------------------------------------------------------------- +# Return the contents of the directory named $dirName, excluding the +# fake . and .. entries. +#----------------------------------------------------------------------------- + + readDirContents($dirName, \my $contentsR, \my $error); + + if ($error) { + die($error); + } + return @{$contentsR}; +} + + + +sub fixSharedStubSymlink($$) { +#----------------------------------------------------------------------------- +# This is a hack to install a shared library link on a GNU system. +# +# On systems that use the GNU dynamic linker, the shared library stub (the +# file one uses at link-edit time to tell the linker what it needs to know +# about the shared library that the code will use at run time) is just a +# symbolic link to a copy of the actual shared library. In the Netpbm +# package, this is a relative symbolic link to the shared library in the +# package. + +# Assuming Caller just copied the contents of the 'sharedlink' directory +# straight from the package to the install target system, that symbolic link +# isn't necessarily correct, and even if it is, it's probably messy. (In the +# normal case, the link value is ../lib/libnetpbm.so.<MAJ>). + +# So what we do is just detect and patch up that case. If the stub is a +# symbolic link to something in the shared library directory of the package, +# we replace it with a symbolic link to the same thing in the shared library +# directory of the install target system. +# ----------------------------------------------------------------------------- + my ($linkDir, $shlibDir) = @_; + + my $oldCwd = getcwd(); + chdir($linkDir); + + foreach my $fsObjNm (dirContents('.')) { + if (-l("$fsObjNm")) { + if (readlink($fsObjNm) =~ m{^\.\./lib/(.*)$}) { + my $shlibNm = $1; + + unlink($fsObjNm) or + die("Failed to delete symlink copied from package " . + "in order to replace it with a proper symlink " . + "for this installation"); + + if ($linkDir eq $shlibDir) { + symlink($shlibNm, $fsObjNm) or + die("Failed to create symlink as shared library stub"); + } else { + symlink("$shlibDir/$shlibNm", $fsObjNm) or + die("Failed to create symlink as shared library stub"); + } + + print("Linked $shlibDir/$shlibNm from $linkDir/$fsObjNm"); + } + } + } + chdir($oldCwd); +} + + + +sub installSharedStub($$$$) { + + my ($pkgdir, $prefix, $shlibDir, $linkdirR) = @_; + + if (-d("$pkgdir/sharedlink")) { + my $linkDir = getSharedLinkDir($prefix); + + print("Installing shared library stubs.\n"); + + my $rc = system("$cpCommand $pkgdir/sharedlink/* $linkDir/"); + + if ($rc != 0) { + print("Copy of files from $pkgdir/sharedlink " . + "to $linkDir failed.\n"); + print("cp return code is $rc\n"); + } else { + fixSharedStubSymlink($linkDir, $shlibDir); + + print("done.\n"); + } + $$linkdirR = $linkDir; + } else { + print("You did not build a shared library, so I will not " . + "install a stub \n"); + $$linkdirR = undef; + } +} + + + +sub getStaticLinkDir($) { +#----------------------------------------------------------------------------- +# Find out from the user where he wants the static libraries installed and # return that. #----------------------------------------------------------------------------- my ($prefix) = @_; @@ -662,15 +848,16 @@ sub installStaticLib($$$) { my ($pkgdir, $prefix, $linkdirR) = @_; - if (-d("$pkgdir/link")) { - my $linkDir = getLinkDir($prefix); + if (-d("$pkgdir/staticlink")) { + my $linkDir = getStaticLinkDir($prefix); - print("Installing link libraries.\n"); + print("Installing static link libraries.\n"); - my $rc = system("$cpCommand $pkgdir/link/* $linkDir/"); + my $rc = system("$cpCommand $pkgdir/staticlink/* $linkDir/"); if ($rc != 0) { - print("Copy of files from $pkgdir/link to $linkDir failed.\n"); + print("Copy of files from $pkgdir/staticlink " . + "to $linkDir failed.\n"); print("cp return code is $rc\n"); } else { print("done.\n"); @@ -679,6 +866,7 @@ sub installStaticLib($$$) { } else { print("You did not build a static library, so I will not " . "install one \n"); + $$linkdirR = undef; } } @@ -1037,7 +1225,10 @@ print("\n"); installSharedLib($pkgdir, $prefix, \my $libdir); print("\n"); -installStaticLib($pkgdir, $prefix, \my $linkdir); +installSharedStub($pkgdir, $prefix, $libdir, \my $sharedlinkdir); +print("\n"); + +installStaticLib($pkgdir, $prefix, \my $staticlinkdir); print("\n"); installDataFile($pkgdir, $prefix, \my $datadir); @@ -1046,6 +1237,8 @@ print("\n"); installHeader($pkgdir, $prefix, \my $includedir); print("\n"); +my $linkdir = defined($sharedlinkdir) ? $sharedlinkdir : $staticlinkdir; + my $templateSubsR = {VERSION => netpbmVersion($pkgdir), BINDIR => $bindir, diff --git a/common.mk b/common.mk index 4bfdb6a1..749488c2 100644 --- a/common.mk +++ b/common.mk @@ -482,7 +482,7 @@ endif PKGMANSUBDIRS = man1 man3 man5 web -PKGSUBDIRS = bin include include/netpbm lib link misc \ +PKGSUBDIRS = bin include include/netpbm lib sharedlink staticlink misc \ $(PKGMANSUBDIRS:%=$(PKGMANDIR)/%) $(PKGSUBDIRS:%=$(PKGDIR)/%): diff --git a/doc/HISTORY b/doc/HISTORY index e1d36a6d..3be06bc7 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -48,6 +48,13 @@ not yet BJH Release 10.86.00 ppmdraw: Fix bug: 'setlinetype nodiag' says invalid type. Always broken. (Ppmdraw was new in Netpbm 10.29 (August 2005)). + Build: split link/ directory in package tree into staticlink/ + and sharedlink/ . Make 'installnetpbm' do separate prompts to + install static libraries and shared library stubs. Make + 'installnetpbm' install clean symlink in the usual case that the + shared library stub and shared library are in the same + directory. + 18.12.29 BJH Release 10.85.00 pnmpaste: Add -nand, -nor, and -nxor. diff --git a/lib/Makefile b/lib/Makefile index 65177758..bc758df4 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -221,7 +221,7 @@ libpm.o: compile.h .PHONY: install.lib ifeq ($(NETPBMLIBTYPE),unixshared) # install a Unix-style shared library -install.lib: $(PKGDIR)/lib $(PKGDIR)/link +install.lib: $(PKGDIR)/lib $(PKGDIR)/sharedlink cd $(PKGDIR)/lib ; rm -f libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).* $(INSTALL) -c -m $(INSTALL_PERM_LIBD) \ libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ).$(MIN) $(PKGDIR)/lib/ @@ -263,26 +263,27 @@ $(INTERFACE_HEADERS:%=%_installhdr): $(PKGDIR)/include/netpbm $(SRCDIR)/lib/$(@:%_installhdr=%) $(PKGDIR)/include/netpbm/ .PHONY: install.staticlib -install.staticlib: $(PKGDIR)/link +install.staticlib: $(PKGDIR)/staticlink $(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.$(STATICLIBSUFFIX) \ - $(PKGDIR)/link + $(PKGDIR)/staticlink # Install a shared library stub -- the ".so" file used at link time to # prepare a program for dynamically linking a library at run time .PHONY: install.sharedlibstub -install.sharedlibstub: $(PKGDIR)/link +install.sharedlibstub: $(PKGDIR)/sharedlink ifeq ($(NETPBMLIBTYPE),unixshared) # install the link-time (.so) links to the runtime libraries - cd $(PKGDIR)/link ; \ + cd $(PKGDIR)/sharedlink ; \ rm -f libnetpbm.$(NETPBMLIBSUFFIX); \ $(SYMLINK) ../lib/libnetpbm.$(NETPBMLIBSUFFIX).$(MAJ) \ libnetpbm.$(NETPBMLIBSUFFIX) endif ifeq ($(NETPBMLIBTYPE),dll) - $(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.dll.a $(PKGDIR)/link + $(INSTALL) -c -m $(INSTALL_PERM_LIBS) libnetpbm.dll.a \ + $(PKGDIR)/sharedlink endif ifeq ($(NETPBMLIBTYPE),dylib) - cd $(PKGDIR)/link/ ; \ + cd $(PKGDIR)/sharedlink/ ; \ rm -f libnetpbm.dylib; \ $(SYMLINK) ../lib/libnetpbm.$(MAJ).$(MIN).dylib libnetpbm.dylib endif |