Add debianisation code and automatic build script
[wmaker-crm.git] / debian / wmaker.preinst
blob41d0dd6efd53b395643f4f8cc59ba67b86f149be
1 #! /bin/sh
3 # set some variables to make the thing a bit more readable...
5 remove_diversion ()
6 {
7 real_file=$1
8 temp_file=$1.wmaker-tmp
9 diversion=$2
11 if [ -e ${real_file} ] ; then
12 mv ${real_file} ${temp_file}
13 fi
14 dpkg-divert --remove --rename --quiet --package wmaker \
15 --divert ${diversion} ${real_file}
16 if [ -e ${temp_file} ] ; then
17 mv ${temp_file} ${real_file}
18 fi
19 }
21 # asclock's location and its diversion
23 asclock=/usr/X11R6/bin/asclock
24 asclock_divert_to=/usr/X11R6/bin/asclock.afterstep
26 # asclock's manpage and its diversions
28 asclock_man=/usr/X11R6/man/man1/asclock.1x.gz
29 asclock_man_divert_to=/usr/X11R6/man/man1/asclock.afterstep.1x.gz
30 old_asclock_man_divert_to=/usr/X11R6/man/man1/asclock.1x.afterstep.gz
32 # are the diversions present?
34 asclock_diversion=$(dpkg-divert --list | grep 'asclock .*by wmaker')
35 asclock_man_diversion=$(dpkg-divert --list | grep 'asclock\.afterstep\.1x.*by wmaker')
36 old_man_diversion=$(dpkg-divert --list | grep 'asclock\.1x\.afterstep.*by wmaker')
38 # ... and set a safety net in case something goes really wrong
40 set -e
42 case "$1" in
43 upgrade|install)
44 if [ "$old_man_diversion" ] ; then
45 echo "Removing really old diversion of asclock manpage by wmaker..."
46 remove_diversion ${asclock_man} ${old_asclock_man_divert_to}
47 fi
49 if [ "$asclock_diversion" ] ; then
50 echo "Removing diversion of asclock to asclock.afterstep..."
51 remove_diversion ${asclock} ${asclock_divert_to}
52 fi
54 if [ "$asclock_man_diversion" ] ; then
55 echo "Removing diversion of asclock.1x to asclock.afterstep.1x..."
56 remove_diversion ${asclock_man} ${asclock_man_divert_to}
57 fi
59 exit 0
60 ;;
61 abort-upgrade)
62 # the postrm has failed; preinst is only called like this after
63 # a failed upgrade and the current postrm also fails. Now,
64 # in what situation does this happen? Force non-zero exit code.
65 exit 1
66 ;;
67 esac
69 #DEBHELPER#