xref: /aosp_15_r20/external/pytorch/scripts/remove_apache_header.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard Workerif [[ "$1" == *.py ]]; then
2*da0073e9SAndroid Build Coastguard Worker  apache_header="apache_python.txt"
3*da0073e9SAndroid Build Coastguard Workerelse
4*da0073e9SAndroid Build Coastguard Worker  apache_header="apache_header.txt"
5*da0073e9SAndroid Build Coastguard Workerfi
6*da0073e9SAndroid Build Coastguard Workerapache_lines=$(wc -l < "${apache_header}")
7*da0073e9SAndroid Build Coastguard Workerapache_md5=$(cat "${apache_header}" | md5)
8*da0073e9SAndroid Build Coastguard Workerheader_md5=$(head -n ${apache_lines} $1 | md5)
9*da0073e9SAndroid Build Coastguard Workerif [ "${header_md5}" == "${apache_md5}" ]; then
10*da0073e9SAndroid Build Coastguard Worker  keep_lines=$(($(wc -l < $1) - ${apache_lines}))
11*da0073e9SAndroid Build Coastguard Worker  tail -n ${keep_lines} $1 > _remove_apache_header.txt
12*da0073e9SAndroid Build Coastguard Worker  mv _remove_apache_header.txt $1
13*da0073e9SAndroid Build Coastguard Workerfi
14