/usr/share/debhelper/autoscripts/displace.sh.in is in config-package-dev 5.1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # displace.sh.in: diversion helpers for maintainer scripts
#
# displace_link <prefix> <suffix>
#
# Ensures that the file <prefix><suffix> is properly diverted to
# <prefix>.divert-orig<suffix> by this package, and becomes a
# symbolic link to either <prefix>.divert<suffix> (default) or
# <prefix>.divert-orig<suffix>.
#
# undisplace_unlink <prefix> <suffix>
#
# Undoes the action of displace_link <prefix> <suffix> specified
# above.
#
# Version: 4.0
#
# Copyright © 2008–2012 Tim Abbott <tabbott@mit.edu> and Anders
# Kaseorg <andersk@mit.edu>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the “Software”), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
package=#PACKAGE#
ours=#DEB_DISPLACE_EXTENSION#
theirs=#DEB_DISPLACE_EXTENSION#-orig
displace_link_displace()
{
file=$1
ourfile=$2
theirfile=$3
if ! LC_ALL=C dpkg-divert --list "$package" | \
grep -xFq "diversion of $file to $theirfile by $package"; then
dpkg-divert --divert "$theirfile" --rename --package "$package" --add "$file"
fi
}
displace_link_symlink()
{
file=$1
ourfile=$2
theirfile=$3
if [ ! -L "$file" ] && [ ! -e "$file" ]; then
ln -s "$(basename "$ourfile")" "$file"
elif [ ! -L "$file" ] || \
[ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
"$(readlink "$file")" != "$(basename "$theirfile")" ]; then
echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
fi
}
displace_link()
{
prefix=$1
suffix=$2
file=$prefix$suffix
ourfile=$prefix$ours$suffix
theirfile=$prefix$theirs$suffix
displace_link_displace "$file" "$ourfile" "$theirfile"
displace_link_symlink "$file" "$ourfile" "$theirfile"
}
displace_hide()
{
file=$1
ourfile=""
theirfile=$2
displace_link_displace "$file" "$ourfile" "$theirfile"
}
undisplace_unlink_symlink()
{
file="$1"
ourfile="$2"
theirfile="$3"
if [ ! -L "$file" ] || \
[ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
"$(readlink "$file")" != "$(basename "$theirfile")" ]; then
echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
else
rm -f "$file"
fi
}
undisplace_unlink_displace()
{
file="$1"
if [ ! -L "$file" ] && [ ! -e "$file" ]; then
dpkg-divert --remove --rename --package "$package" "$file"
else
echo "Not removing diversion of $file by $package" >&2
fi
}
undisplace_unlink()
{
prefix=$1
suffix=$2
file=$prefix$suffix
ourfile=$prefix$ours$suffix
theirfile=$prefix$theirs$suffix
undisplace_unlink_symlink "$file" "$ourfile" "$theirfile"
undisplace_unlink_displace "$file"
}
undisplace_unhide()
{
file=$1
undisplace_unlink_displace "$file"
}
check_undisplace_unlink()
{
prefix=$1
suffix=$2
file=$prefix$suffix
ourfile=$prefix$ours$suffix
theirfile=$prefix$theirs$suffix
if LC_ALL=C dpkg-divert --list "$package" | \
grep -xFq "diversion of $file to $theirfile by $package"; then
undisplace_unlink "$prefix" "$suffix"
fi
}
check_undisplace_unhide()
{
file=$1
hiddenfile=$2
if LC_ALL=C dpkg-divert --list "$package" | \
grep -xFq "diversion of $file to $hiddenfile by $package"; then
undisplace_unhide "$file"
fi
}
# End of divert.sh.in
|