Skip to content

Instantly share code, notes, and snippets.

@LiberalArtist
Last active December 4, 2021 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiberalArtist/f96fa9fab28c9122631f0d3b1d4f9123 to your computer and use it in GitHub Desktop.
Save LiberalArtist/f96fa9fab28c9122631f0d3b1d4f9123 to your computer and use it in GitHub Desktop.
racket-tethered-apps-dir-demo
/workspace/
/layer/
*~
\#*
.\#*
.DS_Store
compiled/
/doc/

racket-tethered-apps-dir-demo

This is a demonstration of an issue with Racket's config-tethered installations, which are not properly respecting the apps-dir configuration.

Run make and observe that layer/share/applications/ does not contain drracket.desktop (or anything else), even though layer/bin/drracket is installed successfully.

Other than make, the only prerequisite is an existing Racket installation with the raco-cross package installed.

SPDX-License-Identifier: (Apache-2.0 OR MIT)

#lang racket/base
(require racket/runtime-path
racket/match
racket/file
racket/path
racket/list
racket/pretty)
(define (build-path-string . args)
(path->string (apply build-path args)))
(define-runtime-path workspace
"workspace")
(define-runtime-path prefix
"layer")
(define parent-layer
(or (for/first ([pth (in-list (directory-list workspace #:build? #t))]
#:when (directory-exists? pth))
pth)
(error 'extend-layer "workspace not initialized")))
(let* ([config
(for/fold
([config (file->value
(build-path
(let ((dir (find-system-path 'config-dir)))
(if (complete-path? dir)
dir
(build-path (path-only (find-system-path 'exec-file)) dir)))
"config.rktd"))])
([spec (in-list
'((lib-dir lib-search-dirs "lib" "lib/racket")
(share-dir share-search-dirs "share" "share/racket")
(links-file links-search-files "share/links.rktd" "share/racket/links.rktd")
(pkgs-dir pkgs-search-dirs "share/pkgs" "share/racket/pkgs")
(bin-dir bin-search-dirs "bin" #f)
(man-dir man-search-dirs "share/man" #f)
(doc-dir doc-search-dirs "share/doc" "share/doc/racket")
(include-dir include-search-dirs "include" "include/racket")))])
(match-define (list main-key search-key in-place-pth maybe-unix-pth) spec)
(define unix-pth (or maybe-unix-pth in-place-pth))
(hash-set*
config
main-key (build-path-string prefix unix-pth)
search-key (list* #f
(hash-ref config
main-key
(λ ()
(define candidate
(build-path-string parent-layer in-place-pth))
(if (file-or-directory-type candidate)
candidate
(build-path-string parent-layer unix-pth))))
(filter values (hash-ref config search-key null)))))]
[config
(hash-set config
'apps-dir
(build-path-string prefix "share/applications"))]
[bin-dir
(hash-ref config 'bin-dir)]
[config
(hash-set* config
'config-tethered-console-bin-dir bin-dir
'config-tethered-gui-bin-dir bin-dir)]
[new-config-pth
(build-path prefix "etc/racket/config.rktd")])
(make-parent-directory* new-config-pth)
(call-with-output-file* new-config-pth
(λ (out)
(pretty-write config out))))
RACO_CROSS=raco cross --workspace workspace
.PHONY: all
all:
$(RACO_CROSS) --native
$(RACO_CROSS) -- racket extend-layer.rkt
$(RACO_CROSS) -- racket --config layer/etc/racket -l- \
raco pkg install -i --auto drracket
.PHONY: clean
clean:
git clean -xdi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment