Merged from trunk -r15193:15199
authorFabian Groffen <grobian@gentoo.org>
Thu, 14 Jan 2010 18:48:20 +0000 (18:48 -0000)
committerFabian Groffen <grobian@gentoo.org>
Thu, 14 Jan 2010 18:48:20 +0000 (18:48 -0000)
   | 15194   | Avoid portage import in order to avoid a potential sandbox   |
   | zmedico | violation if portage's *.pyc files are stale.                |

   | 15195   | Fix unicode quote handling to work with python3.             |
   | zmedico |                                                              |

   | 15196   | Fix output handling to avoid potential UnicodeEncodeError.   |
   | zmedico |                                                              |

   | 15197   | Use encoded byte strings with python-2.x, since the python   |
   | zmedico | ebuilds are known to remove the encodings module when        |
   |         | USE=build is enabled (thus disabling unicode                 |
   |         | decoding/encoding).                                          |

   | 15198   | Bug #300744 - Inside xpak(), exclude CONTENTS for quickpkg   |
   | zmedico | since contents is generated by the merge process.            |

   | 15199   | Make sure repoman knows about all files in the directory to  |
   | grobian | commit using bzr. Patch by Christian Faulhammer.             |

svn path=/main/branches/prefix/; revision=15200

bin/check-implicit-pointer-usage.py
bin/repoman
pym/portage/xpak.py

index 302939a1f2fbcb0a3c3662e23ea0a84fabfa45ad..f261e2ef5f6b6e1de0f2f888ec883189bd2c99b8 100755 (executable)
@@ -19,11 +19,9 @@ from __future__ import print_function
 import re
 import sys
 
-from portage import _unicode_decode
-
 implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration "
                               + "of function [`']([^']*)'")
-pointer_pattern = re.compile(
+pointer_pattern = (
     "([^:]*):(\d+): warning: "
     + "("
     +  "(assignment"
@@ -34,19 +32,40 @@ pointer_pattern = re.compile(
     +  ") makes pointer from integer without a cast"
     + "|"
     + "cast to pointer from integer of different size)")
+
+if sys.hexversion < 0x3000000:
+    # Use encoded byte strings in python-2.x, since the python ebuilds are
+    # known to remove the encodings module when USE=build is enabled (thus
+    # disabling unicode decoding/encoding). The portage module has a
+    # workaround for this, but currently we don't import that here since we
+    # don't want to trigger potential sandbox violations due to stale pyc
+    # files for the portage module.
+    unicode_quote_open = '\xE2\x80\x98'
+    unicode_quote_close = '\xE2\x80\x99'
+    def write(msg):
+        sys.stdout.write(msg)
+else:
+    unicode_quote_open = '\u2018'
+    unicode_quote_close = '\u2019'
+    def write(msg):
+        sys.stdout.buffer.write(msg.encode('utf_8', 'backslashreplace'))
+
+pointer_pattern = re.compile(pointer_pattern)
+
 last_implicit_filename = ""
 last_implicit_linenum = -1
 last_implicit_func = ""
 
 while True:
     if sys.hexversion >= 0x3000000:
-        line = _unicode_decode(sys.stdin.buffer.readline())
+        line = sys.stdin.buffer.readline().decode('utf_8', 'replace')
     else:
         line = sys.stdin.readline()
-    if line == '':
+    if not line:
         break
     # translate unicode open/close quotes to ascii ones
-    line = line.replace("\xE2\x80\x98", "`").replace("\xE2\x80\x99", "'")
+    line = line.replace(unicode_quote_open, "`")
+    line = line.replace(unicode_quote_close, "'")
     m = implicit_pattern.match(line)
     if m:
         last_implicit_filename = m.group(1)
@@ -59,6 +78,7 @@ while True:
             pointer_linenum = int(m.group(2))
             if (last_implicit_filename == pointer_filename
                 and last_implicit_linenum == pointer_linenum):
-                print(("Function `%s' implicitly converted to pointer at " \
-                      "%s:%d" % (last_implicit_func, last_implicit_filename,
-                                 last_implicit_linenum)))
+                write("Function `%s' implicitly converted to pointer at " \
+                      "%s:%d\n" % (last_implicit_func,
+                                   last_implicit_filename,
+                                   last_implicit_linenum))
index c181bf73fcaae09aa742643d6952ec531d6b4019..9dc783727079d6b1a356d4c2e79aa881663205ea 100755 (executable)
@@ -1109,7 +1109,7 @@ for x in scanlist:
                        if vcs == "svn":
                                myf = os.popen("svn status --depth=files --verbose " + checkdir)
                        if vcs == "bzr":
-                               myf = os.popen("bzr status -S " + checkdir)
+                               myf = os.popen("bzr ls -v --kind=file " + checkdir)
                        myl = myf.readlines()
                        myf.close()
                        for l in myl:
index 262f14c854a0f17e4eacb43cb3cc15282b4db183..7d595bdab33500009798446efa825b1aecf39ebb 100644 (file)
@@ -86,6 +86,9 @@ def xpak(rootdir,outfile=None):
        mylist.sort()
        mydata = {}
        for x in mylist:
+               if x == 'CONTENTS':
+                       # CONTENTS is generated during the merge process.
+                       continue
                x = _unicode_encode(x, encoding=_encodings['fs'], errors='strict')
                mydata[x] = open(os.path.join(rootdir, x), 'rb').read()