From fb915825e9c8c67943cee542a196ac27a3f0a300 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 5 Feb 2013 07:24:25 -0700 Subject: [PATCH] Allowing PNR to decide which github checksum is used --- collects/planet2/lib.rkt | 19 +++++++++++++------ collects/tests/planet2/tests-network.rkt | 18 +++++++++++++++++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/collects/planet2/lib.rkt b/collects/planet2/lib.rkt index d5404f35b8..8aa4b352ec 100644 --- a/collects/planet2/lib.rkt +++ b/collects/planet2/lib.rkt @@ -398,7 +398,10 @@ #: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 + #:given-checksum [given-checksum #f]) (define-values (inferred-pkg-name type) (if (path? pkg) (package-source->name+type (path->string pkg) @@ -428,16 +431,19 @@ (update-install-info-orig-pkg (match type ['github + (when given-checksum + (set! checksum given-checksum)) (unless checksum - (pkg-error (~a "could not find checksum for github package source, which implies it doesn't exist\n" - " source: ~a") - pkg)) + (pkg-error + (~a "could not find checksum for github package source, which implies it doesn't exist\n" + " source: ~a") + pkg)) (match-define (list* user repo branch path) (map path/param-path (url-path/no-slash pkg-url))) (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 +650,8 @@ (define checksum (hash-ref index-info 'checksum)) (define info (install-package source #f - pkg-name)) + pkg-name + #:given-checksum checksum)) (when (and (install-info-checksum info) check-sums? (not (equal? (install-info-checksum info) checksum))) diff --git a/collects/tests/planet2/tests-network.rkt b/collects/tests/planet2/tests-network.rkt index 6c618f5e40..094f850637 100644 --- a/collects/tests/planet2/tests-network.rkt +++ b/collects/tests/planet2/tests-network.rkt @@ -20,4 +20,20 @@ (shelly-install "remote/github with slash" "github://github.com/jeapostrophe/galaxy/master/tests/planet2/test-pkgs/planet2-test1/") (shelly-install "remote/github with auto prefix" - "--type github jeapostrophe/galaxy/master/tests/planet2/test-pkgs/planet2-test1/"))) + "--type github jeapostrophe/galaxy/master/tests/planet2/test-pkgs/planet2-test1/") + + (hash-set! *index-ht-1* "planet2-test1-github-different-checksum" + (hasheq 'checksum + "23eeaee731e72a39bddbacdf1ed6cce3bcf423a5" + 'source + "github://github.com/jeapostrophe/galaxy/master/tests/planet2/test-pkgs/planet2-test1/")) + + (with-fake-root + (shelly-case + "remote/name package" + $ "raco pkg config --set indexes http://localhost:9990" + $ "racket -e '(require planet2-test1)'" =exit> 1 + $ "raco pkg install planet2-test1-github-different-checksum" + $ "racket -e '(require planet2-test1)'" + $ "raco pkg remove planet2-test1-github-different-checksum" + $ "racket -e '(require planet2-test1)'" =exit> 1))))