postinst is in apt-cacher-ng 0.7.2-1ubuntu1.
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 | #!/bin/sh -e
. /usr/share/debconf/confmodule
NAME=apt-cacher-ng
CDIR=/var/cache/$NAME
LDIR=/var/log/$NAME 
SLIST=/etc/apt/sources.list
CFG=/etc/apt-cacher-ng
DDIR=/usr/lib/apt-cacher-ng
VDIR=/var/lib/apt-cacher-ng
gen_mirror_list() {
   tmpfile="$1.dpkg-new"
   case "$2" in
      *gz)
      pickcmd=zgrep
      ;;
      *)
      pickcmd=grep
      ;;
   esac;
   (
   grep -h '^deb'  $SLIST.d/* $SLIST 2>/dev/null | sed -e "s,ftp:/,http:/," | \
   (
   while read a b c ; do
      case "$b" in http*) $pickcmd "$b" "$2" || true ;; esac
   done
   ) # but don't add duplicates
   ) | ( while read a ; do grep -q "$a" "$tmpfile" 2>/dev/null || echo "$a" >> "$tmpfile" ; done)
   # replace only if it got contents
   if test -s "$tmpfile" ; then
      cat "$tmpfile" > "$1"
   fi
   rm -f "$tmpfile"
}
sig='#09f369bf9c82a2210934e82213360226'
def_file_header="# This is a configuration file. All lines starting with # will be ignored.
#
# WARNING: this file is maintained by configuration scripts of the apt-cacher-ng
# package. All manual changes WILL BE LOST after the next package upgrade as
# long as a line looking exactly like $sig
# is found inside. Remove or modify that line to stop auto-updates of this file.
$sig
"
# .default files specify a set of fallback configuration for the cases where
# it's not possible to construct something useful in the regular backends files
set_def_files() {
   # ftp.debian.org is a geodns location, should be good as-is
   if ! test -r $VDIR/backends_debian.default ; then
      echo "$def_file_header" > $VDIR/backends_debian.default
      # Debian mirrors are using geodns
      echo http://ftp.debian.org/debian/ >> $VDIR/backends_debian.default
   fi
   if ! test -r $VDIR/backends_ubuntu.default ; then
      echo "$def_file_header" > $VDIR/backends_ubuntu.default
      echo http://archive.ubuntu.com/ubuntu/ >> $VDIR/backends_ubuntu.default
   fi
   # try to find a more suitable fallback mirror
   if ! test -s $CFG/backends_ubuntu ; then
      pick_ubuntu_mirrors $VDIR/backends_ubuntu.default
   fi
   # silent fix of the broken file generated by the first versions of the mirror picking code
   if grep -q "^$sig$" $VDIR/backends_ubuntu.default && grep -q "^http://archive.ubuntu.com/?$" $VDIR/backends_ubuntu.default ; then
      sed "s,http://archive.ubuntu.com,http://archive.ubuntu.com/ubuntu," -i $VDIR/backends_ubuntu.default
   fi
}
pick_ubuntu_mirrors() {
   headlen=$(grep -n "^$sig$" "$1" 2>/dev/null | cut -f2 -d: | tail -n1)
   if ! test "$headlen" ; then
      return # not for us, changed or removed by user
   fi
   
   tmpfile="`mktemp`"
   # may hit a local mirror
   sed -e 's,\([a-z]\)/.*,\1,' < $CFG/backends_debian | xargs -n1 -i grep "{}" $DDIR/ubuntu_mirrors > $tmpfile || true
   if ! test -s $tmpfile ; then # ok, go by Debian TLD
      grep debian.org/ /etc/apt-cacher-ng/backends_debian | \
         sed -e 's,^http://ftp[2-3]\?\.\([a-z][a-z]\).*,http://\1.archive.ubuntu.com/,' | \
         sort -u | xargs -n1 -i grep "{}" $DDIR/ubuntu_mirrors > $tmpfile || true
   fi
   if ! test -s $tmpfile ; then # ok, just any TLD
      sed -e 's,^http://\([^\/]\+\).*,\1,;s,.*\.\(.*\),http://\1.archive.ubuntu.com/,' < $CFG/backends_debian | \
         sort -u | xargs -n1 -i grep "{}" $DDIR/ubuntu_mirrors > $tmpfile || true
   fi
   if ! test -s $tmpfile ; then
      echo http://archive.ubuntu.com/ubuntu/ > $tmpfile || true
   fi
   if test -s $tmpfile ; then
      echo "$def_file_header" > $1
      cat $tmpfile >> $1
      # echo $- | grep x && cat $tmpfile || :
   fi
   rm -f "$tmpfile" 2>/dev/null
}
gen_lists() {
   gen_mirror_list $CFG/backends_debian $DDIR/deb_mirrors.gz
   gen_mirror_list $CFG/backends_ubuntu $DDIR/ubuntu_mirrors
   gen_mirror_list $CFG/backends_debvol $DDIR/debvol_mirrors.gz
}
if [ "$1" = "configure" ]; then
   adduser --quiet --system --group --no-create-home --home $CDIR $NAME
   for x in $CDIR $LDIR ; do 
      if [ ! -d "$x" ]; then
         install -d -g $NAME -o $NAME -m2755 "$x"
      fi
   done
   db_get apt-cacher-ng/gentargetmode || true
   case "$RET" in
      "Create once"|"Set up once")
      gen_lists
      db_set apt-cacher-ng/gentargetmode "No automated setup"
      db_go
      ;;
      "Create now and update later"|"Set up now and update later")
      gen_lists
      ;;
      "No automated setup")
      ;;
   esac
   db_stop || true
   rm -f $CFG/in.acng $CFG/mount.acng
   if [ -z "$(dpkg-statoverride --list $CFG/security.conf)" ] ; then
      dpkg-statoverride --update --add apt-cacher-ng apt-cacher-ng 600 $CFG/security.conf
   fi
   set_def_files
fi
# Automatically added by dh_installinit
if [ -x "/etc/init.d/apt-cacher-ng" ]; then
	if [ ! -e "/etc/init/apt-cacher-ng.conf" ]; then
		update-rc.d apt-cacher-ng defaults 18 >/dev/null
	fi
	invoke-rc.d apt-cacher-ng start || exit $?
fi
# End automatically added section
 |