Update COS license regex

- Allow things like '#!/usr/bin/python'
- Allow 'https', and 4 spaces before the license URL (as per
  go/releasing/preparing)

Other changes:
- Don't license check README files
- Allow projects to override COS license check settings
- Expect first-party repos to have a PRESUBMIT.cfg that explicitly sets
  the correct license check settings

BUG=None
TEST=`repo upload` on some changes

Change-Id: I1edd8633be34dc676776e720868bc2c006e1629c
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
index 15d0057..8450c7e 100644
--- a/PRESUBMIT.cfg
+++ b/PRESUBMIT.cfg
@@ -7,6 +7,7 @@
 
 [Hook Overrides]
 cros_license_check: false
+cos_license_check: true
 long_line_check: true
 tab_check: true
 stray_whitespace_check: true
diff --git a/pre-upload.py b/pre-upload.py
index 569df9d..868956e 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -106,6 +106,7 @@
 
 LICENSE_EXCLUDED_PATHS = [
     r'^(.*/)?OWNERS(\..*)?$',
+    r'^(.*/)?README(\..*)?$',
 ]
 
 _CONFIG_FILE = 'PRESUBMIT.cfg'
@@ -1444,14 +1445,13 @@
   and Apache 2.0 license
   """
   COS_LICENSE_HEADER = (
-      r"""^[<!\-#/\*]*
-[#/\*]* ?Copyright (20[0-9]{2}) Google LLC
+      r"""[#/\*]* ?Copyright (20[0-9]{2}) Google LLC
 [#/\*]* ?
 [#/\*]* ?Licensed under the Apache License, Version 2.0 \(the "License"\);
 [#/\*]* ?you may not use this file except in compliance with the License\.
 [#/\*]* ?You may obtain a copy of the License at
 [#/\*]* ?
-[#/\*]* ?      http://www\.apache\.org/licenses/LICENSE-2\.0
+[#/\*]* ?     ? ?https?://www\.apache\.org/licenses/LICENSE-2\.0
 [#/\*]* ?
 [#/\*]* ?Unless required by applicable law or agreed to in writing, software
 [#/\*]* ?distributed under the License is distributed on an "AS IS" BASIS,
@@ -2139,9 +2139,6 @@
 _PROJECT_SPECIFIC_HOOKS = {
     'chromiumos/third_party/kernel': [_kernel_configcheck],
     'chromiumos/third_party/kernel-next': [_kernel_configcheck],
-    'cos/manifest': [_check_cos_license],
-    'cos/repohooks': [_check_cos_license],
-    'cos/overlays/board-overlays': [_check_cos_ebuild_license_header],
 }
 
 
@@ -2154,6 +2151,8 @@
     'stray_whitespace_check': _check_no_stray_whitespace,
     'json_check': _run_json_check,
     'long_line_check': _check_no_long_lines,
+    'cos_license_check': _check_cos_license,
+    'cos_ebuild_license_header_check': _check_cos_ebuild_license_header,
     'cros_license_check': _check_cros_license,
     'aosp_license_check': _check_aosp_license,
     'gofmt_check': _check_gofmt,