[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using Config::Model to compare files



Hello

Le Saturday 7 July 2012 02:43:17, vous avez écrit :
> I was wondering if, given that CM can understand config files, if it can be
> used to compare 2 files.
> The use case I'm thinking of is debian/copyright. There is a CDBS routine
> that tries to collect copyright information for the whole package, file by
> file. It would be interesting if cme could compare the two files to see
> what differences apply. Also, it could be applied at different versions of
> the autogenerated file (say, for different upstream releases), to identify
> missing copyright notices.
> 
> Does that sound like something that cme could do?

Sort of. 

I was tempted to use the fusefs interface [1] to mount 2 directories matching copyright contents and use tkdiff to compare. 
Unfortunately, fuse barfs on the file entries containing '/' (which happens quite often).:

$ ll test-cop/Files/
ls: impossible d'accéder à test-cop/Files/debian/*: Aucun fichier ou dossier de ce type
ls: impossible d'accéder à test-cop/Files/examples/lcdproc/LCDd.conf: Aucun fichier ou dossier de ce type
ls: impossible d'accéder à test-cop/Files/lib/Config/Model/models/LCDd*: Aucun fichier ou dossier de ce type
total 512
drwxr-xr-x 1 domi domi 3 juil.  7 20:07 *
?????????? ? ?    ?    ?              ? debian/*
?????????? ? ?    ?    ?              ? examples/lcdproc/LCDd.conf
?????????? ? ?    ?    ?              ? lib/Config/Model/models/LCDd*


Another possibility is to dump debian-copyright content into the internal
tree structure format:

$ cme dump dpkg-copyright 
Upstream-Name=Config-Model
Upstream-Contact="Dominique Dumont <ddumont@cpan.org>"
Source=http://search.cpan.org/dist/Config-Model/
Files:"*"
  Copyright="2005-2012, Dominique Dumont <ddumont@cpan.org>
          2005-2011, Krzysztof Tyszecki"
  License
    short_name=LGPL-2.1+ - -
[etc...]

There one major caveat: Since cme keeps the order of the Files entries, 
you may have different dump content just because the order of the Files 
entries are different.

That said, fixing fuse interface is quite easy: just replace '/' with 
something else ( may be '\' ? ;-) )

Another possibility would be to create a new cme command like to dump a 
diff like string:

  cme-diff dpkg dir1 dir2

but it would be more work (patches welcome)

All the best

Dominique

[1] Here's a similar fuse interface example:
    http://ddumont.wordpress.com/2011/01/30/how-to-configure-openssh-through-a-virtual-filesystem/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: