The problem seems to occur only if you have script(s) in /etc/profile.d.
On the last upgrade to 9.3 Stretch, we experienced this issue. Also, see
comment by Vagnerr at
https://askubuntu.com/questions/422264/how-to-debug-dpkg-configure-error-in-subprocess-post-installation
describing this problem from May 2015.
"I had a similar issue to you. With the installer just flat failing.
Mine turned out to be an issue with installing the latest version from
debian-backports for wheezy. It turned out that they changed the post
install script to have a 'su - $OWNER -c "sa-update ...' call which did
a full login shell exec to /bin/sh which was incompatible with our
/etc/profile and /etc/profile.d files. removing the '-' making it "su
$OWNER -c ...." fixed it for me – Vagnerr May 16 '15 at 14:43"
I can confirm that removal of the file in /etc/profile.d fixed the problem.
The file in question is /var/lib/dpkg/info/sa-compile.postinst, line 10,
which reads:
su - $OWNER -c "sa-compile --quiet"
Here is the relevant portion of the transcript from our upgrade
highlighting the issue with /etc/profile.d.
Setting up spamassassin (3.4.1-6+deb9u1) ...
Installing new version of config file /etc/cron.daily/spamassassin ...
Installing new version of config file /etc/spamassassin/65_debian.cf ...
-su: 19: /etc/profile.d/lcx_all_users_aliases.sh: Syntax error: "("
unexpected
dpkg: error processing package spamassassin (--configure):
subprocess installed post-installation script returned error exit status 2
Setting up zsh (5.3.1-4+b2) ...
Setting up libicu57:amd64 (57.1-6+deb9u1) ...
Setting up iproute2 (4.9.0-1+deb9u1) ...
Setting up linux-image-4.9.0-4-amd64 (4.9.65-3) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.9.0-4-amd64
W: initramfs-tools configuration sets
RESUME=UUID=e4df7c74-843d-4e43-a7de-8c97d1469f24
W: but no matching swap device is available.
I: The initramfs will attempt to resume from /dev/vda2
I: (UUID=bf035740-4836-4088-835d-84bd43a5cd05)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.0-4-amd64
Found initrd image: /boot/initrd.img-4.9.0-4-amd64
Found linux image: /boot/vmlinuz-4.9.0-3-amd64
Found initrd image: /boot/initrd.img-4.9.0-3-amd64
done
Processing triggers for libc-bin (2.24-11+deb9u1) ...
dpkg: dependency problems prevent configuration of sa-compile:
sa-compile depends on spamassassin; however:
Package spamassassin is not configured yet.
dpkg: error processing package sa-compile (--configure):
dependency problems - leaving unconfigured
Processing triggers for systemd (232-25+deb9u1) ...
Setting up libsqlite3-0:amd64 (3.16.2-5+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up libpython2.7-minimal:amd64 (2.7.13-2+deb9u2) ...
Setting up openssh-client (1:7.4p1-10+deb9u2) ...
Setting up spamc (3.4.1-6+deb9u1) ...
Setting up libpython2.7-stdlib:amd64 (2.7.13-2+deb9u2) ...
Setting up libdbus-1-3:amd64 (1.10.24-0+deb9u1) ...
Setting up python2.7-minimal (2.7.13-2+deb9u2) ...
Setting up iproute (1:4.9.0-1+deb9u1) ...
Setting up python2.7 (2.7.13-2+deb9u2) ...
Setting up openssh-sftp-server (1:7.4p1-10+deb9u2) ...
Setting up libpython2.7:amd64 (2.7.13-2+deb9u2) ...
Setting up libpython2.7-dev:amd64 (2.7.13-2+deb9u2) ...
Setting up dbus (1.10.24-0+deb9u1) ...
A reboot is required to replace the running dbus-daemon.
Please reboot the system when convenient.
Setting up python2.7-dev (2.7.13-2+deb9u2) ...
Setting up openssh-server (1:7.4p1-10+deb9u2) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Errors were encountered while processing:
spamassassin
sa-compile
--
Terry
LinuxChix System Admins