kyuubi/build/release/append_notice.py
ulysses-you a06a2ca441
[KYUUBI #2746][INFRA] Improve NOTICE of binary release
### _Why are the changes needed?_

Maintain notice-binary manually.

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #2828 from ulysses-you/notice.

Closes #2746

52a0652f [ulysses-you] netty
c92695ec [ulysses-you] provided
318a7f5c [ulysses-you] maintain notice-binary
04cc02da [ulysses-you] init

Authored-by: ulysses-you <ulyssesyou18@gmail.com>
Signed-off-by: ulysses-you <ulyssesyou@apache.org>
2022-06-09 11:15:06 +08:00

60 lines
1.9 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
import sys
def usage():
print('Usage: %s <NOTICE file> <APPEND file1> <APPEND file2> ...' % sys.argv[0])
redundant_text_list = [
"""This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).""",
"""This product includes software developed at
The Apache Software Foundation (https://www.apache.org/).""",
"""This product includes software developed by
The Apache Software Foundation (http://www.apache.org/)."""
]
def append(notice_file, append_file):
with open(notice_file, 'r') as f:
notice_text = f.read()
with open(append_file, 'r') as f:
append_text = f.read()
for text in redundant_text_list:
append_text = append_text.replace(text, '')
append_text = append_text.strip()
if not append_text in notice_text:
with open(notice_file, 'a') as f:
f.write(append_text)
f.write('\n\n')
if __name__ == "__main__":
if len(sys.argv) < 3:
print(sys.argv)
usage()
sys.exit(-1)
notice_file = sys.argv[1]
for append_file in sys.argv[2:]:
append(notice_file, append_file)