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 17:05
raw | new post
modification of post by Anonymous (view diff)

  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. # - Genreate test tar.bz2 files like this:
  14. # $ seq 1000000 >10000seq.txt ; tar -cvf - 10000seq.txt | bzip2 -9 >10000seq.tar.bz2
  15. # - Compare individual files with
  16. # $ diff -u <(od -x -v cygwintar/bin/ksh93.exe) <(od -x -v wintar/bin/ksh93.exe)
  17. #
  18.  
  19. export PATH='/bin:/usr/bin'
  20.  
  21. # set umask=0000 to avoid permission madness on SMB
  22. umask 0000
  23.  
  24. typeset intarfile="$1"
  25. typeset f
  26. typeset -i num_failed_hash_compare=0
  27.  
  28. if [[ ! -x '/cygdrive/c/Windows/system32/tar' ]] ; then
  29.         printf $"%s: %s not found.\n" \
  30.                 "$0" '/cygdrive/c/Windows/system32/tar' 1>&2
  31.         exit 1
  32. fi
  33.  
  34. if [[ ! -r "$intarfile" ]] ; then
  35.         printf $"%s: Input file %q not readable.\n" \
  36.                 "$0" "$intarfile" 1>&2
  37.         exit 1
  38. fi
  39.  
  40. typeset IFS=$'\n'
  41.  
  42. set -o xtrace
  43. set -o errexit
  44.  
  45. intarfile="$(realpath "$intarfile")"
  46.  
  47. rm -Rf 'wintar_tmp' 'cygwintar_tmp'
  48. mkdir 'wintar_tmp' 'cygwintar_tmp'
  49.  
  50. cd 'wintar_tmp'
  51. /cygdrive/c/Windows/system32/tar -xvf "$(cygpath -w "$intarfile")"
  52. cd '..'
  53.  
  54. cd 'cygwintar_tmp'
  55. /usr/bin/tar -xvf "$intarfile"
  56. cd '..'
  57.  
  58. typeset -a file_list=(
  59.         $(cd 'cygwintar_tmp' && find . -type f)
  60. )
  61.  
  62. set +o xtrace +o errexit
  63.  
  64. for f in "${file_list[@]}" ; do
  65.         IFS=' ' read wintar_hash dummy < <(openssl md5 -r "wintar_tmp/$f")
  66.         IFS=' ' read cygwintar_hash dummy < <(openssl md5 -r "cygwintar_tmp/$f")
  67.  
  68.         if [[ "$wintar_hash" == "$cygwintar_hash" ]] ; then
  69.                 printf $"NOTE:\tHashes for file %q OK\n" "$f"
  70.         else
  71.                 printf $"ERROR:\tHashes for file %q differ, wintar_hash(%s) != cygwintar_hash(%s)\n" \
  72.                         "$f" "$wintar_hash" "$cygwintar_hash"
  73.                 (( num_failed_hash_compare++ ))
  74.         fi
  75. done
  76.  
  77. 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