libpam systemd - installation error ubuntu 14.04 unable to install updates

yesterday i was trying to build a custom iso of trusty i386. during the first attempt, towards the end (after i decided to mark all upgrades and install them) the error message appeared-after repeated attempts to fix the broken packages and -f options to remove and install the package i had to give up the project. here is the message from the terminal

# sudo dpkg --configure -a
Setting up linux-image-3.13.0-27-generic (3.13.0-27.50) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
initrd.img(/boot/initrd.img-3.13.0-27-generic
) points to /boot/initrd.img-3.13.0-27-generic
 (/boot/initrd.img-3.13.0-27-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-3.13.0-27-generic.postinst line 491.
vmlinuz(/boot/vmlinuz-3.13.0-27-generic
) points to /boot/vmlinuz-3.13.0-27-generic
 (/boot/vmlinuz-3.13.0-27-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-3.13.0-27-generic.postinst line 491.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.13.0-27-generic /boot/vmlinuz-3.13.0-27-generic
run-parts: executing /etc/kernel/postinst.d/dkms 3.13.0-27-generic /boot/vmlinuz-3.13.0-27-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.13.0-27-generic /boot/vmlinuz-3.13.0-27-generic
update-initramfs: Generating /boot/initrd.img-3.13.0-27-generic
run-parts: executing /etc/kernel/postinst.d/pm-utils 3.13.0-27-generic /boot/vmlinuz-3.13.0-27-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 3.13.0-27-generic /boot/vmlinuz-3.13.0-27-generic
run-parts: executing /etc/kernel/postinst.d/zz-extlinux 3.13.0-27-generic /boot/vmlinuz-3.13.0-27-generic
P: Checking for EXTLINUX directory... found.
P: Writing config for /boot/vmlinuz-3.13.0-27-generic...
P: Installing debian theme... done.
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.13.0-27-generic /boot/vmlinuz-3.13.0-27-generic
/etc/kernel/postinst.d/zz-update-grub: 22: /etc/kernel/postinst.d/zz-update-grub: Syntax error: "fi" unexpected
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 2
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.13.0-27-generic.postinst line 1025.
dpkg: error processing package linux-image-3.13.0-27-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of libpam-systemd:i386:
 libpam-systemd:i386 depends on systemd-services (= 204-5ubuntu20); however:
  Version of systemd-services on system is 204-5ubuntu20.2.

dpkg: error processing package libpam-systemd:i386 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.13.0-27-generic; however:
  Package linux-image-3.13.0-27-generic is not configured yet.

dpkg: error processing package linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.13.0.27.33); however:
  Package linux-image-generic is not configured yet.

dpkg: error processing package linux-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-extra-3.13.0-27-generic:
 linux-image-extra-3.13.0-27-generic depends on linux-image-3.13.0-27-generic; however:
  Package linux-image-3.13.0-27-generic is not configured yet.

dpkg: error processing package linux-image-extra-3.13.0-27-generic (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-3.13.0-27-generic
 libpam-systemd:i386
 linux-image-generic
 linux-generic
 linux-image-extra-3.13.0-27-generic

please help me...


I've just encountered this problem when trying to make my own custom Ubuntu 14.04 distribution in a fakechroot, and I came up with a solution which seems to work. In the (admittedly dated) Ubuntu Live CD Customization guide, there is a bug involving initctl mentioned. I used the same approach to prevent invoke-rc.d from running, which the configuration of libpam-systemd uses. invoke-rc.d is a utility for starting and stopping initd scripts, which don't need to be running in the chroot:

dpkg-divert --rename --add /usr/sbin/invoke-rc.d
ln -s /bin/true /usr/sbin/invoke-rc.d
#Run apt-get, dpkg etc...
rm /usr/sbin/invoke-rc.d
dpkg-divert --rename --remove /usr/sbin/invoke-rc.d

With the diversion in place, invoke-rc.d always returns success and doesn't do anything, which is exactly the desired behaviour inside a chroot.


is a well known bug: (see Bug #1325142 on Launchpad); I met this problem too while I was building my own Live in chroot and I solved it (if "solved" can be the right word ... let's create a new word, say "workarounded") this way:

in chroot, after having finished installing everything, I've stated not to update libpam-systemd:

echo "libpam-systemd  hold"|dpkg --set-selections

then I've dist-upgraded my distro without (obviously) getting any error and finally I've built my live DVD.

To test if my workaround was good, I've installed trusty on a VM from that iso, logged in and from shell I've revoked the directive on iso about not to upgrade libpam-systemd:

sudo -i
echo "libpam-systemd install"|dpkg --set-selecions

and finally I've dist-upgraded again the brand new system: no errors.

I think it's a problem happening just in chroot environment.

Cheers,

Silvia