<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>4732</bug_id>
          
          <creation_ts>2013-06-14 17:16:25 +0000</creation_ts>
          <short_desc>Wrong path to terminfo files in buildtools-tarball causes python version check to fail</short_desc>
          <delta_ts>2013-07-30 02:13:19 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Yocto Project Subprojects</classification>
          <product>ADT</product>
          <component>adt</component>
          <version>1.5</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>1.5 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Saul Wold">sgw</reporter>
          <assigned_to name="Hongxu Jia">hongxu.jia</assigned_to>
          <cc>hongxu.jia</cc>
    
    <cc>kai.kang</cc>
    
    <cc>liezhi.yang</cc>
    
    <cc>mark.hatle</cc>
    
    <cc>ning.zhang</cc>
    
    <cc>poky.adt.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>Qi.Chen</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>sen.zhang</cc>
    
    <cc>sgw</cc>
    
    <cc>wenzong.fan</cc>
    
    <cc>yi.zhao</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>33908</commentid>
    <comment_count>0</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-06-14 17:16:25 +0000</bug_when>
    <thetext>With the addition of the build tools tarball, the version check for python will sometimes be incorrect due to the terminal type. There is a mismatch between the nativesdk tinfo and the system&apos;s terminfo files.

This can be seen with by strace&apos;ing the write90 syscall, depending on your TERM setting you might see:

write(1, &quot;\33[?1034hTrue\n&quot;, 13True
)        = 13
or 
write(1, &quot;True\n&quot;, 13True
)        = 13

The first variation will cause the version check to fail, we could modify the version check to ignore the leading escapes and/or point tinfo at the right terminfo files.

Adding TERMINFO shell variable pointing to the nativesdk will work for the common TERM types, but still seems to fail for xterm-256color, which is not in our nativesdk terminfo.

I propose that we modify the version check to ignore the leading escapes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33910</commentid>
    <comment_count>1</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-06-14 20:44:46 +0000</bug_when>
    <thetext>I tried setting TERMPATH TERMINFO_DIRS, TERMINFO, all had no effect with the xterm-256color entry, it would search the nativesdk terminfo if set, but failing to find it would then search the system terminfo files

More interesting is is works OK on Fedora, but fails on Ubuntu for the same TERM settings

Since we are operating in a script, preserving TERM and unsetting TERM seems like the right approach with a consistent result.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33911</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-06-14 21:06:40 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Since we are operating in a script, preserving TERM and unsetting TERM seems
&gt; like the right approach with a consistent result.

No, this is a really bad idea. Think about devshell for example. Setting TERM and running python should not break and this is a problem in the nativesdk. Lets fix the nativesdk, not hack around it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33912</commentid>
    <comment_count>3</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-06-14 21:23:06 +0000</bug_when>
    <thetext>devshell works fine, it&apos;s the value that the shell is testing from python. Vi and all the other tools work fine in a devshell since they are using distro tools, distro terminfo. Even knotty looks correct and sets the correct colors.

I agree we need to fix the nativesdk&apos;s python build, but until then, people are going to be running into this with older releases and will be getting failures with master.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33933</commentid>
    <comment_count>4</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-06-17 16:09:15 +0000</bug_when>
    <thetext>Have a better fix for this pending...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33996</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-06-20 12:13:44 +0000</bug_when>
    <thetext>This was fixed by  http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=c281cd149bdbce29fc69cb34c65c4295cfed2060 and http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=534c4d0f1e287d0ac82504b273a5497d3457582a</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34378</commentid>
    <comment_count>6</comment_count>
    <who name="Wenzong.Fan">wenzong.fan</who>
    <bug_when>2013-07-08 09:44:49 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; This was fixed by 
&gt; http://git.yoctoproject.org/cgit.cgi/poky/commit/
&gt; ?id=c281cd149bdbce29fc69cb34c65c4295cfed2060 and
&gt; http://git.yoctoproject.org/cgit.cgi/poky/commit/
&gt; ?id=534c4d0f1e287d0ac82504b273a5497d3457582a

This should fixed the xterm issue but xterm-256color still failed, shall we add a tinfo file for xterm-256color? or just link it to xterm-color simply?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34655</commentid>
    <comment_count>7</comment_count>
    <who name="Hongxu Jia">hongxu.jia</who>
    <bug_when>2013-07-18 06:44:54 +0000</bug_when>
    <thetext>I think the issue is still there since xterm-256color is added to
terminfo-base in ncurses:

NATIVELSBSTRING   = &quot;Ubuntu-13.04&quot;
TARGET_SYS        = &quot;i586-poky-linux&quot;
MACHINE           = &quot;emenlow-noemgd&quot;
master 3dee534f1e25109e0bdb681de0746c336f4b8840

* On host
bitbake nativesdk-python -cdevshell
root:Python-2.7.3# export TERM=xterm-256color

root:Python-2.7.3# which python
/home/jiahongxu/yocto/build-20130522-pmount-sysvinit/tmp/sysroots/x86_64-linux/usr/bin/python-native/python
root:Python-2.7.3# python -c &quot;import readline;print &apos;a&apos;&quot; | hexdump -c
0000000 033   [   ?   1   0   3   4   h   a  \n                        
000000a

* On target
root@emenlow-noemgd:~# export TERM=xterm-256color
root@emenlow-noemgd:~# which python
/usr/bin/python
root@emenlow-noemgd:~# python -c &quot;import readline;print &apos;a&apos;&quot; | hexdump -c
0000000 033   [   ?   1   0   3   4   h   a  \n</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34656</commentid>
    <comment_count>8</comment_count>
    <who name="Hongxu Jia">hongxu.jia</who>
    <bug_when>2013-07-18 06:48:36 +0000</bug_when>
    <thetext>While imports readline in python, if the term in terminfo is available and 
it contains the variable &apos;km&apos; and &apos;smm&apos;, the readline initialization will
output the value of &apos;smm&apos; which is the escape sequence &apos;\E[?1034h&apos;.

&apos;km&apos; means the terminal has a meta key which is a special key on MIT keyboards,
&apos;smm&apos; means turn on the meta key if this terminal has one.

There are ** solutin to fix this issue:

1) Preserving TERM and unsetting TERM, or setting TERM with a terminal
   without &apos;smm&apos; (such as terminal &apos;dumb&apos;). This is the most common 
   approach.
   https://bugzilla.redhat.com/show_bug.cgi?id=304181
   http://bugs.python.org/issue11390
   http://lists.gnu.org/archive/html/bug-readline/2013-06/msg00000.html
   But the effect is global even we don&apos;t import readline.

2) Modify readline.c in python, let readline use a term without &apos;smm&apos;
   as default terminal (such as &apos;dumb&apos;), it is similar to the above
   solution, but it localizes the effect in readline.

3) Modify terminfo.src in ncurses, let terminfo database doesn&apos;t
   contian &apos;smm&apos;, but the kinds of terms we supported is limited.

4) Modify terminal.c and readline.c in GNU Readline library to
   explicity disable meta key, or just comment out the outputing code.
   
I prefer solution 2, because it has the least side effect.
Explicitly use dumb as default terminal to avoid probably escape sequence
output. The dumb is used to label tty lines when you don&apos;t know what kind
of terminal is on it. The characteristics of an unknown terminal are the 
lowest common denominator.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34680</commentid>
    <comment_count>9</comment_count>
    <who name="Saul Wold">sgw</who>
    <bug_when>2013-07-18 17:17:39 +0000</bug_when>
    <thetext>Another option is for the nativesdk version to not hardcode include the readline library, since bitbake imports readline it will work correctly.

Hardcoding the terminal to dumb would break the bitbake knotty interface.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34692</commentid>
    <comment_count>10</comment_count>
    <who name="Hongxu Jia">hongxu.jia</who>
    <bug_when>2013-07-19 08:08:31 +0000</bug_when>
    <thetext>How about to explicitly disable meta key in python readline module
while readline initialization.

Meta key is a special key on MIT keyboards such as the space-cadet
keyboard, and on Sun Microsystems keyboards, marked as a solid
diamond. It almost doesn&apos;t exist in our keyboards, so it has no side
effect to disable it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>35138</commentid>
    <comment_count>11</comment_count>
    <who name="Hongxu Jia">hongxu.jia</who>
    <bug_when>2013-07-30 02:13:19 +0000</bug_when>
    <thetext>Merged into master:
http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=fcfee5c46cdb8797cba0097994815d59157bac7c</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>