[plt-scheme] Re: how do you include documentation with a teachpack or planet collection?

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Aug 15 01:11:51 EDT 2008

Actually, there might be a way to get what you want (it wasn't clear
if this is what you tried so apologies if you already did).

The first step is to create a post-installer hook -- add a line like
this to your "info.ss":

  (define post-install-collection "post-installer.ss")

Then, the real work happens in that hook -- in the "post-installer.ss"
put something like the following (warning: completely untested
skeleton code...), which creates a stub file that reprovides the
teachpack from planet:

  --------------------------------------------------------------------
  #lang scheme/base
  (provide post-installer)

  ;; the filename for your teachpack
  (define tp-name "my-teachpack.ss")
  ;; the require spec for your package
  (define tp-req '(planet foo/bar))

  (require scheme/path)
  (define tp-dir (build-path (find-system-path 'addon-dir)
                             (version) "collects" "installed-teachpacks"))
  (define tp-path (build-path tp-dir tp-name))

  (define (post-installer plt-home)
    ;; a stub file that provides everything from the planet package
    (define stub-file
      (format ";; stub for ~s\n#lang scheme/base\n(require ~s)\n"
              tp-req tp-req))
    ;; create the directory if it's not there
    (make-directory* tp-dir)
    (let ([existing
           (and (file-exists? tp-path)
                (with-input-from-file tp-path
                  (lambda () (read-string (string-length stub-file)))))])
      (cond [(not existing)
             ;; the file is not there, write it
             (with-output-to-file tp-path (lambda () (display stub-file)))]
            [(not (equal? stub-file existing))
             ;; the file is there, but has different contents
             (some-gui-warning
              "The ~a teachpack was not added because blah blah blah"
              tp-name)]
            ;; otherwise there is nothing to do -- the file is there,
            ;; and has our contents, probably from a previous install
            )))
  --------------------------------------------------------------------

Note that this does not check for permissions -- this code happens
after the planet package was installed, so you should be able to write
to the user-specific collection tree.



On Aug 14, Robby Findler wrote:
> No, there isn't a better way than that, I'm sorry to say. And your
> script should probably make sure it has permissions to write to that
> directory or else it will fail for some folks.
> 
> We do plan to go back to something more like the standard file
> dialog for teachpacks and also to emphasize using `require'
> directly, but that's not something we've done yet.
> 
> Robby
> 
> On Thu, Aug 14, 2008 at 9:53 PM, Stephen Bloch <sbloch at adelphi.edu> wrote:
> >
> > Is there a way to control WHERE the package gets unpacked?
> > Ideally, I'd like it to show up in the "installed-teachpacks"
> > directory, rather than (or in addition to) the PLaneT cache
> > directory, so my students only have to type the "(require ...)"
> > thing once, after which they can just use "Add Teachpack".
> >
> > I tried putting a few lines at the end of the module that check in
> > the "installed-teachpacks" directory for a file with the same name
> > as (this-expression-file-name), and if it's not there, copies the
> > current source file to that directory... but there MUST be a
> > better way than that!

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.