This file is indexed.

postinst is in udev 175-7.2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/bin/sh -e

supported_kernel() {
  case "$(uname -r)" in
    2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
    2.6.[12][0-9]|2.6.[12][0-9][!0-9]*) return 1 ;;
    2.6.3[0-1]|2.6.3[0-1][!0-9]*) return 1 ;;
  esac
  return 0
}

tempdir() {
  local dir=$(tempfile --prefix=udev.)
  rm $dir
  mkdir $dir
  echo $dir
}

chrooted() {
  if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ];
  then
    # the devicenumber/inode pair of / is the same as that of /sbin/init's
    # root, so we're *not* in a chroot and hence return false.
    return 1
  fi
  echo "A chroot environment has been detected, udev not started."
  return 0
}

in_debootstrap() {
  # debootstrap --second-stage may be run in an emulator instead of a chroot,
  # we need to check for this special case because start-stop-daemon would
  # not be available. (#520742)
  if [ -d /debootstrap/ ]; then
    echo "Being installed by debootstrap, udev not started."
    return 0
  fi
  return 1
} 

can_start_udevd() {
  if ! supported_kernel; then
    echo "udev requires a kernel >= 2.6.32, not started."
    return 1
  fi

  if [ ! -d /sys/class/ ]; then
    echo "udev requires a mounted sysfs, not started."
    return 1
  fi

  if [ ! -e /sys/kernel/uevent_helper ]; then
    echo "udev requires hotplug support, not started."
    return 1
  fi

  if ! ps --no-headers --format args ax | egrep -q '^\['; then
    echo "udev does not support containers, not started."
    return 1
  fi

  if ! grep -q '[[:space:]]tmpfs$' /proc/filesystems; then
    echo "udev requires tmpfs support, not started."
    return 1
  fi

  if [ -e /etc/udev/disabled ]; then
    echo "/etc/udev/disabled has been detected, udev not started."
    return 1
  fi

  return 0
}

enable_udev() {
  can_start_udevd || return 0

  echo > /sys/kernel/uevent_helper

  # create the directory which will hold our new /dev
  TEMPDEV=$(tempdir)

  export UDEV_ROOT=$TEMPDEV
  invoke-rc.d udev restart

  if ! mount -n -o size=10M,mode=0755 -t tmpfs tmpfs $TEMPDEV; then
    echo "Not enabling udev because the system lacks tmpfs support!"
    rm -f $TEMPDEV/.udev/uevent_seqnum
    rmdir $TEMPDEV/.udev/ 2> /dev/null || true
    return
  fi

  echo "Populating the new /dev filesystem temporarily mounted on $TEMPDEV/..."
  /lib/udev/create_static_nodes $TEMPDEV
  udevadm trigger --action=add

  # wait for the udevd children to finish
  udevadm settle || true

  for dir in pts shm; do
    [ -d /dev/$dir ] || continue
    mkdir -p $TEMPDEV/$dir
    if mountpoint -q /dev/$dir; then
      mount -n --move /dev/$dir $TEMPDEV/$dir
    fi
  done

  mount -n --move $TEMPDEV /dev

  # start the final daemon with the normal configuration
  unset UDEV_ROOT
  invoke-rc.d udev restart

  # XXX Some people reported that the directory was not empty.
  # This should fix the issue (udevd reopens the file for each event):
  rm -f $TEMPDEV/.udev/uevent_seqnum
  rmdir $TEMPDEV/.udev/ 2> /dev/null || true

  if ! rmdir $TEMPDEV; then
    echo "WARNING: $TEMPDEV is not empty!"
    ls -laR $TEMPDEV
  fi

  # restart some daemons because their /dev sockets have been hidden by
  # the tmpfs
  kill -s HUP 1
  local sysloginits="inetutils-syslogd rsyslog socklog-run sysklogd syslog-ng"
  for script in $sysloginits; do
    [ -x /etc/init.d/$script ] && invoke-rc.d $script restart || true
  done
}

update_initramfs() {
  [ -x /usr/sbin/update-initramfs -a -e /etc/initramfs-tools/initramfs.conf ] \
    || return 0
  update-initramfs -u
}

write_interfaces_rules() {
  local devpath
  for devpath in /sys/class/net/*; do
    [ -d "$devpath" ] || continue
    udevadm test --action=add $devpath > /dev/null || true
  done
}

fix_persistent_net_rules() {
  if [ -e /etc/udev/rules.d/70-persistent-net.rules ]; then
    sed -i -e 's/\bATTRS{/ATTR{/g' /etc/udev/rules.d/70-persistent-net.rules
  fi
}

upgrade_fixes() {
  if dpkg --compare-versions "$2" lt "171-3"; then

  # in 171-2 this directory becomes a symlink to libudev0, so it must be
  # manually deleted because dpkg cannot automatically deal with this  
  if [ -e /usr/share/doc/udev -a ! -L /usr/share/doc/udev ]; then
    rm -rf /usr/share/doc/udev
    ln -s libudev0 /usr/share/doc/udev
  fi
  
  if dpkg --compare-versions "$2" lt "140-2"; then
    fix_persistent_net_rules
  fi

  fi

  # 167-1 introduced /run/udev/ but does not move the old database on
  # upgrades when it decides to switch to /run/.
  if ! chrooted && [ -d /dev/.udev/ -a ! -d /run/udev/ ] \
      && grep -E -q "^[^[:space:]]+ /run tmpfs " /proc/mounts; then
    mv /dev/.udev/ /run/udev/
  fi
}

case "$1" in
    configure)
    if [ -z "$2" ]; then # first install
      if ! chrooted && ! in_debootstrap; then
	write_interfaces_rules
	enable_udev
      fi
    else # upgrades
      upgrade_fixes "$@"
      if ! chrooted; then
	if [ -e /etc/udev/kernel-upgrade ]; then
	  echo "Kernel upgrade mode, udevd has not been restarted."
	  echo "Please reboot the system as soon as possible."
	  rm /etc/udev/kernel-upgrade
	elif can_start_udevd; then
	  rm -f /run/systemd/system/udev.service
	  invoke-rc.d udev restart
	fi
      fi
    fi

    update_initramfs
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    interfaces)
    write_interfaces_rules
    ;;

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

# Automatically added by dh_installinit
if [ -x "/etc/init.d/udev" ]; then
	update-rc.d udev start 03 S . >/dev/null || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/udev-mtab" ]; then
	update-rc.d udev-mtab start 36 S . >/dev/null || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/udev-finish" ]; then
	update-rc.d udev-finish start 37 S . >/dev/null || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/udevtrigger" ]; then
	update-rc.d udevtrigger defaults >/dev/null || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/udevmonitor" ]; then
	update-rc.d udevmonitor defaults >/dev/null || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/udev-fallback-graphics" ]; then
	update-rc.d udev-fallback-graphics defaults >/dev/null || exit $?
fi
# End automatically added section