On Thu, Dec 18, 2008 at 05:24:25PM +0800, jklyekai wrote:

> But some file like:
>    grub's splash.xpm.gz 
>       file 8ccd759e9fdb0bbae20aa259e9fe35c536ee8bda 
> chash=ff984d5e01af0caf4252438cccb18ecbb21f21c1 group=sys mode=0644 owner=root 
> path=boot/grub/splash.xpm.gz pkg.csize=47363 pkg.size=47330
> 
> I know  shasunw value 8ccd759e9fdb0bbae20aa259e9fe35c536ee8bda is a file
> name,file's orignal name is splash.xpm.gz .that's to say  splash.xpm.gz
> 's sha1sum is  8ccd759e9fdb0bbae20aa259e9fe35c536ee8bda .Then I get a
> wrong result ,it's not   chash=ff984d5e01af0caf4252438cccb18ecbb21f21c1 .
> So I want to know the detail arithmetic and compute steps. 

I'm not sure I understand your question.  The file hash (8ccd...) can
easily be computed by simply running "digest -a sha1" or "sha1sum" on the
file, which in this case gives precisely that answer.  The compressed hash
(pkg.chash) is computed on the modified gzip-compressed version of the
file.  See src/modules/pkggzip.py in the pkg(5) source base for the code,
but the idea is that the normal gzip header has had its pathname and
timestamp removed or zeroed out, so that the checksum of that compressed
file is the same, regardless of when it was compressed.  When the file was
downloaded, it was cached in /var/pkg/download/8c/cd759e/8ccd... in its
compressed form.  Taking the sha1 hash of that file will give you ff984....

Danek

Reply via email to