On Tue, Aug 02, 2011 at 01:09:38PM +1000, Malcolm Herbert wrote:
| (Apologies if this is not the correct forum - I'm not sure who is
| responsible for mtree)
|
| At the moment, if I merely want to see the differences between two
| directory trees or compare to an mtree spec I can't tell mtree not to
| make any modifications to it. I can tell it not to update permissions
| and attributes with the -W flag, but mtree still insists on creating
| missing directories.
|
| For example, assuming the following directory trees:
|
| new
| new/blah
| new/foo/
| old
| old/bar/
| old/blah
| old/foo/empty
|
| old/blah and new/blah differ in their content, so MD5 checks will fail
|
| If I want to compare these, I'd run the following:
|
| tiu[/data/scratch] 134v>: mtree -c -p old -K md5 | mtree -Wu -p new -K md5
| blah: md5 (0x5149d403009a139c7e085405ef762e1a,
0x3d709e89c8ce201e3c928eb917989aef)
| missing: ./bar (created)
| missing: ./foo/empty
|
| ... but then mtree will have created new/bar for me, as above.
|
| So, can we add a "don't to anything" option to mtree? -n appears to be
| available and would match expected behaviour for other tools ...
Try it without -u in the mtree that you're using to check with.
mtree -c -p old -K md5 | mtree -W -p new -K md5
As an aside, I'd pipe the output of the first mtree through -C -K md5
to convert it to a format that I find saner to use especially
if you're going to save the output of the former or process it
with other tools. E.g,
> mtree -c -p old -K md5 | mtree -C -K md5
. type=dir uid=1001 gid=0 mode=0755 nlink=4 time=1312627733.236059515
flags=none
./blah type=file uid=1001 gid=0 mode=0644 nlink=1 size=4
time=1312627730.115126094 md5=814fa5ca98406a903e22b43d9b610105 flags=none
./bar type=dir uid=1001 gid=0 mode=0755 nlink=2
time=1312627724.939881485 flags=none
./foo type=dir uid=1001 gid=0 mode=0755 nlink=2
time=1312627736.603895490 flags=none
./foo/empty type=file uid=1001 gid=0 mode=0644 nlink=1 size=0
time=1312627736.603862649 md5=d41d8cd98f00b204e9800998ecf8427e flags=none
(You need to pass the same -K flags to the -C invocation otherwise
mtree will strip the keywords :)
cheers,
Luke.
Attachment:
pgpIYZK3vJrtu.pgp
Description: PGP signature