lafilefixing: Use .replace() instead of the broken regex to update the contents
authorSebastian Luther <SebastianLuther@gmx.de>
Sun, 18 Jul 2010 05:39:39 +0000 (07:39 +0200)
committerZac Medico <zmedico@gentoo.org>
Sun, 18 Jul 2010 13:49:21 +0000 (06:49 -0700)
pym/portage/tests/lafilefixer/test_lafilefixer.py
pym/portage/util/lafilefixer.py

index 71ed31b64d448a307431ded32dc7e3fda20bdf18..0bcffaadafd0c23a6fd62d4c06532ee6eda10332 100644 (file)
@@ -85,6 +85,17 @@ class test_lafilefixer(TestCase):
                        b"dependency_libs=' -L/usr/lib'\n"
                yield b"dependency_libs=' -L/usr/lib/pkgconfig/../.. -L/usr/lib/pkgconfig/..'\n", \
                        b"dependency_libs=' -L/usr -L/usr/lib'\n"
+               #we once got a backtrace on this one
+               yield b"dependency_libs=' /usr/lib64/libMagickCore.la -L/usr/lib64 -llcms2 /usr/lib64/libtiff.la " + \
+                       b"-ljbig -lc /usr/lib64/libfreetype.la /usr/lib64/libjpeg.la /usr/lib64/libXext.la " + \
+                       b"/usr/lib64/libXt.la /usr/lib64/libSM.la -lICE -luuid /usr/lib64/libICE.la /usr/lib64/libX11.la " + \
+                       b"/usr/lib64/libxcb.la /usr/lib64/libXau.la /usr/lib64/libXdmcp.la -lbz2 -lz -lm " + \
+                       b"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/libgomp.la -lrt -lpthread /usr/lib64/libltdl.la -ldl " + \
+                       b"/usr/lib64/libfpx.la -lstdc++'", \
+                       b"dependency_libs=' -L/usr/lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4 -lMagickCore -llcms2 " + \
+                       b"-ltiff -ljbig -lc -lfreetype -ljpeg -lXext -lXt -lSM -lICE -luuid -lX11 -lxcb -lXau -lXdmcp " + \
+                       b"-lbz2 -lz -lm -lgomp -lrt -lpthread -lltdl -ldl -lfpx -lstdc++'"
+
 
        def get_test_cases_broken(self):
                yield b""
index 7d6171c16e26f313a109c526b7550e05ca2e5fae..2b093d87b22c6fbf4d2e17df914b94b0b7cbf904 100644 (file)
@@ -167,15 +167,19 @@ def rewrite_lafile(contents):
 
        #Don't touch the file if we don't need to, otherwise put the expected values into
        #'contents' and write it into the la file.
-       if dep_libs == expected_dep_libs and \
-               (inh_link_flags is None or expected_inh_link_flags == inh_link_flags):
-               return False, None
 
-       contents = re.sub(b"dependency_libs='" + dep_libs + b"'", \
-               b"dependency_libs='" + expected_dep_libs + b"'" , contents)
+       changed = False
+       if dep_libs != expected_dep_libs:
+               contents = contents.replace(b"dependency_libs='" + dep_libs + b"'", \
+                       b"dependency_libs='" + expected_dep_libs + b"'")
+               changed = True
 
-       if inh_link_flags is not None:
-               contents = re.sub(b"inherited_linker_flags='" + inh_link_flags + b"'", \
-                       b"inherited_linker_flags='" + expected_inh_link_flags + b"'" , contents)
+       if inh_link_flags is not None and expected_inh_link_flags != inh_link_flags:
+               contents = contents.replace(b"inherited_linker_flags='" + inh_link_flags + b"'", \
+                       b"inherited_linker_flags='" + expected_inh_link_flags + b"'")
+               changed = True
 
-       return True, contents
+       if changed:
+               return True, contents
+       else:
+               return False, None