commit a2a59d942cb7fe9cee765920b8fb679973a0319d
parent 7e935020140cf99f4ad9576509f64451ba42a172
Author: Matthew Flatt <mflatt@racket-lang.org>
Date: Fri, 5 Dec 2014 16:53:28 -0700
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.
Diffstat:
3 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/distro-build-server/info.rkt b/distro-build-server/info.rkt
@@ -2,7 +2,7 @@
(define collection "distro-build")
-(define deps '("base"
+(define deps '(["base" #:version "6.1.1.6"]
"distro-build-client"
"web-server-lib"
"ds-store-lib"
diff --git a/distro-build-server/pack-built.rkt b/distro-build-server/pack-built.rkt
@@ -7,7 +7,8 @@
racket/file
racket/path
openssl/sha1
- racket/cmdline)
+ racket/cmdline
+ setup/getinfo)
(module test racket/base)
@@ -23,7 +24,6 @@
(define build-dir "build")
(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 catalog-dir (build-path dest-dir "catalog"))
(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-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))])
- (define native-zip (build-path native-dir (path-add-suffix pkg ".zip")))
- (unless (file-exists? native-zip)
- (define ht (hash-ref pkg-details pkg (hash)))
- (define dest-zip (build-path pkg-dest-dir (~a pkg ".zip")))
- (pkg-create 'zip pkg
- #:source 'name
- #:dest pkg-dest-dir
- #:mode create-mode)
- (call-with-output-file*
- (build-path catalog-pkg-dir pkg)
- #:exists 'truncate
- (lambda (o)
- (write (hash 'source (path->string (find-relative-path
- (simple-form-path catalog-dir)
- (simple-form-path dest-zip)))
- 'checksum (call-with-input-file* dest-zip sha1)
- 'name pkg
- 'author (hash-ref ht 'author "plt@racket-lang.org")
- 'description (hash-ref ht 'author "library")
- 'tags (hash-ref ht 'tags '())
- 'dependencies (hash-ref ht 'dependencies '())
- 'modules (hash-ref ht 'modules '()))
- o)
- (newline o)))))
+ (define ht (hash-ref pkg-details pkg (hash)))
+ (define dest-zip (build-path pkg-dest-dir (~a pkg ".zip")))
+ (pkg-create 'zip pkg
+ #:source 'name
+ #:dest pkg-dest-dir
+ #:mode (if (prefer-binary? pkg)
+ 'binary
+ create-mode))
+ (call-with-output-file*
+ (build-path catalog-pkg-dir pkg)
+ #:exists 'truncate
+ (lambda (o)
+ (write (hash 'source (path->string (find-relative-path
+ (simple-form-path catalog-dir)
+ (simple-form-path dest-zip)))
+ 'checksum (call-with-input-file* dest-zip sha1)
+ 'name pkg
+ 'author (hash-ref ht 'author "plt@racket-lang.org")
+ 'description (hash-ref ht 'author "library")
+ 'tags (hash-ref ht 'tags '())
+ 'dependencies (hash-ref ht 'dependencies '())
+ 'modules (hash-ref ht 'modules '()))
+ o)
+ (newline o))))
diff --git a/distro-build-server/serve-catalog.rkt b/distro-build-server/serve-catalog.rkt
@@ -42,9 +42,8 @@
(define build-dir (path->complete-path "build"))
(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)
(for/or ([d (in-list dirs)])