On Mar 15, 2011, at 5:18 PM, Ralf S. Engelschall wrote: > I got a report that RPM (here the older version 5.1.9) > does not return a failure code (!= 0) on some operations > where a failure code is strongly expected (and where > RPM 4.x still returned a failure code). > From the report: > > # openpkg rpm -i /tmp/asdf.rpm > error: open of /tmp/asdf.rpm failed: No such file or directory > # echo 0 > 0 > # touch /tmp/asdf.rpm > # openpkg rpm -i /tmp/asdf.rpm > # echo 0 > 0 > > You can just ignore here the "openpkg" run-time wrapper in > the report as the same problem occurs also when calling the > rpm(1) executable directly. > > Before I investigate and jump deeper into the sources myself, > is this a known problem (perhaps already fixed in versions > 5.1.9)? > Does anybody have a clue why RPM still returns just 0 on those > errors? Any hints welcome... >
Yes a known problem. There are code paths throughout RPM which cannot return error codes properly without breaking API/ABI or because its work-in-progress. The above 2 cases seem pretty innocent, but its not going to surprise me to see more serious problems under a rpmgi also returning 0. IIRC, there was discussion (from Mark Hatle? arekm?) abt 2 rpmgi failure cases on rpm-devel@ here like August 2007. cvs annotate lib/rpmgi.c should show the time frame. I can wire up error codes (or find details why not) for those two error cases if you wish. With -i (and -q and -K) using the rpmgi iterator, its a bit more complex than just coding up if (open(....) < 0) return errno because of the interlocked state in the rpmgi (Generalized Iterator). I can look at rpm-5.1.9 (and all later versions) tonight if you want. I need to revisit the rpmgi pretty soon anyways, because hdlists-as-used-by-mandriva aren't the same as hdlists-as-used-by-rpm and its almost time to fix (Mandriva's not rpm's) divergence. But lemme ask first: Does openpkg need/use status returned from rpm? Is it ok to switch to EXIT_FAILURE instead of (what rpm has traditionally done) return no of failing "packages" Drilling EXIT_FAILURE everywhere has been on my todo++ list for abt 2 years, just, well, its gonna be messy and tedious (but returning no. of pkgs in 8 bits started to become silly in ~2001). hth 73 de Jeff ______________________________________________________________________ RPM Package Manager http://rpm5.org Developer Communication List rpm-devel@rpm5.org