Debian Codegraph @

debian/laptop-mode-tools.preinst

raw
1 #!/bin/sh
2 # preinst script for laptop-mode-tools
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # Remove a no-longer used conffile
9 rm_conffile() {
10 local PKGNAME="$1"
11 local CONFFILE="$2"
12
13 [ -e "$CONFFILE" ] || return 0
14
15 local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')"
16 local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | \
17 sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
18 if [ "$md5sum" != "$old_md5sum" ]; then
19 echo "Obsolete conffile $CONFFILE has been modified by you."
20 echo "Saving as $CONFFILE.dpkg-bak ..."
21 mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
22 else
23 echo "Removing obsolete conffile $CONFFILE ..."
24 rm -f "$CONFFILE"
25 fi
26 }
27
28 case "$1" in
29 install|upgrade)
30 # ideally this clean-up should have been done at the same time
31 # as we stopped shipping the file, but since we had releases in
32 # between we will compare with the version shipping this clean-up
33 # instead of the first version not shipping the file
34 if dpkg --compare-versions "$2" lt "1.51-2"; then
35 rm_conffile laptop-mode-tools "/etc/pm/sleep.d/99laptop-mode"
36 fi
37 esac
38
39 #DEBHELPER#
40
41 exit 0