licensing: moved all legacy licenses to third party source tree

1) Some licenses under licenses/* weren't used anymore, those are deleted.

2) A few licenses belonged in third_party/chromiumos-overlay/licenses/
all along and were moved there (like BSD-Google or Atheros)

3) Some other licenses were static mappings for BSD/MIT packages without
licenses in their source tree and they have (already) been moved
under third_party/chromiumos-overlay/licenses/copyright-attribution/

licenses.py:
- removed code that looks in the licenses/ dir where this code is stored
- Added new COPYRIGHT_ATTRIBUTION_DIR constant to point to copyright
  attribution tree
- PACKAGE_LICENSES was emptied of all its special cases (yeah!)
- _GetOverrideLicense is the new method that finds a license for
  packages missing a copyright attribution license in their source tree
- added more debugging info and better error messages

diff_license_html.py:
- updated regexes for the new types of licenses.

TEST=ran the code against an older M31 tree to see the old code vs the
new one:
License removed: Source License xz/COPYING
=> this is normal. I added as-is in a static mapping to get this file, and this hack was removed.

License removed: Stock License Atheros
License added: Custom License Atheros
License removed: Stock License BSD-Google
License added: Custom License BSD-Google
License removed: Stock License BSD-bsdiff
License added: Copyright Attribution License chromiumos-overlay/licenses/copyright-attribution/dev-util/bsdiff
License removed: Stock License BSD-dhcpcd
License added: Copyright Attribution License chromiumos-overlay/licenses/copyright-attribution/net-misc/dhcpcd
License removed: Stock License BSD-iputils
License added: Copyright Attribution License chromiumos-overlay/licenses/copyright-attribution/net-misc/iputils
License removed: Stock License BSD-libevent
License added: Copyright Attribution License chromiumos-overlay/licenses/copyright-attribution/dev-libs/libevent
License removed: Stock License MIT-MIT
License added: Copyright Attribution License chromiumos-overlay/licenses/copyright-attribution/net-dns/c-ares
License removed: Stock License MIT-Mesa
License added: Source License Mesa/docs/COPYING
License removed: Stock License Marvell
License added: Custom License Marvell-sd8787
License removed: Stock License X
License added: Custom License X
=> These are expected license moves to the new locations

License removed: Stock License fontconfig
License added: Custom License fontconfig
=> as Mike pointed out, this is actually incorrect, it's an MIT license. I'll change our source tree in a subsequent CL.

License removed: Stock License ncurses
License added: Source License ncurses/Ada95/package/debian/copyright
License added: Source License ncurses/test/package/debian/copyright
=> The old custom license said
Copyright (c) 1998-2000,2005 Free Software Foundation, Inc.
INFO:root:Read licenses from ebuild for sys-libs/ncurses-5.9-r2: MIT
The new licenses picked up in the source, also show an FSF copyright file
so we're good.

License removed: Stock License ppp-2.4.4
License added: Source License ppp/pppd/plugins/pppoatm/COPYING
License added: Source License ppp/pppd/plugins/radius/COPYRIGHT
=> these new files show better licensing than the old incomplete file.

License added: Copyright Attribution License chromiumos-overlay/licenses/copyright-attribution/sys-libs/timezone-data
=> This is good, we were missing that.

=> o3d used to be wrongfully labelled as BSD-Google. This was not correct.
It is now BSD, and my script found all of these licenses. In the code.
It's a lot, but as far as I can tell, it's actually the correct thing to do:
License added: Source License o3d/base/third_party/dmg_fp/LICENSE
License added: Source License o3d-203170/o3d/samples/box2d/demos/LICENSE.txt
License added: Source License o3d-203170/o3d/samples/box2d/third_party/box2d/LICENSE.txt
License added: Source License o3d-203170/o3d/samples/o3d-webgl-samples/box2d/demos/LICENSE.txt
License added: Source License o3d-203170/o3d/samples/o3d-webgl-samples/box2d/third_party/box2d/LICENSE.txt
License added: Source License o3d/base/third_party/dmg_fp/LICENSE
License added: Source License o3d/base/third_party/dynamic_annotations/LICENSE
License added: Source License o3d/base/third_party/icu/LICENSE
License added: Source License o3d/base/third_party/nspr/LICENSE
License added: Source License o3d/base/third_party/symbolize/LICENSE
License added: Source License o3d/base/third_party/valgrind/LICENSE
License added: Source License o3d/base/third_party/xdg_mime/LICENSE
License added: Source License o3d/base/third_party/xdg_user_dirs/LICENSE
License added: Source License o3d/native_client/LICENSE
License added: Source License o3d/net/third_party/gssapi/LICENSE
License added: Source License o3d/net/third_party/mozilla_security_manager/LICENSE
License added: Source License o3d/net/third_party/nss/LICENSE
License added: Source License o3d/net/tools/spdyshark/COPYING
License added: Source License o3d/o3d/installer/linux/debian.in/copyright
License added: Source License o3d/o3d/samples/third_party/codemirror/LICENSE
License added: Source License o3d/o3d/samples/third_party/xmljs/COPYING
License added: Source License o3d/o3d/third_party/gflags/COPYING
License added: Source License o3d/o3d/third_party/gflags/packages/deb/copyright
License added: Source License o3d/o3d/third_party/glu/LICENSE.txt
License added: Source License o3d/o3d/third_party/libtxc_dxtn/LICENSE
License added: Source License o3d/o3d/third_party/npapi/COPYING
License added: Source License o3d/o3d/third_party/ply/COPYING
License added: Source License o3d/o3d/third_party/vectormath/LICENSE
License added: Source License o3d/o3d/third_party/vectormath/files/vectormathlibrary/LICENSE
License added: Source License o3d/ppapi/LICENSE
License added: Source License o3d/testing/gmock/COPYING
License added: Source License o3d/testing/gmock/scripts/generator/COPYING
License added: Source License o3d/testing/gtest/COPYING
License added: Source License o3d/third_party/antlr3/LICENSE.txt
License added: Source License o3d/third_party/antlr3/runtime/ActionScript/LICENSE
License added: Source License o3d/third_party/antlr3/runtime/C/COPYING
License added: Source License o3d/third_party/antlr3/runtime/CSharp/LICENSE.TXT
License added: Source License o3d/third_party/antlr3/runtime/JavaScript/build/license.txt
License added: Source License o3d/third_party/antlr3/runtime/Python/LICENSE
License added: Source License o3d/third_party/cg/LICENSE
License added: Source License o3d/third_party/fcollada/LICENSE
License added: Source License o3d/third_party/fcollada/files/LibXML/COPYING
License added: Source License o3d/third_party/fcollada/files/LibXML/Copyright
License added: Source License o3d/third_party/glew/LICENSE
License added: Source License o3d/third_party/harfbuzz/COPYING
License added: Source License o3d/third_party/icu/source/data/brkitr/LICENSE
License added: Source License o3d/third_party/libevent/LICENSE
License added: Source License o3d/third_party/libjpeg/LICENSE
License added: Source License o3d/third_party/libpng/LICENSE
License added: Source License o3d/third_party/makeself/COPYING
License added: Source License o3d/third_party/makeself/LICENSE
License added: Source License o3d/third_party/mesa/MesaLib/docs/COPYING
License added: Source License o3d/third_party/modp_b64/LICENSE
License added: Source License o3d/third_party/skia/LICENSE
License added: Source License o3d/third_party/skia/third_party/glu/LICENSE.txt
License added: Source License o3d/third_party/skia/third_party/harfbuzz/COPYING
License added: Source License o3d/third_party/zip_utils/LICENSE
License added: Source License o3d/third_party/zlib/LICENSE
License added: Source License o3d/tools/gyp/LICENSE
License added: Source License o3d/v8/LICENSE

BUG=chromium:271836 chromium:271812

Change-Id: I7ebe3206b849eb36ef156c740a04ce872b4cfc1d
Reviewed-on: https://chromium-review.googlesource.com/175004
Reviewed-by: David James <davidjames@chromium.org>
Reviewed-by: Marc MERLIN <merlin@chromium.org>
Commit-Queue: Marc MERLIN <merlin@chromium.org>
Tested-by: Marc MERLIN <merlin@chromium.org>
diff --git a/scripts/diff_license_html.py b/scripts/diff_license_html.py
index 83bd138..e9ecbe3 100644
--- a/scripts/diff_license_html.py
+++ b/scripts/diff_license_html.py
@@ -29,13 +29,17 @@
   licenses = set()
 
   pkg_rgx = re.compile(r'<span class="title">(.+)-(.+)</span>')
+  # Do not add <pre> in the regex or it would only show the first entry on
+  # a package that has multiple hits.
   license_rgx1 = re.compile(r'Scanned (Source License .+):', re.IGNORECASE)
-  license_rgx2 = re.compile(r'<pre>(Custom License .+):', re.IGNORECASE)
+  license_rgx2 = re.compile(r'(Custom License .+):', re.IGNORECASE)
+  license_rgx3 = re.compile(r'(Copyright Attribution .+):', re.IGNORECASE)
+  # This regex isn't as tight because it has to match these:
   # Gentoo Package Stock License BZIP2:
+  # <a ... class="title">Gentoo Package Provided Stock License public-domain</a>
   # <a ... class="title">Gentoo Package Stock License public-domain</a>
-  license_rgx3 = re.compile(r'Gentoo Package (Stock License [^<:]+)',
-                            re.IGNORECASE)
-  license_rgx4 = re.compile(r'class="title">(Custom License .+)</a>',
+  license_rgx4 = re.compile(r'(Stock License [^<:]+)', re.IGNORECASE)
+  license_rgx5 = re.compile(r'class="title">(Custom License .+)</a>',
                             re.IGNORECASE)
   with open(html_file, 'r') as f:
     for line in f:
@@ -57,7 +61,7 @@
         lic = re.sub(r'Source license', r'Source License', lic)
         licenses.add(lic)
 
-      for rgx in (license_rgx2, license_rgx3, license_rgx4):
+      for rgx in (license_rgx2, license_rgx3, license_rgx4, license_rgx5):
         match = rgx.search(line)
         if match:
           licenses.add(match.group(1))