Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 293859 - app-admin/webapp-config-1.50-r3 ignores hooked script's exit status
Summary: app-admin/webapp-config-1.50-r3 ignores hooked script's exit status
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Web Application Packages Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-20 15:25 UTC by Hugo Mildenberger
Modified: 2023-01-28 20:30 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch against ebuild.py coming with version 1.50.16-r3 (test-hooked-script-return-status.patch,2.93 KB, patch)
2009-11-22 17:36 UTC, Hugo Mildenberger
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hugo Mildenberger 2009-11-20 15:25:29 UTC
webapp.ebuild provides the ability to hook a script via "webapp_hook_script", which runs later during the webapp-config phase. Many scripts of already existing vhosts aware ebuilds use something like "exit 1" do indicate an error condition. However, webapp-config merely displays the stdout and stderr output and then happily terminates, saying

"* Install completed - success".

Inspection /usr/lib/python2.6/site-packages/WebappConfig/ebuild.py shows that within subroutine "run_hook()", nobody cares to test the exit status of the spawned process:

126         if os.path.isdir(self.__hooksd):
127             for x in os.listdir(self.__hooksd):
128
129                 if (os.path.isfile(self.__hooksd + '/' + x) and
130                     os.access(self.__hooksd + '/' + x, os.X_OK)):
131
132                     OUT.debug('Running hook script', 7)
133
134                     fi, fo, fe = os.popen3(self.__hooksd + '/' + x + ' '
135                                            + type)
136                     fi.close()
137                     result_lines = fo.readlines()
138                     error_lines  = fe.readlines()
139                     fo.close()
140                     fe.close()
141
142                     if result_lines:
143                         for i in result_lines:
144                             OUT.notice(i)
145
146                     if error_lines:
147                         for i in error_lines:
148                             OUT.warn(i)
149
150         sandbox.stop()

Section 18.1.3.5 of http://docs.python.org/library/subprocess.html describes how to replace the now deprecated os.popen3 function, for example by the "Popen()" function. An object instance 'p' returned by "p=Popen()" would provide an attribute  p.returncode.
Comment 1 Hugo Mildenberger 2009-11-22 17:36:07 UTC
Created attachment 210905 [details, diff]
Patch against ebuild.py coming with version 1.50.16-r3 

This patch uses "subprocess.Popen()" instead of "os.popen3()", hence it also cures the warning concerning "os.popen3" being deprecated. Tested using Python 2.6.3, works ok.
Comment 2 Anthony Basile gentoo-dev 2013-08-03 14:44:04 UTC
Devan can you take a look at this and make a recommendation.