Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 223213 Details for
Bug 286191
app-eselect/eselect-python: python-wrapper sometimes breaks init scripts using start-stop-daemon with Python scripts
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for python.eclass
python.eclass.patch (text/plain), 4.23 KB, created by
Arfrever Frehtes Taifersar Arahesis (RETIRED)
on 2010-03-11 20:33:29 UTC
(
hide
)
Description:
Patch for python.eclass
Filename:
MIME Type:
Creator:
Arfrever Frehtes Taifersar Arahesis (RETIRED)
Created:
2010-03-11 20:33:29 UTC
Size:
4.23 KB
patch
obsolete
>--- python.eclass >+++ python.eclass >@@ -774,6 +774,8 @@ > import sys > > EPYTHON_re = re.compile(r"^python(\d+\.\d+)$") >+python_shebang_re = re.compile(r"^#!.*python") >+python_verification_output_re = re.compile("^GENTOO_PYTHON_TARGET_SCRIPT_PATH supported\n$") > > EOF > if [[ "$?" != "0" ]]; then >@@ -798,16 +800,16 @@ > sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") > sys.exit(1) > >- eselect_output = eselect_process.stdout.read() >- if not isinstance(eselect_output, str): >+ EPYTHON = eselect_process.stdout.read().rstrip("\n") >+ if not isinstance(EPYTHON, str): > # Python 3 >- eselect_output = eselect_output.decode() >+ EPYTHON = EPYTHON.decode() > >- EPYTHON_matched = EPYTHON_re.match(eselect_output) >+ EPYTHON_matched = EPYTHON_re.match(EPYTHON) > if EPYTHON_matched: > PYTHON_ABI = EPYTHON_matched.group(1) > else: >- sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output) >+ sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON) > sys.exit(1) > EOF > if [[ "$?" != "0" ]]; then >@@ -823,16 +825,16 @@ > sys.stderr.write("Execution of 'eselect python show${eselect_python_option:+ }${eselect_python_option}' failed\n") > sys.exit(1) > >-eselect_output = eselect_process.stdout.read() >-if not isinstance(eselect_output, str): >+EPYTHON = eselect_process.stdout.read().rstrip("\n") >+if not isinstance(EPYTHON, str): > # Python 3 >- eselect_output = eselect_output.decode() >+ EPYTHON = EPYTHON.decode() > >-EPYTHON_matched = EPYTHON_re.match(eselect_output) >+EPYTHON_matched = EPYTHON_re.match(EPYTHON) > if EPYTHON_matched: > PYTHON_ABI = EPYTHON_matched.group(1) > else: >- sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % eselect_output) >+ sys.stderr.write("'eselect python show${eselect_python_option:+ }${eselect_python_option}' printed unrecognized value '%s" % EPYTHON) > sys.exit(1) > EOF > if [[ "$?" != "0" ]]; then >@@ -841,13 +843,47 @@ > fi > cat << EOF >> "${file}" > >-os.environ["PYTHON_SCRIPT_NAME"] = sys.argv[0] >-target_executable = "%s-%s" % (os.path.realpath(sys.argv[0]), PYTHON_ABI) >-if not os.path.exists(target_executable): >- sys.stderr.write("'%s' does not exist\n" % target_executable) >+wrapper_script_path = os.path.realpath(sys.argv[0]) >+target_executable_path = "%s-%s" % (wrapper_script_path, PYTHON_ABI) >+os.environ["GENTOO_PYTHON_WRAPPER_SCRIPT_PATH"] = sys.argv[0] >+os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH"] = target_executable_path >+if not os.path.exists(target_executable_path): >+ sys.stderr.write("'%s' does not exist\n" % target_executable_path) > sys.exit(1) > >-os.execv(target_executable, sys.argv) >+target_executable = open(target_executable_path, "rb") >+target_executable_first_line = target_executable.readline() >+if not isinstance(target_executable_first_line, str): >+ # Python 3 >+ target_executable_first_line = target_executable_first_line.decode("utf_8", "replace") >+ >+python_shebang_matched = python_shebang_re.match(target_executable_first_line) >+target_executable.close() >+ >+if python_shebang_matched: >+ try: >+ python_interpreter_path = "${EPREFIX}/usr/bin/%s" % EPYTHON >+ os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] = "1" >+ python_verification_process = subprocess.Popen([python_interpreter_path, "-c", "pass"], stdout=subprocess.PIPE) >+ del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] >+ if python_verification_process.wait() != 0: >+ raise ValueError >+ >+ python_verification_output = python_verification_process.stdout.read() >+ if not isinstance(python_verification_output, str): >+ # Python 3 >+ python_verification_output = python_verification_output.decode() >+ >+ if not python_verification_output_re.match(python_verification_output): >+ raise ValueError >+ >+ os.execv(python_interpreter_path, [python_interpreter_path] + sys.argv) >+ except: >+ pass >+ if "GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION" in os.environ: >+ del os.environ["GENTOO_PYTHON_TARGET_SCRIPT_PATH_VERIFICATION"] >+ >+os.execv(target_executable_path, sys.argv) > EOF > if [[ "$?" != "0" ]]; then > die "${FUNCNAME}(): Generation of '$1' failed"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 286191
:
205104
|
213083
|
213125
|
220639
|
220641
|
221107
|
222473
|
222883
|
222885
|
222887
|
223211
|
223213