tech-pkg archive

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

Re: make mdi and fetch/checksum



On Fri, 11 Jul 2008, Dieter Baron wrote:
> currently, make mdi (the convenience target to compute distinfo)
> downloads the new distfile from every available master site in turn
> and then fails.
> 
>   That is because mk/checksum/checksum fails if no checksum is
> recorded in the distinfo file (with exit code 2, as opposed to exit
> code 1 on checksum mismatch), and that in turn causes mk/fetch/fetch
> to retry with the next master site.

Oh, I thought it did that for me because I have a weird configuration.
If it does the same for others, then I should probably commit my patch
to fix it.  Could you test this patch?

--apb (Alan Barrett)

=== mk/fetch/fetch
==================================================================
--- mk/fetch/fetch      (revision 921)
+++ mk/fetch/fetch      (revision 922)
@@ -200,14 +200,19 @@
        _file="${1#./}"
        ${TEST} -f $_file || return 1
        if ${TEST} -n "$checksum"; then
-               ${CHECKSUM} -s ".pkgsrc.resume" $distinfo ${_file} || return 1
-               return 0
-       elif ${TEST} -n "$distsize"; then
+               ${CHECKSUM} -s ".pkgsrc.resume" $distinfo ${_file}
+               case $? in
+               0) return 0 ;; # Checksum is correct
+               2) ;; # Missing checksum in distinfo file (fallthrough)
+               *) return 1 ;; # Incorrect checksum, or other error
+               esac
+       fi
+       if ${TEST} -n "$distsize"; then
                _size=`${WC} -c < $_file`
                ${TEST} "$_size" -eq "$distsize" || return 1
                return 0
        fi
-       return 0;
+       return 0; # Neither checksum nor size was available to be checked
 }
 
 # If the file already exists and it verifies, then we don't need to fetch


Home | Main Index | Thread Index | Old Index