Bug 195153

Summary: arm host, chroot qemu xubuntu guest apt-get install libc6 libc-bin fails by ldconfig error
Product: Virtualization Reporter: Dieter Drewanz (dieterd2005)
Component: XenAssignee: virtualization_xen
Status: RESOLVED DOCUMENTED    
Severity: blocking    
Priority: P1    
Hardware: ARM   
OS: Linux   
Kernel Version: Linux cubietruck 4.9.12-sunxi #4 SMP Thu Feb 23 19:46:51 CET 2017 armv7l GNU/Linux Subsystem:
Regression: No Bisected commit-id:

Description Dieter Drewanz 2017-03-28 20:39:39 UTC
This bug does not occur till xubuntu 14.04 i386. This bug exists for versions 16.04 i386 and higher, Linux Kernel 4.8 and higher. In chroot environment ldconfig fails. Then you cannot install any package with apt-get or dpkg. 
Verified for linux mate 18.1 too. 


apt-get update
apt-get upgrade
.....
Setting up libc6:i386 (2.23-0ubuntu5) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
/sbin/ldconfig.real: 1: /sbin/ldconfig.real: Syntax error: "(" unexpected
/sbin/ldconfig.real: 1: /sbin/ldconfig.real: Syntax error: "(" unexpected
dpkg: error processing package libc-bin (--configure):
 subprocess installed post-installation script returned error exit status 2
Processing triggers for man-db (2.7.5-1) ...
Errors were encountered while processing:
 libc-bin
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@cubietruck:/# 

After this you cannot install any package on chroot guest system. 

While trying to fix trouble, there was a punch through to host, which I posted here:
http://pastebin.com/CmMdFrGr
It's possible that xen is affected too, because of similarities to qemu. 

qemu-i386 --version
qemu-i386 version 2.7.1, Copyright (c) 2003-2016 Fabrice Bellard and the QEMU Project developers

Output of guest:
cubietruck / # ldconfig
/sbin/ldconfig.real: 1: /sbin/ldconfig.real: Syntax error: "(" unexpected
cubietruck / # ldconfig.real
bash: /sbin/ldconfig.real: cannot execute binary file: Exec format error
Comment 1 Dieter Drewanz 2017-04-01 08:13:53 UTC
	Possible solution for this trouble:

root@cubietruck:/# cat /sbin/ldconfig
#!/bin/sh

if  test $# = 0							\
    && test x"$LDCONFIG_NOTRIGGER" = x				\
 && test x"$DPKG_MAINTSCRIPT_PACKAGE" != x			\
 && dpkg-trigger --check-supported 2>/dev/null
then
	if dpkg-trigger --no-await ldconfig; then
		if test x"$LDCONFIG_TRIGGER_DEBUG" != x; then
			echo "ldconfig: wrapper deferring update (trigger activated)"
		fi
		exit 0
	fi	
fi

exec /sbin/ldconfig.real "$@"
root@cubietruck:/# 


Change last line from 
exec /sbin/ldconfig.real "$@"
to
exec /usr/bin/qemu-i386-static  /sbin/ldconfig.real "$@"
as fast solution till bug is really solved. 

This temporarely work around is working for this bug. 

Seems to be similar bugs:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854892
https://github.com/meefik/linuxdeploy/issues/359
Comment 2 Dieter Drewanz 2017-04-02 09:00:14 UTC
In chroot i386 I did apt-get update and apt-get upgrade with change in ldconfig as proposed: 

exec /usr/bin/qemu-i386-static  /sbin/ldconfig.real "$@"

These 300-400MB updates (xubuntu 16.04.1 and 16.04.2) took about 8-10 hours in emulation mode on arm-architecture cubietruck. 
Some libc6/libc-bin on host are affected too, now 2.19-18+deb8u4 for arm and i386. 

The arm host apt-get update and apt-get upgrade was also done. 
Then rebooting cubietruck. 

After this the bug is solved.  

Resumee:
When in chroot this happens:
/sbin/ldconfig.real: 1: /sbin/ldconfig.real: Syntax error: "(" unexpected

You can solve this hen egg problem by editing ldconfig last line 
exec /usr/bin/qemu-i386-static  /sbin/ldconfig.real "$@"

After this you can change ldconfig back to
exec /sbin/ldconfig.real "$@"

You have to restart all (host and guest) and then all will be ok. 

For chroot like here please use for Versions 16.04 or higher of any distribution version not older than April 2017 to run not in same trouble!