Bug 9456

Summary: opkg-build does not return error when Version is missing from control file
Product: [Yocto Project Subprojects] opkg Reporter: Thomas De Schampheleire <patrickdepinguin>
Component: opkgAssignee: Alejandro del Castillo <alejandro.delcastillo>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided    
Version: unspecified   
Target Milestone: 0.3.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Thomas De Schampheleire 2016-04-13 12:59:58 UTC
The error checking in opkg-build (part of the opkg-utils repo) is not entirely correct. Excerpt from pkg_appears_sane() in opkg_build:

	pkg=`required_field Package`
	[ "$?" -ne 0 ] && PKG_ERROR=1

	version=`required_field Version | sed 's/Version://; s/^.://g;'`
	[ "$?" -ne 0 ] && PKG_ERROR=1

	arch=`required_field Architecture`
	[ "$?" -ne 0 ] && PKG_ERROR=1


For fields Package and Architecture, the error check works well, but for Version it doesn't. Even if the Version field is missing, $? will be the return value of sed, which is normally 0.

The result with a missing Version field in the control file is an error message (originating from function 'required_field') but opkg does not bail out with an error return code, meaning that the caller script is unaware of the error.

A possible change (untested) is:

	version=`required_field Version`
	[ "$?" -ne 0 ] && PKG_ERROR=1
        version=`echo $version | sed 's/Version://; s/^.://g;'`
Comment 1 Alejandro del Castillo 2016-05-10 16:09:19 UTC
fixed on commit 69aa4345f34dbd70b645d940a80fce0d5bfd8384