| 1 | #! /bin/bash |
|---|
| 2 | # This script compares SecureFileList.txt against the release source tree to |
|---|
| 3 | # identify any files that would be stripped by the docsafe. |
|---|
| 4 | # To use this script execute it from the directory where tarball with the |
|---|
| 5 | # release source is located. Alternatively, execute this script from the |
|---|
| 6 | # HD DTA source root - a directory containing dta directory. Alternatively, |
|---|
| 7 | # directory should contain source.lst file that has list of all the files in |
|---|
| 8 | # the release. |
|---|
| 9 | # The scrpt requres tar, grep, awk and the recent version of bash. |
|---|
| 10 | |
|---|
| 11 | secure_name_list="SecureFileList.txt" |
|---|
| 12 | source_file_list="source.lst" |
|---|
| 13 | match_file_list="match.lst" |
|---|
| 14 | module_file_list="modules.lst" |
|---|
| 15 | |
|---|
| 16 | function create-source-list() |
|---|
| 17 | { |
|---|
| 18 | local archive_name=$(compgen -G "*.tar.gz") |
|---|
| 19 | # select first name from the list |
|---|
| 20 | for name in ${archive_name} ; do |
|---|
| 21 | archive_name=${name} |
|---|
| 22 | break |
|---|
| 23 | done |
|---|
| 24 | if [ -n "${archive_name}" ] ; then |
|---|
| 25 | echo -n "Found archive ${archive_name}... " |
|---|
| 26 | tar -tzf ${archive_name} > ${source_file_list} |
|---|
| 27 | else |
|---|
| 28 | if [ -d ./dta ] ; then |
|---|
| 29 | echo -n "Found dta directory... " |
|---|
| 30 | find . > ${source_file_list} |
|---|
| 31 | else |
|---|
| 32 | echo "Unable create source list, exiting." |
|---|
| 33 | exit 254 |
|---|
| 34 | fi |
|---|
| 35 | fi |
|---|
| 36 | echo "created source list." |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | if [ ! -e ${secure_name_list} ] ; then |
|---|
| 41 | echo "Secure file list can not be found." |
|---|
| 42 | exit 255 |
|---|
| 43 | fi |
|---|
| 44 | |
|---|
| 45 | if [ ! -e ${source_file_list} ] ; then |
|---|
| 46 | echo "Source file list can not be found, attempting to create." |
|---|
| 47 | create-source-list |
|---|
| 48 | fi |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | sed -e 's/[ \t]*$//' -e 's/\\/\//g' -e '/^$/{d}' -e 's/\(^[^\/#]\)/\/\1/' ${secure_name_list} > u_${secure_name_list} |
|---|
| 52 | |
|---|
| 53 | grep -Fo -f u_${secure_name_list} ${source_file_list} > ${match_file_list} |
|---|
| 54 | |
|---|
| 55 | echo "###" >> ${match_file_list} |
|---|
| 56 | grep -F -f ${match_file_list} u_${secure_name_list} > ${module_file_list} |
|---|
| 57 | |
|---|
| 58 | awk '/^###/{header=$0}; /^[^#]/{if(header != "") {print header; header=""}; print $0}' ${module_file_list} |
|---|
| 59 | |
|---|
| 60 | rm ${source_file_list} ${match_file_list} ${module_file_list} u_${secure_name_list} |
|---|
| 61 | |
|---|