pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


wintartest001.bash - /cygdrive/c/Windows/system32/tar filesystem test
Posted by Anonymous on Tue 12th Nov 2024 16:23
raw | new post
view followups (newest first): wintartest001.bash - /cygdrive/c/Windows/system32/tar filesystem test by Anonymous

  1. #!/bin/bash
  2.  
  3. #
  4. # wintartest001.bash - /cygdrive/c/Windows/system32/tar filesystem test
  5. # which compares files unpacked by /cygdrive/c/Windows/system32/tar
  6. # and /usr/bin/tar, and checks whether files have same hashes
  7. #
  8. # Written by Roland Mainz <roland.mainz@nrubsig.org>
  9. #
  10.  
  11. #
  12. # Notes:
  13. # - Compare individual files with
  14. # $ diff -u <(od -x -v cygwintar/bin/ksh93.exe) <(od -x -v wintar/bin/ksh93.exe)
  15. #
  16.  
  17. export PATH='/bin:/usr/bin'
  18.  
  19. # set umask=0000 to avoid permission madness on SMB
  20. umask 0000
  21.  
  22. typeset intarfile="$1"
  23. typeset f
  24. typeset -i num_failed_hash_compare=0
  25.  
  26. if [[ ! -x '/cygdrive/c/Windows/system32/tar' ]] ; then
  27.         printf $"%s: %s not found.\n" \
  28.                 "$0" '/cygdrive/c/Windows/system32/tar' 1>&2
  29.         exit 1
  30. fi
  31.  
  32. if [[ ! -r "$intarfile" ]] ; then
  33.         printf $"%s: Input file %q not readable.\n" \
  34.                 "$0" "$intarfile" 1>&2
  35.         exit 1
  36. fi
  37.  
  38. typeset IFS=$'\n'
  39.  
  40. set -o xtrace
  41. set -o errexit
  42.  
  43. intarfile="$(realpath "$intarfile")"
  44.  
  45. rm -Rf 'wintar_tmp' 'cygwintar_tmp'
  46. mkdir 'wintar_tmp' 'cygwintar_tmp'
  47.  
  48. cd 'wintar_tmp'
  49. /cygdrive/c/Windows/system32/tar -xvf "$(cygpath -w "$intarfile")"
  50. cd '..'
  51.  
  52. cd 'cygwintar_tmp'
  53. /usr/bin/tar -xvf "$intarfile"
  54. cd '..'
  55.  
  56. typeset -a file_list=(
  57.         $(cd 'cygwintar_tmp' && find . -type f)
  58. )
  59.  
  60. set +o xtrace +o errexit
  61.  
  62. for f in "${file_list[@]}" ; do
  63.         IFS=' ' read wintar_hash dummy < <(openssl md5 -r "wintar_tmp/$f")
  64.         IFS=' ' read cygwintar_hash dummy < <(openssl md5 -r "cygwintar_tmp/$f")
  65.  
  66.         if [[ "$wintar_hash" == "$cygwintar_hash" ]] ; then
  67.                 printf $"NOTE:\tHashes for file %q OK\n" "$f"
  68.         else
  69.                 printf $"ERROR:\tHashes for file %q differ, wintar_hash(%s) != cygwintar_hash(%s)\n" \
  70.                         "$f" "$wintar_hash" "$cygwintar_hash"
  71.                 (( num_failed_hash_compare++ ))
  72.         fi
  73. done
  74.  
  75. exit $((num_failed_hash_compare > 0?1:0))

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at