diff --git a/scripts/apache_python.txt b/scripts/apache_python.txt new file mode 100644 index 000000000000..f946a1a64380 --- /dev/null +++ b/scripts/apache_python.txt @@ -0,0 +1,15 @@ +# Copyright (c) 2016-present, Facebook, Inc. +# +# 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. +############################################################################## + diff --git a/scripts/remove_apache_header.sh b/scripts/remove_apache_header.sh new file mode 100755 index 000000000000..97980bfbb0ef --- /dev/null +++ b/scripts/remove_apache_header.sh @@ -0,0 +1,13 @@ +if [[ "$1" == *.py ]]; then + apache_header="apache_python.txt" +else + apache_header="apache_header.txt" +fi +apache_lines=$(wc -l < "${apache_header}") +apache_md5=$(cat "${apache_header}" | md5) +header_md5=$(head -n ${apache_lines} $1 | md5) +if [ "${header_md5}" == "${apache_md5}" ]; then + keep_lines=$(($(wc -l < $1) - ${apache_lines})) + tail -n ${keep_lines} $1 > _remove_apache_header.txt + mv _remove_apache_header.txt $1 +fi diff --git a/scripts/temp.sh b/scripts/temp.sh old mode 100644 new mode 100755 index 73e29d532312..18eb2b473381 --- a/scripts/temp.sh +++ b/scripts/temp.sh @@ -1,6 +1,7 @@ -find ../caffe2 -name "*.h" -exec ./add_apache_header.sh {} \; -find ../caffe2 -name "*.cc" -exec ./add_apache_header.sh {} \; -find ../caffe2 -name "*.cpp" -exec ./add_apache_header.sh {} \; -find ../caffe2 -name "*.cu" -exec ./add_apache_header.sh {} \; -find ../caffe2 -name "*.mm" -exec ./add_apache_header.sh {} \; -find ../caffe2 -name "*.m" -exec ./add_apache_header.sh {} \; +find ../caffe2 -name "*.py" -exec ./remove_apache_header.sh {} \; +find ../caffe2 -name "*.h" -exec ./remove_apache_header.sh {} \; +find ../caffe2 -name "*.cc" -exec ./remove_apache_header.sh {} \; +find ../caffe2 -name "*.cpp" -exec ./remove_apache_header.sh {} \; +find ../caffe2 -name "*.cu" -exec ./remove_apache_header.sh {} \; +find ../caffe2 -name "*.mm" -exec ./remove_apache_header.sh {} \; +find ../caffe2 -name "*.m" -exec ./remove_apache_header.sh {} \;