Bug#798462: libsasl2-2: recreate and use /etc/sasl2/ for new installations
David Magda
David.Magda at oicr.on.ca
Thu Apr 13 15:33:30 UTC 2017
I was reviewing some stuff and ran across this bug I filed a while ago.
I do not know if this is the best way to do this, but:
I have created a "preinst" script to try to create /etc/sasl2/ by
default, but handle situations where /usr/lib/sasl2/ already exists (and
create softlinks for compat). There is also a "postrm" script to try to
handle the various clean-up situations.
Please see attached.
Regards,
David
-------------- next part --------------
#! /bin/sh
set -e
# We want to put configuration stuff in /etc/sasl2/, but have to deal
# with legacy installations in /usr/lib/sasl2/. This script does
# a bunch of tests to try create things in /etc while supporting
# any 'legacy' installations (and docs) that use /usr.
if [ -e /usr/lib/sasl2 ]; then
# if something is there, leave it, and deal with legacy stuff
if [ -L /usr/lib/sasl2 ]; then
# If a link exists, assume it points somewhere useful
if [ -e /etc/sasl2 ]; then
# if something is there, just assume it does
# something useful and move one
exit 0
else
# Create a link for compat
ln -s /usr/lib/sasl2 /etc/sasl2 && exit 0
fi
elif [ -d /usr/lib/sasl2 ]; then
# If a dir exits, leave it alone
if [ -e /etc/sasl2 ]; then
# if something is there, just assume it does
# something useful and move one
exit 0
else
# Create a link for compat
ln -s /usr/lib/sasl2 /etc/sasl2 && exit 0
fi
else
# non-link, non-dir situation? manually have someone
# look at it
exit 10
fi
else
# nothing in /usr, so go with the new world order
if [ -e /etc/sasl2 ]; then
if [ -d /etc/sasl2 ]; then
# Create a link for legacy support
ln -s /etc/sasl2 /usr/lib/sasl2 && exit 0
elif [ -L /etc/sasl2 ]; then
# Not sure why a link would exist, but assume it
# points somewhere useful, and enable legacy support
ln -s /etc/sasl2 /usr/lib/sasl2 && exit 0
else
# non-link, non-dir situation? manually have someone
# look at it
exit 11
fi
else
# nothing in /etc, nor in /usr,
# so do things in the new way
mkdir /etc/sasl2 || exit 2
# create a link for legacy support
ln -s /etc/sasl2 /usr/lib/sasl2 && exit 0
fi
fi
# We've reached an odd situation that is not covered by the above scenarios
# so throw an error and have someone manually look at things.
exit 20
# At some point in the future (Debian 10? 11?), /usr/lib/sasl2 should
# go away, and only /etc/sasl2 should be used.
# EOF
-------------- next part --------------
#! /bin/sh
set -e
# For legacy reasons, the config files can be in two places,
# so test the various scenarios and remove the object/s
# in the appropriate way.
if [ -e /usr/lib/sasl2 ]; then
if [ -L /usr/lib/sasl2 ]; then
rm /usr/lib/sasl2 || exit 10
elif [ -d /usr/lib/sasl2]; then
# do not exit-out if it fails, as the contents may
# have been left there on purpose
rmdir /usr/lib/sasl2
else
# non-link, non-dir situation? just keep going
# instead of trying to be clever
fi
fi
if [ -e /etc/sasl2 ]; then
if [ -L /etc/sasl2 ]; then
rm /etc/sasl2 || exit 20
elif [ -d /etc/sasl2 ]; then
# do not exit-out if it fails, as the contents may
# have been left there on purpose
rmdir /etc/sasl2
else
# non-link, non-dir situation? just keep going
# instead of trying to be clever
fi
fi
exit 0
# EOF
More information about the Pkg-cyrus-sasl2-debian-devel
mailing list