ディレクトリを再帰的に辿り、すべてのファイルにcmpを実行する。ただし、オブジェクトファイルに対してはobjdump -dで逆アセンブルしたものをcmpする。 自分でビルドしたパッケージと公式パッケージの差分の有無を確かめるために作成。 好きに使ってください。

Format
Shell
Post date
2019-05-23 01:57
Zeitraum der Veröffentlichung
Unbegrenzt
  1. #!/bin/sh
  2. diff_recursive(){
  3. local a="$1"
  4. local b="$2"
  5. local f1
  6. if [ -d "$a" ]; then
  7. if [ -d "$b" ]; then
  8. ls "$a" | while read f1; do
  9. if ! [ -e "$b/$f1" ]; then
  10. echo "there is $a/$f1 but no $b/$f1"
  11. else
  12. diff_recursive "$a/$f1" "$b/$f1"
  13. fi
  14. done
  15. else
  16. echo "$a is a directory but $b is not"
  17. fi
  18. elif [ -L "$a" ]; then
  19. if ! [ -L "$b" ]; then
  20. echo "$a is a link buf $b is not"
  21. fi
  22. elif [ -f "$a" ]; then
  23. if [ -f "$b" ]; then
  24. if [ "$(file -b "$a"|head -c 3)" = ELF -a \
  25. "$(file -b "$b"|head -c 3)" = ELF -o \
  26. "$(file -b "$a")" = "current ar archive" -a \
  27. "$(file -b "$b")" = "current ar archive" ]
  28. then
  29. if ! objdump -d "$a" | tail -n +3 | ( exec 3<&0; (objdump -d "$b" | tail -n +3) | cmp -s /dev/fd/0 /dev/fd/4 4<&3 ) ; then
  30. echo "objdiff in $a and $b"
  31. fi
  32. else
  33. if ! cmp -s "$a" "$b"; then
  34. echo "diff in $a and $b"
  35. fi
  36. fi
  37. else
  38. echo "$a is a normal file but $b is not"
  39. fi
  40. else
  41. echo "$a is not supported type"
  42. fi
  43. }
  44. diff_recursive $1 $2
Download Printable view

URL of this paste

Embed with JavaScript

Embed with iframe

Raw text