fix some absolute paths in an in-place build

This commit is contained in:
Matthew Flatt 2013-07-08 19:27:55 -06:00
parent 301bdf9764
commit 267ba4c72b
5 changed files with 32 additions and 15 deletions

View File

@ -582,7 +582,7 @@
(match-define (pkg-info orig-pkg checksum _) info) (match-define (pkg-info orig-pkg checksum _) info)
(match orig-pkg (match orig-pkg
[`(,(or 'link 'static-link) ,orig-pkg-dir) [`(,(or 'link 'static-link) ,orig-pkg-dir)
orig-pkg-dir] (path->complete-path orig-pkg-dir (pkg-installed-dir))]
[_ [_
(build-path (pkg-installed-dir) pkg-name)])))) (build-path (pkg-installed-dir) pkg-name)]))))
@ -961,7 +961,10 @@
[(or (eq? type 'link) [(or (eq? type 'link)
(eq? type 'static-link)) (eq? type 'static-link))
(install-info pkg-name (install-info pkg-name
`(,type ,(simple-form-path* pkg)) `(,type ,(path->string
(find-relative-path (pkg-installed-dir)
(simple-form-path pkg)
#:more-than-root? #t)))
pkg pkg
#f #f #f #f
(directory->module-paths pkg pkg-name metadata-ns))] (directory->module-paths pkg pkg-name metadata-ns))]

View File

@ -115,6 +115,7 @@
(and i (sc-pkg-info? i) (sc-pkg-info-collect i)))))] (and i (sc-pkg-info? i) (sc-pkg-info-collect i)))))]
[else [else
;; Maybe it's a linked package ;; Maybe it's a linked package
(define pkgs-dir (get-pkgs-dir scope))
(for/fold ([pkg #f] [subpath #f] [collect #f]) (for/fold ([pkg #f] [subpath #f] [collect #f])
([(k v) (in-hash (read-pkg-db/cached))] ([(k v) (in-hash (read-pkg-db/cached))]
#:when (not pkg)) #:when (not pkg))
@ -122,7 +123,7 @@
(if (and (pair? orig) (if (and (pair? orig)
(or (eq? 'link (car orig)) (or (eq? 'link (car orig))
(eq? 'static-link (car orig)))) (eq? 'static-link (car orig))))
(let ([orig-pkg-dir (cadr orig)]) (let ([orig-pkg-dir (simplify-path (path->complete-path (cadr orig) pkgs-dir) #f)])
(define e (explode orig-pkg-dir)) (define e (explode orig-pkg-dir))
(if (sub-path? <= p e) (if (sub-path? <= p e)
(values k (values k

View File

@ -9,7 +9,7 @@
;; "config" ;; "config"
(define config-dir (define config-dir
(delay (complete-path (find-system-path 'config-dir)))) (delay (complete-path-from-exe (find-system-path 'config-dir))))
(define (find-config-dir) (define (find-config-dir)
(force config-dir)) (force config-dir))
@ -39,6 +39,13 @@
[else l])) [else l]))
(define (complete-path p) (define (complete-path p)
(cond [(complete-path? p) p]
[else
(path->complete-path
p
(find-main-collects))]))
(define (complete-path-from-exe p)
(cond [(complete-path? p) p] (cond [(complete-path? p) p]
[(absolute-path? p) (exe-relative p)] [(absolute-path? p) (exe-relative p)]
[else [else

View File

@ -964,9 +964,8 @@
(if (eq? (car p) 'info) (if (eq? (car p) 'info)
(info-relative->path p) (info-relative->path p)
(main-lib-relative->path p))) (main-lib-relative->path p)))
(and (complete-path? p)
;; `c' must be `(lib ...)' ;; `c' must be `(lib ...)'
(list? c) (and (list? c)
(pair? c) (pair? c)
(eq? 'lib (car c)) (eq? 'lib (car c))
(pair? (cdr c)) (pair? (cdr c))
@ -1031,7 +1030,10 @@
;; Try relative to `lib': ;; Try relative to `lib':
(let ([p (path->main-lib-relative (cc-path cc))]) (let ([p (path->main-lib-relative (cc-path cc))])
(if (path? p) (if (path? p)
(path->bytes p) ;; Fall back to relative (with ".."s) to info root:
(path->bytes (find-relative-path (cc-info-root cc)
p
#:more-than-root? #t))
p))] p))]
[else (path->bytes (cc-path cc))]) [else (path->bytes (cc-path cc))])
(cons (domain) (cc-shadowing-policy cc))))) (cons (domain) (cc-shadowing-policy cc)))))

View File

@ -10,7 +10,8 @@
(define config-dir-path (build-path "racket" "etc")) (define config-dir-path (build-path "racket" "etc"))
(define config-file-path (build-path config-dir-path "config.rktd")) (define config-file-path (build-path config-dir-path "config.rktd"))
(define devel-pkgs-dir (build-path "racket" "lib" "devel-pkgs")) (define devel-pkgs-rel-dir (build-path "devel-pkgs"))
(define devel-pkgs-dir (build-path "racket" "lib" devel-pkgs-rel-dir))
(define only-platform? #f) (define only-platform? #f)
(define sticky? #f) (define sticky? #f)
@ -61,19 +62,20 @@
(newline o))))) (newline o)))))
(define devel-pkgs-bytes (define devel-pkgs-bytes
(path->bytes (path->complete-path devel-pkgs-dir))) (path->bytes (build-path 'up devel-pkgs-rel-dir)))
(define devel-links-bytes (define devel-links-bytes
(path->bytes (path->complete-path (build-path devel-pkgs-dir "links.rktd")))) (path->bytes (build-path 'up devel-pkgs-rel-dir "links.rktd")))
(when (file-exists? config-file-path) (when (file-exists? config-file-path)
(call-with-input-file* (call-with-input-file*
config-file-path config-file-path
(lambda (i) (lambda (i)
(define r (read i)) (define r (read i))
(define (check what id bytes) (define (check what id bytes alt-path)
(define l (hash-ref r id #f)) (define l (hash-ref r id #f))
(unless (and (list? l) (unless (and (list? l)
(member bytes l)) (or (member bytes l)
(member (path->bytes (path->complete-path alt-path)) l)))
(error 'link-all (error 'link-all
(~a "config file exists, but does not have a definition of `~a' that includes development ~a\n" (~a "config file exists, but does not have a definition of `~a' that includes development ~a\n"
" config file: ~a\n" " config file: ~a\n"
@ -85,10 +87,12 @@
bytes))) bytes)))
(check "packages" (check "packages"
'pkgs-search-dirs 'pkgs-search-dirs
devel-pkgs-bytes) devel-pkgs-bytes
devel-pkgs-dir)
(check "links" (check "links"
'links-search-files 'links-search-files
devel-links-bytes)))) devel-links-bytes
(build-path devel-pkgs-dir "links.rktd")))))
;; found: maps each available package name to a directory ;; found: maps each available package name to a directory
(define found (make-hash)) (define found (make-hash))