File: preinst

package info (click to toggle)
procps 2:3.3.12-3+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,820 kB
  • sloc: ansic: 21,793; sh: 5,038; makefile: 444; exp: 367; sed: 16
file content (72 lines) | stat: -rw-r--r-- 1,592 bytes parent folder | download | duplicates (7)
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
#!/bin/sh
# preinst script for procps
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <new-preinst> `install'
#        * <new-preinst> `install' <old-version>
#        * <new-preinst> `upgrade' <old-version>
#        * <old-preinst> `abort-upgrade' <new-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

prep_mv_conffile()
{
  PKGNAME=$1
  CONFFILE=$2

  if [ -e "$CONFFILE" ]; then
	md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
	old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
	if [ "$md5sum" = "$old_md5sum" ]; then
	  rm -f "$CONFFILE"
	fi
  fi
}

upgradeoldconffile()
{
  f=/etc/init.d/procps.sh
  [ ! -e "$f" ] && return

  curmd5=`md5sum "$f" |awk '{print $1}'`
  oldmd5=`dpkg-query -W -f='${Conffiles}' procps | sed "{\\'^ $f ' ! d; s///}"`
  [ "$curmd5" = "$oldmd5" ] && {
      # The admin has not modified $f
	  echo "Preparing to remove obsolete, unmodified conffile: $f"
	  mv -fv "$f" "$f.from-preinst"
	  return
	} >&2

	# The admim modified $f; cause a deliberate conffile prompt
	echo "Moving obsolete conffile to new pathname:"
	mv -fv "$f" "${f%.sh}"
}


case "$1" in
    install)
    ;;
	upgrade)
	  prep_mv_conffile procps "/etc/init.d/procps.sh"
    ;;
    abort-upgrade)
    ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0