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.
This commit is contained in:
Matthew Flatt 2015-05-03 17:25:15 -07:00
parent ec0350e6d9
commit 0304fedf92
3 changed files with 57 additions and 21 deletions

View File

@ -193,12 +193,18 @@ After you've built and installed minimal Racket, you could install
packages via the package-catalog server, completely ignoring the packages via the package-catalog server, completely ignoring the
content of "pkgs". content of "pkgs".
If you want to install packages manually out of the "pkgs", the If you want to install packages manually out of the "pkgs" directory,
`local-catalog' target creates a catalog as "racket/local/catalog" that the `local-catalog' target creates a catalog as "racket/local/catalog"
merges the currently configured catalog's content with pointers to the that merges the currently configured catalog's content with pointers
packages in "pkgs". A Unix-style build works that way: it builds and to the packages in "pkgs". A Unix-style build works that way: it
installs minimal Racket, and then it installs packags out of a catalog builds and installs minimal Racket, and then it installs packags out
that is created by `make local-catalog'. 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=<url>
Linking Packages for In-place Development Mode 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. configuration file "racket/etc/config.rktd" exists already.
All other packages (as specified by `PKGS') are installed via the 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 the content of "racket/share/pkgs" is not meant to be edited. To
reinstall a package in a mode suitable for editing and manipulation reinstall a package in a mode suitable for editing and manipulation
with Git tools, use with Git tools, use

View File

@ -32,6 +32,7 @@ WIN32_PLAIN_RACKET = racket\racket
PLAIN_RACO = racket/bin/racket -N raco -l- raco PLAIN_RACO = racket/bin/racket -N raco -l- raco
WIN32_PLAIN_RACO = racket\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_ARGS = -I racket/base -e '(case (system-type) [(macosx) (exit 0)] [else (exit 1)])'
MACOSX_CHECK = $(PLAIN_RACKET) -G build/config $(MACOSX_CHECK_ARGS) MACOSX_CHECK = $(PLAIN_RACKET) -G build/config $(MACOSX_CHECK_ARGS)
@ -112,6 +113,7 @@ cpus-unix-style:
plain-unix-style: plain-unix-style:
if [ "$(PREFIX)" = "" ] ; then $(MAKE) error-need-prefix ; fi if [ "$(PREFIX)" = "" ] ; then $(MAKE) error-need-prefix ; fi
$(MAKE) base CONFIGURE_ARGS_qq='$(CONFIGURE_ARGS_qq) $(CONFIG_PREFIX_ARGS)' $(UNIX_BASE_ARGS) $(MAKE) base CONFIGURE_ARGS_qq='$(CONFIGURE_ARGS_qq) $(CONFIG_PREFIX_ARGS)' $(UNIX_BASE_ARGS)
$(MAKE) set-src-catalog
$(MAKE) local-catalog $(MAKE) local-catalog
"$(DESTDIR)$(PREFIX)/bin/raco" pkg install $(UNIX_RACO_ARGS) $(REQUIRED_PKGS) $(PKGS) "$(DESTDIR)$(PREFIX)/bin/raco" pkg install $(UNIX_RACO_ARGS) $(REQUIRED_PKGS) $(PKGS)
cd racket/src/build; $(MAKE) fix-paths 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/racket" -l- pkg/dirs-catalog --check-metadata $(LOC_CATALOG) pkgs
"$(DESTDIR)$(PREFIX)/bin/raco" pkg catalog-copy --force --from-config $(LOC_CATALOG) $(UNIX_CATALOG) "$(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 # Base build
@ -177,7 +183,7 @@ racket/src/build/Makefile: racket/src/configure racket/src/Makefile.in
# side of its definition. # side of its definition.
# Catalog for package sources: # 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 # A URL embedded in documentation for remote searches, where a Racket
# version and search key are added as query fields to the URL, and "" # 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: pkgs-catalog:
$(PLAIN_RACKET) $(PKGS_CATALOG) racket/share/pkgs-catalog pkgs $(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 $(PLAIN_RACKET) racket/src/pkgs-check.rkt racket/share/pkgs-catalog
win32-pkgs-catalog: win32-pkgs-catalog:

View File

@ -14,10 +14,14 @@
(define catalog-relative-path (build-path 'up "share" "pkgs-catalog")) (define catalog-relative-path (build-path 'up "share" "pkgs-catalog"))
(define catalog-relative-path-str (path->string catalog-relative-path)) (define catalog-relative-path-str (path->string catalog-relative-path))
(command-line (define-values (default-src-catalog src-catalog)
#:args (command-line
() #:args
(void)) (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) (when (file-exists? config-file-path)
(call-with-input-file* (call-with-input-file*
@ -25,16 +29,31 @@
(lambda (i) (lambda (i)
(define r (read i)) (define r (read i))
(define l (hash-ref r 'catalogs #f)) (define l (hash-ref r 'catalogs #f))
(unless (and (list? l) (define starts-as-expected?
((length l) . >= . 1) (and (list? l)
(equal? (car l) catalog-relative-path-str)) ((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 (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" " config file: ~a\n"
" expected initial element: ~s\n" " expected ~acatalog: ~s\n"
" possible solution: delete the config file") " possible solution: delete the config file")
config-file-path (if (not starts-as-expected?)
catalog-relative-path-str))))) "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) (unless (file-exists? config-file-path)
(printf "Writing ~a\n" config-file-path) (printf "Writing ~a\n" config-file-path)
@ -42,7 +61,12 @@
config-file-path config-file-path
(lambda (o) (lambda (o)
(write (hash 'catalogs (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 'installation-name
"development" "development"
'default-scope 'default-scope