Bug 9456 - opkg-build does not return error when Version is missing from control file
Summary: opkg-build does not return error when Version is missing from control file
Status: RESOLVED FIXED
Alias: None
Product: opkg
Classification: Yocto Project Subprojects
Component: opkg (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Undecided normal
Target Milestone: 0.3.2
Assignee: Alejandro del Castillo
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-04-13 12:59 UTC by Thomas De Schampheleire
Modified: 2016-05-10 16:09 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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