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

Re: Using Config::Model to compare files



On Sat, Jul 7, 2012 at 2:15 PM, Dominique Dumont <dod@debian.org> wrote:
> 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)

I think we need something more elaborate. I'm not sure if cme could
handle this or a new executable on top of config::model would be in
order, but here is my idea of how a specific copyright file comparer
would work:

Read copyright file 1 and parse it
Read copyright file 2 and parse it
Walk the directory tree and for each file, compare the license from
file 1 and file 2.

Maybe config model is not the right tool for this. The copyright file
cannot be understood on its own: the source tree is needed to
determine the copyright file's meaning. I believe this is not the
usual thing for configuration files.


-- 

Saludos,
Felipe Sateler


Reply to: