summaryrefslogtreecommitdiffstats
path: root/debian/dpkg.postinst
blob: 6388730078a3f1d95600e8c01c8a636ae09c617c (plain)
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
#!/bin/sh
# See deb-postinst(5).

set -e

PROGNAME=dpkg

. /usr/share/dpkg/sh/dpkg-error.sh

setup_colors

get_vendor()
{
  local origin="$DPKG_ROOT/etc/dpkg/origins/default"
  local vendor

  if [ -n "$DEB_VENDOR" ]; then
    vendor="$DEB_VENDOR"
  elif [ -e "$origin" ]; then
    vendor=$(sed -ne 's/^Vendor: *\([^ ]\+\) */\1/p' "$origin" | tr A-Z a-z)
  fi

  echo "${vendor:-default}"
}

check_merged_usr_via_aliased_dirs()
{
  local vendor

  vendor=$(get_vendor)

  case "$vendor" in
  debian)
    # In Debian some people have gotten so offended by the following _warning_
    # that they have resorted to bullying and abuse. Life's too short, sorry.
    return
    ;;
  ubuntu)
    # Ubuntu does not seem interested in it.
    return
    ;;
  esac

  for d in /bin /sbin /lib /lib32 /libo32 /libx32 /lib64; do
    linkname="$(readlink $DPKG_ROOT$d || true)"
    if [ "$linkname" = "usr$d" ] || [ "$linkname" = "/usr$d" ]; then
      warning "This system uses merged-usr-via-aliased-dirs, going behind dpkg's"
      warning "back, breaking its core assumptions. This can cause silent file"
      warning "overwrites and disappearances, and its general tools misbehavior."
      warning "See <https://wiki.debian.org/Teams/Dpkg/FAQ#broken-usrmerge>."
      break
    fi
  done
}

setup_aliases()
{
  local prog=start-stop-daemon

  # Add a backward compatibility symlink alias for s-s-d, which is now
  # installed in its canonical location.
  if [ ! -f "$DPKG_ROOT/sbin/$prog" ]; then
    ln -s "/usr/sbin/$prog" "$DPKG_ROOT/sbin/$prog"
  fi
}

case "$1" in
configure)
  setup_aliases
  ;;
abort-upgrade|abort-deconfigure|abort-remove)
  ;;
*)
  error "called with unknown argument '$1'"
  ;;
esac

# Due to #932360 in debhelper we need to explicitly tell systemd to reload.
case "$1" in
configure|abort-upgrade|abort-deconfigure|abort-remove)
  if [ -d /run/systemd/system ]; then
    systemctl --system daemon-reload >/dev/null || true
  fi
  ;;
esac

#DEBHELPER#
exit 0