aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mergenotice.py
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-03-18 12:01:38 +0900
committerJiyong Park <jiyong@google.com>2019-03-21 08:05:50 +0900
commit52818fcde8265fd43ad5f331f57122ecdbe7a6be (patch)
tree9c0edd5e4f9dfcae48cb3f87ff0f10c11b3fa776 /scripts/mergenotice.py
parent5a3f31b28451717dd7e9d948bcaa5644de759b17 (diff)
downloadbuild_soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.tar.gz
build_soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.tar.bz2
build_soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.zip
Notice support for APEX
Notice file for an APEX is created by merging notice files for the modules included in it (plus the notice file for the APEX itself if specified). Notice files having the same content are not duplicated; it is emitted only once. Bug: 128701495 Test: m (apex_test is amended) Test: m and inspect $(PRODUCT_OUT)/obj/NOTICE.txt to check there are license entries for /system/apex/*.apex files Change-Id: I169d91038291a6c71615de97cf5b03174afab5d4
Diffstat (limited to 'scripts/mergenotice.py')
-rwxr-xr-xscripts/mergenotice.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/mergenotice.py b/scripts/mergenotice.py
new file mode 100755
index 00000000..407ae8cc
--- /dev/null
+++ b/scripts/mergenotice.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2019 The Android Open Source Project
+#
+# 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
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""
+Merges input notice files to the output file while ignoring duplicated files
+This script shouldn't be confused with build/make/tools/generate-notice-files.py
+which is responsible for creating the final notice file for all artifacts
+installed. This script has rather limited scope; it is meant to create a merged
+notice file for a set of modules that are packaged together, e.g. in an APEX.
+The merged notice file does not reveal the individual files in the package.
+"""
+
+import sys
+import argparse
+
+def get_args():
+ parser = argparse.ArgumentParser(description='Merge notice files.')
+ parser.add_argument('--output', help='output file path.')
+ parser.add_argument('inputs', metavar='INPUT', nargs='+',
+ help='input notice file')
+ return parser.parse_args()
+
+def main(argv):
+ args = get_args()
+
+ processed = set()
+ with open(args.output, 'w+') as output:
+ for input in args.inputs:
+ with open(input, 'r') as f:
+ data = f.read().strip()
+ if data not in processed:
+ processed.add(data)
+ output.write('%s\n\n' % data)
+
+if __name__ == '__main__':
+ main(sys.argv)