# After upgrading the library you should restart anything linked with the
# shared library. If the machine you're upgrading is a non-server or a
# non-critical server, it might be easier to just reboot the machine in
# some cases (lots of things use zlib). To check to see if a binary is
# linked with zlib's shared library, try something like 'ldd /usr/bin/ssh'
# to look for a line of output like one of these:
# libz.so.1 => /usr/lib/libz.so.1 (0x40138000)
# libz.so.1 => /lib64/libz.so.1 (0x00007fac8f68c000)
# which shows that /usr/bin/ssh was linked with the zlib shared library.
# You can also try (if you have lsof installed) 'lsof /usr/lib/libz.so'
# which will list currently running applications that have the zlib shared
# library opened.
#
# Rebuild and reinstall anything that was statically linked with zlib
# (libz.a).
# Get the source tarball
cd
test -f installed/zlib-1.3.1.tar.xz && mv installed/zlib-1.3.1.tar.xz .
test ! -f zlib-1.3.1.tar.xz && wget https://zlib.net/zlib-1.3.1.tar.xz
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "zlib-*" -exec rm -r {} \;
tar xJvf ~/zlib-1.3.1.tar.xz
cd zlib-1.3.1
test $UID = 0 && chown -R root:root .
# Because libkmod requires libz, Slackware moves the shared library file
# (libz.so.1.3) up a level to /lib or /lib64. I would imagine this is
# done in case /usr is NFS-mounted or something like that. We pass
# sharedlibdir to configure below to get the same effect. The shared
# library itself ends up in /lib*/ and the rest under /usr/lib*/ and that
# way the paths in the zlib.pc file are correct as well.
## configure the build
# 64-bit systems:
test $(uname -m) = "x86_64" &&
./configure --prefix=/usr --libdir=/usr/lib64 --sharedlibdir=/lib64
# Non-64-bit systems:
test $(uname -m) = "x86_64" || ./configure --prefix=/usr --sharedlibdir=/lib
# Build it
make
# Test the build
make test
# Become root to remove old files and install the new version
su
# If you want to see what daemon-type things are running right now that are
# using the zlib shared library, try this:
# lsof /lib*/libz.so.*
# Anything in the list is using it right now. If you see things using, for
# example: /lib64/libz.so.1.2.12 now, after you install libz.so.1.3.1 below,
# if you restart them, it may start using the newer one. If not, recompile
# and install it.
# Remove the Slackware package, if there is one. zlib is in the aaa_elflibs
# package also (just elflibs in earlier versions), so there will still be a
# shared library file left in /lib or /lib64 after this.
test -x /sbin/removepkg && /sbin/removepkg zlib
# Remove the many variations of symlinks and let 'make install' create new
# ones. BE CAREFUL, make sure you really can do this with no issues.
# The safe option is, DON'T DO THIS.
test -d /lib64 && ( cd /lib64 ; rm -f libz.so.1 libz.so )
test -d /usr/lib64 && ( cd /usr/lib64 ; rm -f libz.so.1 libz.so )
test -d /lib && ( cd /lib ; rm -f libz.so.1 libz.so )
test -d /usr/lib && ( cd /usr/lib ; rm -f libz.so.1 libz.so )
# Install the new version. It will install static (.a) and shared (.so)
# versions of libz. The default base man directory is /usr/share/man,
# which in Slackware is usually either not there or a symlink to /usr/man.
make install mandir=/usr/man
# Now create symlinks in /usr/lib*/ pointing to the real one in /lib*/:
test -f /lib64/libz.so.1.3.1 &&
( ln -sf /lib64/libz.so.1.3.1 /usr/lib64/libz.so.1.3.1
ln -sf /lib64/libz.so.1.3.1 /usr/lib64/libz.so.1
ln -sf /lib64/libz.so.1.3.1 /usr/lib64/libz.so )
test -f /lib/libz.so.1.3.1 &&
( ln -sf /lib/libz.so.1.3.1 /usr/lib/libz.so.1.3.1
ln -sf /lib/libz.so.1.3.1 /usr/lib/libz.so.1
ln -sf /lib/libz.so.1.3.1 /usr/lib/libz.so )
# Update /etc/ld.so.cache
ldconfig
# Remove old docs, then put new ones in /usr/doc/zlib-1.3.1
find /usr/doc -maxdepth 1 -type d -name "zlib-*" -exec rm -r {} \;
mkdir -p /usr/doc/zlib-1.3.1
cp ChangeLog FAQ INDEX README /usr/doc/zlib-1.3.1/
chown -R root:root /usr/doc/zlib-1.3.1
# Now that you've installed the new version, you'll find that if you restart
# the things that showed up in the 'lsof' list above, they will start
# using the new version's shared library: /lib/libz.so.1.3.1
# (or /lib64/libz.so.1.3.1, or a symlink pointing to one of them)
# Once you are 100% sure that nothing is using the old version shared
# library file any more, you can remove it, but a tidy system is the only
# reason to bother doing that.
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become your non-root user again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/zlib-*.tar.* installed/zlib-*patch*.txt
mv zlib-1.3.1.tar.xz installed/