Bug 10146

Summary: oe_soinstall fails with confusing error if shared library does not have elf tag 'SONAME'
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Henry Bruce <henry.bruce>
Component: coreAssignee: Henry Bruce <henry.bruce>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: meta.mr.watcher, meta.watcher, ross.burton, sgw
Version: 2.1   
Target Milestone: 2.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know
Attachments:
Description Flags
log.do_package for oe_soinstall bug report none

Description Henry Bruce 2016-08-15 18:47:23 UTC
oe_soinstall is typically invoked as follows:
  oe_soinstall ${WORKDIR}/${MACHINE_ARCH}/libfoo.so.X.Y.Z ${D}${libdir} 
where X, Y and Z  are major, minor and patch versions.
It is assumed that libfoo.so.X.Y.Z contains SONAME elf tag libfoo.so.X so symbolic links can be set up automatically.
However if SONAME tag is missing symbolic link fails as target is the library directory (/usr/lib), not a library file inside it (usr/lib/libfoo.so.X.Y.Z).
See also bug 7136.

Observed behavior
------------------
User sees a confusing error message in do_install
ln: failed to create symbolic link ā€˜/usr/lib/libfoo.so.X.Y.Z’: File exists

Expected behavior
------------------
oe_soinstall should detect absence of SONAME and give bitbake error
e.g. libfoo.so.X.Y.Z musty contain elf tag SONAME with value 'libfoo.so.X'
Comment 1 Henry Bruce 2016-08-15 21:51:38 UTC
Created attachment 3357 [details]
log.do_package for oe_soinstall bug report
Comment 2 Henry Bruce 2016-08-15 21:54:42 UTC
Error message incorrectly capture. See correction below. Full log in attachment 3357 [details].

Observed behavior
------------------
User sees a confusing error message in do_package
libfoo-1.0-r0 do_package: Function failed: split_and_strip_files

Expected behavior
------------------
oe_soinstall should detect absence of SONAME and give bitbake error
e.g. libfoo.so.X.Y.Z musty contain elf tag SONAME with value 'libfoo.so.X'
Comment 3 Henry Bruce 2016-08-15 23:16:46 UTC
Here is a proposed update so oe_soinstall. My updates are the if statements. Feedback on wording is welcome. 

oe_soinstall() {
	# Purpose: Install shared library file and
	#          create the necessary links
	# Example: oe_soinstall libfoo.so.1.2.3 ${D}{libdir}
	libname=`basename $1`
	if [[ "$libname" == *.so ]]; then
		bbfatal "oe_soinstall: Shared library must append version to filename (e.g. libfoo.so.1.2.3)"
	fi
	install -m 755 $1 $2/$libname
	sonamelink=`${HOST_PREFIX}readelf -d $1 |grep 'Library soname:' |sed -e 's/.*\[\(.*\)\].*/\1/'`
	if [ -z $sonamelink ]; then
		bbfatal "oe_soinstall: $libname is missing ELF tag 'SONAME'. Cannot continue."
	fi
	solink=`echo $libname | sed -e 's/\.so\..*/.so/'`
	ln -sf $libname $2/$sonamelink
	ln -sf $libname $2/$solink
}
Comment 4 Ross Burton 2016-09-14 15:57:28 UTC
Fixed in oe-core cd5d532bd2a3f409b9470591c8d6f6b21e5995dd.