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
|
#!/bin/sh
# vim: ts=3 et
# $Id: fix_conffiles 251 2010-03-23 22:17:56Z robert $
set -e
[ -d debian ] || cd ..
[ -d debian ] || cd ..
[ -d debian ] || { echo "Can't find debian directory" ; exit 1; }
DESTDIR=debian/tmp
ASDIR=usr/share/afterstep
UCFDIR=$ASDIR/ucf
CONFDIR1=etc/X11/afterstep
CONFDIR2=etc/menu-methods
POSTINST=debian/afterstep.postinst.debhelper
POSTRM=debian/afterstep.postrm.debhelper
gen_dh_script() {
script=$1; shift
cfgdir=$1; shift
args=$*
cat > "$script.tmp" << EOF
# Automatically added by $0
cfgdir="$cfgdir"
ucfdir="/$UCFDIR"
cfgfiles="$args"
EOF
case "$script.tmp" in
*postinst*)
cat >> "$script.tmp" << "EOF"
if [ "$1" = "configure" ] ; then
for f in $cfgfiles; do
uf="$ucfdir/$f"
cf="$cfgdir/${f%.menu-method}"
ucf --three-way "$uf" "$cf"
ucfr afterstep "$cf"
done
fi
EOF
;;
*postrm*)
cat >> "$script.tmp" << "EOF"
if [ "$1" = "purge" ] ; then
# check is ucf is still installed (see Bug#325905)
which ucf >/dev/null && HAS_UCF=yes || HAS_UCF=no
which ucfr >/dev/null && HAS_UCFR=yes || HAS_UCFR=no
for f in $cfgfiles; do
cf="$cfgdir/${f%.menu-method}"
# we mimic dpkg as closely as possible, so we remove configuration
# files with dpkg backup extensions too:
for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist ''; do
rm -f "${cf}${ext}"
done
if [ "$HAS_UCF" = "yes" ]; then ucf --purge "$cf"; fi
if [ "$HAS_UCFR" = "yes" ]; then ucfr --purge afterstep "$cf"; fi
done
fi
EOF
esac
echo "# End automatically added section" >> "$script.tmp"
[ -e "$script" ] && cat "$script" >> "$script.tmp"
mv "$script.tmp" "$script"
}
rm -f debian/cfgfiles
mkdir -p "$DESTDIR/$UCFDIR"
for x in $DESTDIR/$ASDIR/*; do
[ ! -f "$x" ] && continue;
bx="${x##*/}"
[ "$bx" = "CREDITS" ] && continue
mv "$x" "$DESTDIR/$UCFDIR/$bx"
ln -sv "/$CONFDIR1/$bx" "$x"
echo -n "$bx " >> debian/cfgfiles
done
rm -f "$POSTINST" "$POSTRM"
gen_dh_script "$POSTINST" "/$CONFDIR1" `cat debian/cfgfiles`
gen_dh_script "$POSTRM" "/$CONFDIR1" `cat debian/cfgfiles`
install -p -m 0644 debian/afterstep.menu-method "$DESTDIR/$UCFDIR"
gen_dh_script "$POSTINST" "/$CONFDIR2" afterstep.menu-method
gen_dh_script "$POSTRM" "/$CONFDIR2" afterstep.menu-method
rm -f debian/cfgfiles
|