Merge "generate_notice.py: fix SPDX confusion." into main am: c29851fd5e

Original change: https://android-review.googlesource.com/c/platform/bionic/+/3486730

Change-Id: I6077c8513d2a4e2f439ad4c4116b0f6e8ec890b4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/libc/NOTICE b/libc/NOTICE
index c52a102..c869a31 100644
--- a/libc/NOTICE
+++ b/libc/NOTICE
@@ -4122,35 +4122,6 @@
 
 -------------------------------------------------------------------
 
-Copyright (c) 2015 Joerg Sonnenberger <joerg@NetBSD.org>.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-1. Redistributions of source code must retain the above copyright
-   notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
-   notice, this list of conditions and the following disclaimer in
-   the documentation and/or other materials provided with the
-   distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
-COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
-BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
-AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
-OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
-
--------------------------------------------------------------------
-
 Copyright (c) 2015 Nuxi, https://nuxi.nl/
 
 Redistribution and use in source and binary forms, with or without
diff --git a/libc/tools/generate_notice.py b/libc/tools/generate_notice.py
index c998e32..034a3b3 100755
--- a/libc/tools/generate_notice.py
+++ b/libc/tools/generate_notice.py
@@ -151,6 +151,12 @@
              (path, len(lines)))
         return
 
+    # Skip over our own files if they're SPDX licensed.
+    # Because we use the // comment style, without this we'd copy the whole source file!
+    if re.compile('^// Copyright \(C\) 2\d\d\d The Android Open Source Project\n' + \
+                  '// SPDX-License-Identifier: ').match(content):
+        return
+
     # Manually iterate because extract_copyright_at tells us how many lines to
     # skip.
     i = 0