Hi all,

One thing that a few people using `raco pkg` (including myself) have
found is that when you upload a package to pkg.racket-lang.org that's
hosted on github, you can easily get checksum errors.

The checksum mismatch happens when the github HEAD has been updated, but
the checksum on the PNS is out of date. The behavior that I expected was
that `raco pkg` would just download the commit matching the PNS checksum
from github and use that.

Is there any design reason to not do that instead?

Attached is a hackish patch that just demonstrates that this is do-able.
As an example, you can try `raco pkg install sweet-exp`, which will
install commit fbd09b4be38b rather than the current github HEAD.

Cheers,
Asumu
>From b1e89c1b30338d9b6788799c47ccfe247fa592da Mon Sep 17 00:00:00 2001
From: Asumu Takikawa <as...@ccs.neu.edu>
Date: Wed, 30 Jan 2013 17:42:59 -0500
Subject: [PATCH] A hack to make checksums more flexible for github

---
 collects/planet2/lib.rkt |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/collects/planet2/lib.rkt b/collects/planet2/lib.rkt
index d5404f3..699170e 100644
--- a/collects/planet2/lib.rkt
+++ b/collects/planet2/lib.rkt
@@ -398,7 +398,9 @@
          #:force? [force? #f]
          descs)
   (define check-sums? (not ignore-checksums?))
-  (define (install-package pkg given-type given-pkg-name)
+  (define (install-package pkg given-type given-pkg-name
+                           ;; This is hackish, but it demonstrates it works
+                           #:index-checksum [index-checksum #f])
     (define-values (inferred-pkg-name type) 
       (if (path? pkg)
           (package-source->name+type (path->string pkg)
@@ -428,6 +430,7 @@
         (update-install-info-orig-pkg
          (match type
            ['github
+            (set! checksum index-checksum)
             (unless checksum
               (pkg-error (~a "could not find checksum for github package source, which implies it doesn't exist\n"
                              "  source: ~a")
@@ -437,7 +440,7 @@
             (define new-url
               (url "https" #f "github.com" #f #t
                    (map (λ (x) (path/param x empty))
-                        (list user repo "tarball" branch))
+                        (list user repo "tarball" checksum))
                    empty
                    #f))
             (define tmp.tgz
@@ -644,7 +647,8 @@
       (define checksum (hash-ref index-info 'checksum))
       (define info (install-package source
                                     #f
-                                    pkg-name))
+                                    pkg-name
+                                    #:index-checksum checksum))
       (when (and (install-info-checksum info)
                  check-sums?
                  (not (equal? (install-info-checksum info) checksum)))
-- 
1.7.10.4

_________________________
  Racket Developers list:
  http://lists.racket-lang.org/dev

Reply via email to