www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

readme.rkt (6628B)


      1 #lang at-exp racket/base
      2 (require racket/format
      3          net/url
      4          (only-in "config.rkt" current-stamp))
      5 
      6 (provide make-readme
      7          make-source-notes
      8          make-macosx-notes
      9          readme-system-type)
     10 
     11 (define (maybe-stamp config)
     12   (if (hash-ref config '#:release? #f)
     13       ""
     14       @~a{ (@(current-stamp))}))
     15 
     16 (define (make-readme config)
     17   @~a{
     18       The Racket Programming Language
     19       ===============================
     20 
     21       This is the
     22         @|(drop-sort-annotations (hash-ref config '#:name "Racket"))|
     23       distribution for version @(version)@(maybe-stamp config).@;
     24 
     25       @(if (let ([src? (hash-ref config '#:source? #f)])
     26              (or (hash-ref config '#:source-runtime? src?)
     27                  (hash-ref config '#:source-pkgs? src?)))
     28            (string-append "\n" (make-source-notes config) "\n")
     29            "")@;
     30       @(if (and (not (hash-ref config '#:source-runtime? 
     31                                (hash-ref config '#:source? #f)))
     32                 (eq? (readme-system-type config) 'macosx))
     33            (string-append "\n" (make-macosx-notes config) "\n")
     34            "")@;
     35       @(let* ([catalogs (filter
     36                          (lambda (s) (not (equal? s "")))
     37                          (or (hash-ref config '#:dist-catalogs #f)
     38                              (let ([v (hash-ref config '#:dist-base-url #f)])
     39                                (and v
     40                                     (list (url->string
     41                                            (combine-url/relative (string->url v) "catalog/")))))
     42                              null))]
     43               [s (if (= 1 (length catalogs)) "" "s")]
     44               [is (if (= 1 (length catalogs)) "is" "are")])
     45          (if (null? catalogs)
     46              ""
     47              @~a{
     48 
     49                  The distribution has been configured so that when you install or
     50                  update packages, the package catalog@|s| at@;
     51                  @(apply ~a (for/list ([catalog (in-list catalogs)])
     52                               @~a{@"\n"  @|catalog|}))
     53                  @|is| consulted first.
     54 
     55                 }))@;
     56       @(let* ([name (hash-ref config '#:install-name "")])
     57          (if (or (equal? name "")
     58                  (equal? name (version)))
     59              ""
     60              @~a{
     61 
     62                  The distribution has been configured so that the installation
     63                  name is
     64                    @name
     65                  Multiple installations with this name share `user'-scoped packages,
     66                  which makes it easier to upgrade from such an installation to this one.
     67                  To avoid sharing (which is better for keeping multiple installations
     68                  active) use `raco pkg config -i --set name ...' to choose a different
     69                  name for this installation.
     70 
     71                 }))@;
     72      
     73       Visit http://racket-lang.org/ for more Racket resources.
     74      
     75      
     76       License
     77       -------
     78      
     79       Racket
     80       Copyright (c) 2010-2016 PLT Design Inc.
     81      
     82       Racket is distributed under the GNU Lesser General Public License
     83       (LGPL).  This means that you can link Racket into proprietary
     84       applications, provided you follow the rules stated in the LGPL.  You can
     85       also modify Racket; if you distribute a modified version, you must
     86       distribute it under the terms of the LGPL, which in particular means
     87       that you must release the source code for the modified software.  See
     88       share/COPYING_LESSER.txt for more information.})
     89 
     90 (define (drop-sort-annotations s)
     91   ;; Any number of spaces is allowed around "{...}" and "|",
     92   ;; so normalize that space while also removing "{...}":
     93   (regexp-replace* #rx" *[|] *"
     94                    (regexp-replace* #rx" *{[^}]*} *" s "")
     95                    " | "))
     96 
     97 (define (make-source-notes config)
     98   (define src? (hash-ref config '#:source? #f))
     99   (define rt-src
    100     @~a{This distribution provides source for the Racket run-time system;
    101         for build and installation instructions, see "src/README".})
    102   (define pkg-src
    103     @~a{(The distribution also includes the core Racket collections and any
    104         installed packages in source form.)})
    105   (define pkg-built
    106     @~a{Besides the run-time system's source, the distribution provides
    107         pre-built versions of the core Racket bytecode, as well as pre-built
    108         versions of included packages and documentation --- which makes it
    109         suitable for quick installation on a Unix platform for which
    110         executable binaries are not already provided.})
    111   (cond
    112    [(and (hash-ref config '#:source-runtime? src?)
    113          (not (hash-ref config '#:source-pkgs? src?)))
    114     (~a rt-src "\n" pkg-built)]
    115    [(and (hash-ref config '#:source-runtime? src?)
    116          (hash-ref config '#:source-pkgs? src?))
    117     (~a rt-src "\n" pkg-src)]
    118    [else
    119     @~a{The distribution includes any pre-installed packages in source form.}]))
    120 
    121 (define (make-macosx-notes config)
    122   (define vers-suffix
    123     (if (hash-ref config '#:versionless? #f)
    124         ""
    125         @~a{ v@(version)}))
    126   (if (hash-ref config '#:mac-pkg? #f)
    127       @~a{The installation directory is
    128             /Applications/@(string-append
    129                             (hash-ref config '#:dist-name "Racket")
    130                             (if (hash-ref config '#:release? #f)
    131                                 ""
    132                                 vers-suffix))
    133           The installer also adjusts "/etc/paths.d/racket" to point to that
    134           directory's "bin" directory, which adjusts the default PATH
    135           environment variable for all users.}
    136       @~a{Install by dragging the enclosing
    137             @|(hash-ref config '#:dist-name "Racket")|@|vers-suffix|
    138           folder to your Applications folder --- or wherever you like. You can
    139           move the folder at any time, but do not move applications or other
    140           files within the folder. If you want to use the Racket command-line
    141           programs, then (optionally) add the path of the "bin" subdirectory to
    142           your PATH environment variable.}))
    143 
    144 (define (readme-system-type config)
    145   (or (hash-ref config '#:cross-platform #f)
    146       (let ([c (hash-ref config '#:cross-target #f)])
    147         (or (and c
    148                  (cond
    149                   [(regexp-match? #rx"mingw" c)
    150                    'windows]
    151                   [(regexp-match? #rx"darwin" c)
    152                    'macosx]
    153                   [(regexp-match? #rx"linux" c)
    154                    'unix]
    155                   [else
    156                    #f]))
    157             (let ([p (hash-ref config '#:platform (system-type))])
    158               (if (eq? p 'windows/bash)
    159                   'windows
    160                   p))))))