+ # Make the template database read-only, so that passthrough debconf
+ # instances can write to it directly; otherwise templates are only
+ # passed through when necessary. Use temporary config databases as
+ # well; we'll copy their contents back at the end.
+ DEBCONF_TMPDIR="$(chroot /root mktemp -dt debconf.XXXXXX)"
+ cp -a /root/var/cache/debconf/config.dat "/root$DEBCONF_TMPDIR/"
+ cp -a /root/var/cache/debconf/passwords.dat "/root$DEBCONF_TMPDIR/"
+ sed "s,^Filename: /var/cache/debconf/\(config\|passwords\).dat$,Filename: $DEBCONF_TMPDIR/\1.dat,; /^Name: templatedb/a\
++Readonly: true" /root/etc/debconf.conf >"/root$DEBCONF_TMPDIR/debconf.conf"