pack native-library packages as 'binary instead of 'built

Otherwise, a distribution and/or installation ends up with two copies
of the native library. This change is needed because
http://pkgs.racket-lang.org/ now has a "source" variant of each
native-library package.

More generally, use the `distribution-preference` value in a
package's "info.rkt", where the default is 'binary for a
native-library package because it has only "info.rkt" sources.
This commit is contained in:
Matthew Flatt 2014-12-05 16:53:28 -07:00
parent 7e93502014
commit a2a59d942c
3 changed files with 41 additions and 29 deletions

View File

@ -2,7 +2,7 @@
(define collection "distro-build") (define collection "distro-build")
(define deps '("base" (define deps '(["base" #:version "6.1.1.6"]
"distro-build-client" "distro-build-client"
"web-server-lib" "web-server-lib"
"ds-store-lib" "ds-store-lib"

View File

@ -7,7 +7,8 @@
racket/file racket/file
racket/path racket/path
openssl/sha1 openssl/sha1
racket/cmdline) racket/cmdline
setup/getinfo)
(module test racket/base) (module test racket/base)
@ -23,7 +24,6 @@
(define build-dir "build") (define build-dir "build")
(define dest-dir (build-path build-dir (~a create-mode))) (define dest-dir (build-path build-dir (~a create-mode)))
(define native-dir (build-path build-dir "native" "pkgs"))
(define pkg-dest-dir (path->complete-path (build-path dest-dir "pkgs"))) (define pkg-dest-dir (path->complete-path (build-path dest-dir "pkgs")))
(define catalog-dir (build-path dest-dir "catalog")) (define catalog-dir (build-path dest-dir "catalog"))
(define catalog-pkg-dir (build-path catalog-dir "pkg")) (define catalog-pkg-dir (build-path catalog-dir "pkg"))
@ -32,28 +32,41 @@
(define pkg-details (call-with-input-file* pkg-info-file read)) (define pkg-details (call-with-input-file* pkg-info-file read))
(define pkg-cache (make-hash))
(define (prefer-binary? pkg)
(define dir (pkg-directory pkg #:cache pkg-cache))
(define i (get-info/full dir))
(define mode (and i (i 'distribution-preference (lambda () #f))))
(or (eq? mode 'binary)
;; Any ".rkt" or ".scrbl" other than "info.rkt"?
(not (for/or ([f (in-directory dir)])
(and (regexp-match? #rx"[.](scrbl|rkt)$" f)
(not (let-values ([(base name dir?) (split-path f)])
(equal? #"info.rkt" (path->bytes name)))))))))
(for ([pkg (in-list (installed-pkg-names))]) (for ([pkg (in-list (installed-pkg-names))])
(define native-zip (build-path native-dir (path-add-suffix pkg ".zip"))) (define ht (hash-ref pkg-details pkg (hash)))
(unless (file-exists? native-zip) (define dest-zip (build-path pkg-dest-dir (~a pkg ".zip")))
(define ht (hash-ref pkg-details pkg (hash))) (pkg-create 'zip pkg
(define dest-zip (build-path pkg-dest-dir (~a pkg ".zip"))) #:source 'name
(pkg-create 'zip pkg #:dest pkg-dest-dir
#:source 'name #:mode (if (prefer-binary? pkg)
#:dest pkg-dest-dir 'binary
#:mode create-mode) create-mode))
(call-with-output-file* (call-with-output-file*
(build-path catalog-pkg-dir pkg) (build-path catalog-pkg-dir pkg)
#:exists 'truncate #:exists 'truncate
(lambda (o) (lambda (o)
(write (hash 'source (path->string (find-relative-path (write (hash 'source (path->string (find-relative-path
(simple-form-path catalog-dir) (simple-form-path catalog-dir)
(simple-form-path dest-zip))) (simple-form-path dest-zip)))
'checksum (call-with-input-file* dest-zip sha1) 'checksum (call-with-input-file* dest-zip sha1)
'name pkg 'name pkg
'author (hash-ref ht 'author "plt@racket-lang.org") 'author (hash-ref ht 'author "plt@racket-lang.org")
'description (hash-ref ht 'author "library") 'description (hash-ref ht 'author "library")
'tags (hash-ref ht 'tags '()) 'tags (hash-ref ht 'tags '())
'dependencies (hash-ref ht 'dependencies '()) 'dependencies (hash-ref ht 'dependencies '())
'modules (hash-ref ht 'modules '())) 'modules (hash-ref ht 'modules '()))
o) o)
(newline o))))) (newline o))))

View File

@ -42,9 +42,8 @@
(define build-dir (path->complete-path "build")) (define build-dir (path->complete-path "build"))
(define built-dir (build-path build-dir from-dir)) (define built-dir (build-path build-dir from-dir))
(define native-dir (build-path build-dir "native"))
(define dirs (list built-dir native-dir)) (define dirs (list built-dir))
(define (pkg-name->info req name) (define (pkg-name->info req name)
(for/or ([d (in-list dirs)]) (for/or ([d (in-list dirs)])