From 7969eea3a215a5a41b61cc0e83ddc54f226104a2 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Fri, 6 Sep 2013 09:52:08 -0600 Subject: [PATCH] raco pkg install: drop redundant "COPYING.txt" and "COPYING_LESSER.txt" When adding a package installation-wide, drop redundant "COPYING.txt" and "COPYING_LESSER.txt" files (i.e., ones that are the same as the ones the "share" directory of a Racket installation). This rule is ad hoc, but it avoids almost 150 copies of the file in the main distribution. --- racket/collects/pkg/lib.rkt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/racket/collects/pkg/lib.rkt b/racket/collects/pkg/lib.rkt index 20cb2fab72..7214c2eaac 100644 --- a/racket/collects/pkg/lib.rkt +++ b/racket/collects/pkg/lib.rkt @@ -819,6 +819,21 @@ given-checksum checksum))) +(define (drop-redundant-files pkg-dir) + ;; Ad hoc space-saving rule: for an installation-wide package, remove + ;; any redundant "COPYING.txt" or "COPYING_LESSER.txt" files. + (when (and (eq? 'installation (current-pkg-scope)) + (find-share-dir)) + (for ([i (in-list '("COPYING.txt" "COPYING_LESSER.txt"))]) + (define pkg-file (build-path pkg-dir i)) + (define share-file (build-path (find-share-dir) i)) + (when (and (file-exists? pkg-file) + (file-exists? share-file) + (equal? (file->bytes pkg-file) + (file->bytes share-file))) + ;; This file would be redundant, so drop it + (delete-file pkg-file))))) + ;; Downloads a package (if needed) and unpacks it (if needed) into a ;; temporary directory. (define (stage-package/info pkg @@ -1128,6 +1143,9 @@ (make-parent-directory* pkg-dir) (copy-directory/files pkg pkg-dir #:keep-modify-seconds? #t))) pkg-dir))) + (when (or (not in-place?) + in-place-clean?) + (drop-redundant-files pkg-dir)) (install-info pkg-name `(dir ,(simple-form-path* pkg)) pkg-dir