5

I'm writing a new formula for Homebrew for some software I maintain and as part of my testing I'd like to ensure that files are only added to the correct places on install and that all files are removed on uninstall.

What's the best way of going about comparing file structures before and after my test installs and uninstalls?

  • Obviously not what you asked for, but still useful for a similar task is 'lsbom'. – Max Ried Feb 18 '12 at 8:24
2

In Terminal I can think of two choice:

  1. ls -R.

  2. tree directory-name/ (after you install it; i.e. brew install tree). The slash at the end preserves the display of special characters in the file the output is saved to.

In both case you redirect the output to a file before and after installation and compare the two files possibly using Apple FileMerge.app shipped with Xcode.

2

I like using "find" and "shasum" for this sort of task. Two different invocations, 1 for the structure, and another for the sha-1's of the files:

find -s /path/to/directory -ls > files-before.txt
find -s /path/to/directory -type f -exec shasum \{} \+ >> files-before.txt

Run your installs/uninstalls, and then use the same process to "files-after.txt". Then

diff files-before.txt files-after.txt
0

Two ways occur to me off the top of my head:

  • fseventer is an app that uses Apple's FSEvents framework to watch the filesytem change live. Be sure to read the warnings and caveats on the developer's website.
  • Make a copy of the relevant directories (to someplace convenient, like your desktop) before performing the action. You can then use FileMerge (comes with the developer utilities) to compare directories.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .