1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
#!/bin/sh
set -e
suffix=notslocate
#DEBUG=echo
#echo "DEBUG========================"
#dpkg-divert --list slocate
#echo "============================="
# check for diversions...
divs=`dpkg-divert --list slocate`
if [ "$divs" != "" ]
then
# remove links
for i in /usr/bin/locate /usr/bin/updatedb
do
old_div=`echo $divs |grep $i || true`
# check for links
if [ -f $i -a "`readlink $i`" != "" ]
then
$DEBUG rm $i
else
# Handle special case where /usr/bin/locate is not a symlink
# to /usr/bin/slocate but a diversion exists.
# We MUST have a $i.old or $i.$suffix.
if [ -f $i.old -o -f $i.$suffix ]
then
$DEBUG rm $i
fi
fi
if [ -f $i.old ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert $i.old $i
fi
if [ -f $i.$suffix ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert $i.$suffix $i
fi
done
old_div=`echo $divs |grep usr/share/man/man1/updatedb || true`
if [ "$old_div" != "" ]
then
if [ -f /usr/share/man/man1/updatedb.1.gz ]
then
$DEBUG rm /usr/share/man/man1/updatedb.1.gz
fi
if [ -f /usr/share/man/man1/updatedb.$suffix.1.gz ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /usr/share/man/man1/updatedb.$suffix.1.gz \
/usr/share/man/man1/updatedb.1.gz
fi
if [ -f /usr/share/man/man1/updatedb.1.gz.old ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /usr/share/man/man1/updatedb.1.gz.old \
/usr/share/man/man1/updatedb.1.gz
fi
fi
old_div=`echo $divs |grep usr/man/man1/updatedb || true`
if [ "$old_div" != "" ]
then
if [ -f /usr/man/man1/updatedb.1.gz ]
then
$DEBUG rm /usr/man/man1/updatedb.1.gz
fi
#if [ -f /usr/man/man1/updatedb.1.gz.old ]
#then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /usr/man/man1/updatedb.1.gz.old \
/usr/man/man1/updatedb.1.gz
#fi
fi
old_div=`echo $divs | grep usr/man/man1/locate || true`
if [ "$old_div" != "" ]
then
if [ -f /usr/man/man1/locate.1.gz ]
then
$DEBUG rm /usr/man/man1/locate.1.gz
fi
#if [ -f /usr/man/man1/locate.1.gz.old ]
#then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /usr/man/man1/locate.1.gz.old \
/usr/man/man1/locate.1.gz
#fi
fi
old_div=`echo $divs | grep usr/share/man/man1/locate || true`
if [ "$old_div" != "" ]
then
if [ -f /usr/share/man/man1/locate.1.gz ]
then
$DEBUG rm /usr/share/man/man1/locate.1.gz
fi
if [ -f /usr/share/man/man1/locate.$suffix.1.gz ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /usr/share/man/man1/locate.$suffix.1.gz \
/usr/share/man/man1/locate.1.gz
fi
if [ -f /usr/share/man/man1/locate.1.gz.old ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /usr/share/man/man1/locate.1.gz.old \
/usr/share/man/man1/locate.1.gz
fi
fi
old_div=`echo $divs | grep /etc/cron.daily/find || true`
if [ "$old_div" != "" -a ! -f /etc/cron.daily.find.$suffix ]
then
if [ -f /etc/cron.daily/find.old ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /etc/cron.daily/find.old \
/etc/cron.daily/find
fi
if [ -f /etc/cron.daily/find.$suffix ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /etc/cron.daily/find.$suffix \
/etc/cron.daily/find
fi
if [ ! -f /etc/cron.daily/find ]
then
# no idea how this happened
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /etc/cron.daily/find.$suffix \
/etc/cron.daily/find
fi
fi
# the cron.daily/find must be divered to /etc/<something> so that
# it is no longer run by cron.
old_div=`echo $divs | grep /etc/cron.daily.find.$suffix || true`
if [ "$old_div" != "" ]
then
if [ -f /etc/cron.daily.find.$suffix ]
then
$DEBUG dpkg-divert --package slocate --remove --rename \
--divert /etc/cron.daily.find.$suffix \
/etc/cron.daily/find
fi
fi
fi
# all diverts should be toast
if [ "`dpkg-divert --list slocate`" != "" ]
then
echo "==============================================="
echo "===Error. The following diversions still exist:"
dpkg-divert --list slocate
echo "==============================================="
exit 1
fi
#if [ install = "$1" ]; then
$DEBUG dpkg-divert --package slocate --add --rename \
--divert /usr/bin/locate.$suffix \
/usr/bin/locate
$DEBUG dpkg-divert --package slocate --add --rename \
--divert /usr/bin/updatedb.$suffix \
/usr/bin/updatedb
$DEBUG dpkg-divert --package slocate --add --rename \
--divert /usr/share/man/man1/locate.$suffix.1.gz \
/usr/share/man/man1/locate.1.gz
$DEBUG dpkg-divert --package slocate --add --rename \
--divert /usr/share/man/man1/updatedb.$suffix.1.gz \
/usr/share/man/man1/updatedb.1.gz
# The cron script must be moved out of cron.daily so that it is
# no longer run.
$DEBUG dpkg-divert --package slocate --add --rename \
--divert /etc/cron.daily/find.$suffix \
/etc/cron.daily/find
#fi
#DEBHELPER#
|