From 0304fedf92891817cb4056413eeb25c74d34024e Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 3 May 2015 17:25:15 -0700 Subject: [PATCH] Makefile: make `SRC_CATALOG` work for in-place and unix-style Configure an in-place or unix-style build to use the given SRC_CATALOG before the default catalogs. --- INSTALL.txt | 20 ++++++++++------ Makefile | 10 ++++++-- racket/src/pkgs-config.rkt | 48 ++++++++++++++++++++++++++++---------- 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/INSTALL.txt b/INSTALL.txt index fcaded5282..0569ed2ad9 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -193,12 +193,18 @@ After you've built and installed minimal Racket, you could install packages via the package-catalog server, completely ignoring the content of "pkgs". -If you want to install packages manually out of the "pkgs", the -`local-catalog' target creates a catalog as "racket/local/catalog" that -merges the currently configured catalog's content with pointers to the -packages in "pkgs". A Unix-style build works that way: it builds and -installs minimal Racket, and then it installs packags out of a catalog -that is created by `make local-catalog'. +If you want to install packages manually out of the "pkgs" directory, +the `local-catalog' target creates a catalog as "racket/local/catalog" +that merges the currently configured catalog's content with pointers +to the packages in "pkgs". A Unix-style build works that way: it +builds and installs minimal Racket, and then it installs packags out +of a catalog that is created by `make local-catalog'. + +To add a package catalog that is used after the content of "pkgs" but +before the default package catalogs, specify the catalog's URL as the +`SRC_CATALOG' makefile variable: + + make .... SRC_CATALOG= Linking Packages for In-place Development Mode ---------------------------------------------- @@ -217,7 +223,7 @@ packages. The configuration adjustment is made only if no configuration file "racket/etc/config.rktd" exists already. All other packages (as specified by `PKGS') are installed via the -default package catalog. They are installed in installation scope, but +configured package catalog. They are installed in installation scope, but the content of "racket/share/pkgs" is not meant to be edited. To reinstall a package in a mode suitable for editing and manipulation with Git tools, use diff --git a/Makefile b/Makefile index 4d71a4118c..3d354ec30a 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ WIN32_PLAIN_RACKET = racket\racket PLAIN_RACO = racket/bin/racket -N raco -l- raco WIN32_PLAIN_RACO = racket\racket -N raco -l- raco +DEFAULT_SRC_CATALOG = http://pkgs.racket-lang.org MACOSX_CHECK_ARGS = -I racket/base -e '(case (system-type) [(macosx) (exit 0)] [else (exit 1)])' MACOSX_CHECK = $(PLAIN_RACKET) -G build/config $(MACOSX_CHECK_ARGS) @@ -112,6 +113,7 @@ cpus-unix-style: plain-unix-style: if [ "$(PREFIX)" = "" ] ; then $(MAKE) error-need-prefix ; fi $(MAKE) base CONFIGURE_ARGS_qq='$(CONFIGURE_ARGS_qq) $(CONFIG_PREFIX_ARGS)' $(UNIX_BASE_ARGS) + $(MAKE) set-src-catalog $(MAKE) local-catalog "$(DESTDIR)$(PREFIX)/bin/raco" pkg install $(UNIX_RACO_ARGS) $(REQUIRED_PKGS) $(PKGS) cd racket/src/build; $(MAKE) fix-paths @@ -128,6 +130,10 @@ local-catalog: "$(DESTDIR)$(PREFIX)/bin/racket" -l- pkg/dirs-catalog --check-metadata $(LOC_CATALOG) pkgs "$(DESTDIR)$(PREFIX)/bin/raco" pkg catalog-copy --force --from-config $(LOC_CATALOG) $(UNIX_CATALOG) +set-src-catalog: + if [ ! "$(SRC_CATALOG)" = "$(DEFAULT_SRC_CATALOG)" ] ; \ + then "$(DESTDIR)$(PREFIX)/bin/raco" pkg config -i --set catalogs "$(SRC_CATALOG)" ""; fi + # ------------------------------------------------------------ # Base build @@ -177,7 +183,7 @@ racket/src/build/Makefile: racket/src/configure racket/src/Makefile.in # side of its definition. # Catalog for package sources: -SRC_CATALOG = http://pkgs.racket-lang.org/ +SRC_CATALOG = $(DEFAULT_SRC_CATALOG) # A URL embedded in documentation for remote searches, where a Racket # version and search key are added as query fields to the URL, and "" @@ -318,7 +324,7 @@ PKGS_CONFIG = -U -G build/config racket/src/pkgs-config.rkt pkgs-catalog: $(PLAIN_RACKET) $(PKGS_CATALOG) racket/share/pkgs-catalog pkgs - $(PLAIN_RACKET) $(PKGS_CONFIG) + $(PLAIN_RACKET) $(PKGS_CONFIG) "$(DEFAULT_SRC_CATALOG)" "$(SRC_CATALOG)" $(PLAIN_RACKET) racket/src/pkgs-check.rkt racket/share/pkgs-catalog win32-pkgs-catalog: diff --git a/racket/src/pkgs-config.rkt b/racket/src/pkgs-config.rkt index bd8638854d..d7401fa91b 100644 --- a/racket/src/pkgs-config.rkt +++ b/racket/src/pkgs-config.rkt @@ -14,10 +14,14 @@ (define catalog-relative-path (build-path 'up "share" "pkgs-catalog")) (define catalog-relative-path-str (path->string catalog-relative-path)) -(command-line - #:args - () - (void)) +(define-values (default-src-catalog src-catalog) + (command-line + #:args + (default-src-catalog src-catalog) + (values default-src-catalog src-catalog))) + +(define src-catalog-is-default? + (equal? src-catalog default-src-catalog)) (when (file-exists? config-file-path) (call-with-input-file* @@ -25,16 +29,31 @@ (lambda (i) (define r (read i)) (define l (hash-ref r 'catalogs #f)) - (unless (and (list? l) - ((length l) . >= . 1) - (equal? (car l) catalog-relative-path-str)) + (define starts-as-expected? + (and (list? l) + ((length l) . >= . 1) + (equal? (car l) catalog-relative-path-str))) + (define has-src-catalog? + (member (if src-catalog-is-default? #f src-catalog) + l)) + (unless (and starts-as-expected? + has-src-catalog?) (error 'pkgs-catalog - (~a "config file exists, but does not have a definition of `catalogs' that starts as expected\n" + (~a "config file exists, but with a mismatched `catalogs';\n" + " the existing configuration does not ~a\n" " config file: ~a\n" - " expected initial element: ~s\n" + " expected ~acatalog: ~s\n" " possible solution: delete the config file") - config-file-path - catalog-relative-path-str))))) + (if (not starts-as-expected?) + "start as expected" + "include the specified catalog") + config-file-path + (if (not starts-as-expected?) + "initial " + "") + (if (not starts-as-expected?) + catalog-relative-path-str + src-catalog)))))) (unless (file-exists? config-file-path) (printf "Writing ~a\n" config-file-path) @@ -42,7 +61,12 @@ config-file-path (lambda (o) (write (hash 'catalogs - (list catalog-relative-path-str #f) + (cons catalog-relative-path-str + (append + (if src-catalog-is-default? + '() + (list src-catalog)) + (list #f))) 'installation-name "development" 'default-scope