Difference between
modified post 33a4be423 by Anonymous on Tue 12th Nov 2024 17:05
original post e75825a by Anonymous on Tue 12th Nov 2024 16:23
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | #!/bin/bash | |
| 2 | 2 | ||
| 3 | 3 | # | |
| 4 | 4 | # wintartest001.bash - /cygdrive/c/Windows/system32/tar filesystem test | |
| 5 | 5 | # which compares files unpacked by /cygdrive/c/Windows/system32/tar | |
| 6 | 6 | # and /usr/bin/tar, and checks whether files have same hashes | |
| 7 | 7 | # | |
| 8 | 8 | # Written by Roland Mainz <roland.mainz@nrubsig.org> | |
| 9 | 9 | # | |
| 10 | 10 | ||
| 11 | 11 | # | |
| 12 | 12 | # Notes: | |
| 13 | + | # - Genreate test tar.bz2 files like this: | |
| 13 | 15 | # - Compare individual files with | |
| 14 | 16 | # $ diff -u <(od -x -v cygwintar/bin/ksh93.exe) <(od -x -v wintar/bin/ksh93.exe) | |
| 15 | 17 | # | |
| 16 | 18 | ||
| 17 | 19 | export PATH='/bin:/usr/bin' | |
| 18 | 20 | ||
| 19 | 21 | # set umask=0000 to avoid permission madness on SMB | |
| 20 | 22 | umask 0000 | |
| 21 | 23 | ||
| 22 | 24 | typeset intarfile="$1" | |
| 23 | 25 | typeset f | |
| 24 | 26 | typeset -i num_failed_hash_compare=0 | |
| 25 | 27 | ||
| 26 | 28 | if [[ ! -x '/cygdrive/c/Windows/system32/tar' ]] ; then | |
| 27 | 29 | printf $"%s: %s not found.\n" \ | |
| 28 | 30 | "$0" '/cygdrive/c/Windows/system32/tar' 1>&2 | |
| 29 | 31 | exit 1 | |
| 30 | 32 | fi | |
| 31 | 33 | ||
| 32 | 34 | if [[ ! -r "$intarfile" ]] ; then | |
| 33 | 35 | printf $"%s: Input file %q not readable.\n" \ | |
| 34 | 36 | "$0" "$intarfile" 1>&2 | |
| 35 | 37 | exit 1 | |
| 36 | 38 | fi | |
| 37 | 39 | ||
| 38 | 40 | typeset IFS=$'\n' | |
| 39 | 41 | ||
| 40 | 42 | set -o xtrace | |
| 41 | 43 | set -o errexit | |
| 42 | 44 | ||
| 43 | 45 | intarfile="$(realpath "$intarfile")" | |
| 44 | 46 | ||
| 45 | 47 | rm -Rf 'wintar_tmp' 'cygwintar_tmp' | |
| 46 | 48 | mkdir 'wintar_tmp' 'cygwintar_tmp' | |
| 47 | 49 | ||
| 48 | 50 | cd 'wintar_tmp' | |
| 49 | 51 | /cygdrive/c/Windows/system32/tar -xvf "$(cygpath -w "$intarfile")" | |
| 50 | 52 | cd '..' | |
| 51 | 53 | ||
| 52 | 54 | cd 'cygwintar_tmp' | |
| 53 | 55 | /usr/bin/tar -xvf "$intarfile" | |
| 54 | 56 | cd '..' | |
| 55 | 57 | ||
| 56 | 58 | typeset -a file_list=( | |
| 57 | 59 | $(cd 'cygwintar_tmp' && find . -type f) | |
| 58 | 60 | ) | |
| 59 | 61 | ||
| 60 | 62 | set +o xtrace +o errexit | |
| 61 | 63 | ||
| 62 | 64 | for f in "${file_list[@]}" ; do | |
| 63 | 65 | IFS=' ' read wintar_hash dummy < <(openssl md5 -r "wintar_tmp/$f") | |
| 64 | 66 | IFS=' ' read cygwintar_hash dummy < <(openssl md5 -r "cygwintar_tmp/$f") | |
| 65 | 67 | ||
| 66 | 68 | if [[ "$wintar_hash" == "$cygwintar_hash" ]] ; then | |
| 67 | 69 | printf $"NOTE:\tHashes for file %q OK\n" "$f" | |
| 68 | 70 | else | |
| 69 | 71 | printf $"ERROR:\tHashes for file %q differ, wintar_hash(%s) != cygwintar_hash(%s)\n" \ | |
| 70 | 72 | "$f" "$wintar_hash" "$cygwintar_hash" | |
| 71 | 73 | (( num_failed_hash_compare++ )) | |
| 72 | 74 | fi | |
| 73 | 75 | done | |
| 74 | 76 | ||
| 75 | 77 | exit $((num_failed_hash_compare > 0?1:0)) | |
| 76 | 78 |
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
nrubsig.kpaste.net RSS