You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bill Milbratz <mi...@gmail.com> on 2008/02/12 22:18:11 UTC

checksum task: how can you use hash in a separate directory

Hi,

Can anyone comment on the best way to solve this problem with the checksum
task:

I'm looking for a means to do the following:
a) take hash-snapshots of shipped files in a directory (e.g. src/jsp)
b) later, check the files against the hashes
c) ant indicates which files do not match the hash.


I've looked at the checksum documentation and the source code, but don't see
a way I can see which specific files have changed.

Yet, I may be missing something.

thanks,

bill

Re: checksum task: how can you use hash in a separate directory

Posted by Bill Milbratz <mi...@gmail.com>.
hi,

a clarification: my subject line doesn't match the question.

I originally had wondered about using 'todir' as a destination for the
checksum files, but realized I had a more basic question. The body mutated;
the subject did not.

bill

Re: checksum task: how can you use hash in a separate directory

Posted by Martin Ficker <m....@googlemail.com>.
Hi,

pathconvert  can be used to perform "String manipulation" on filesets or
pathes.

The following would echo a linebreak seperated list of the files:

       (append after the  previous example)
        <pathconvert property ="result.prop" refid="result"
pathsep="${line.separator}">
            <globmapper from="${basedir}/checksums/*.MD5"
to="${basedir}/src/*"/>
        </pathconvert>
        <echo>${result.prop}</echo>

For further  manipulation as a fileset you could pathconvert to a comma
seperated list an stuff it back into a fileset.
For example to copy the changed files to backupDir:

        <pathconvert property="backup.prop" refid="result" pathsep=",">
            <globmapper from="${basedir}/checksums/*.MD5" to="*"/>
        </pathconvert>
               
        <copy todir="backupDir">
           <fileset dir="src" includes="${backup.prop}"/>
        </copy>

I don't know of o easier way to convert pathes into filesets.  

Best regards

Martin

Bill Milbratz schrieb:
> Hi all,
>
> Thanks for the resposnes. Martin, that's an elegant example and belongs in
> the ant documentation.
>
> As a follow up to Martin's example:
> once you have the list of 'result" files (which lists all the .md5 files
> which differ), how in ant can you generate a list of the *original* files.
>
> i.e. so you can send a message telling the user that he changed
> 'src/jsp/foo.jsp' and not just that 'checksums/jsp/foo.jsp.md5' doesn't
> match 'newchecksums/jsp/foo.jsp.md5'
> Or better yet, so that your ant target can "act on those changes", i.e. and
> backup src/jsp/foo.jsp before overwriting it....
>
> This may simply be an exercise in string manipulation with Ant or "advanced
> use of filesets",
>
> thanks,
>
> bill
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: checksum task: how can you use hash in a separate directory

Posted by Bill Milbratz <mi...@gmail.com>.
Hi all,

Thanks for the resposnes. Martin, that's an elegant example and belongs in
the ant documentation.

As a follow up to Martin's example:
once you have the list of 'result" files (which lists all the .md5 files
which differ), how in ant can you generate a list of the *original* files.

i.e. so you can send a message telling the user that he changed
'src/jsp/foo.jsp' and not just that 'checksums/jsp/foo.jsp.md5' doesn't
match 'newchecksums/jsp/foo.jsp.md5'
Or better yet, so that your ant target can "act on those changes", i.e. and
backup src/jsp/foo.jsp before overwriting it....

This may simply be an exercise in string manipulation with Ant or "advanced
use of filesets",

thanks,

bill

Re: checksum task: how can you use hash in a separate directory

Posted by Martin Ficker <m....@googlemail.com>.
You could backup the directory with the checksums and later use a
fileset with different selector  to select those
hash file that have changed.
Example:

<project name="test" default="test">
   
    <target name="hash">     
        <checksum todir="checksums">
            <fileset dir="src" includes ="**/*"/>
        </checksum>          
    </target>
      
    <target name = "verify">
        <checksum  todir="newchecksums">
            <fileset dir="src" includes ="**/*"/>       
        </checksum>
       
        <fileset id="result" dir="checksums">
           
            <different targetdir="newchecksums" ignoreFileTimes="true"/>
        </fileset>
        <echo>Changed Files: ${toString:result}</echo>       
    </target>       
</project>

Best regards

Martin

Bill Milbratz schrieb:
> Hi,
>
> Can anyone comment on the best way to solve this problem with the checksum
> task:
>
> I'm looking for a means to do the following:
> a) take hash-snapshots of shipped files in a directory (e.g. src/jsp)
> b) later, check the files against the hashes
> c) ant indicates which files do not match the hash.
>
>
> I've looked at the checksum documentation and the source code, but don't see
> a way I can see which specific files have changed.
>
> Yet, I may be missing something.
>
> thanks,
>
> bill
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org