[racket] tips for raco distribution

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Mon Oct 8 00:58:48 EDT 2012

"raco exe" and "raco distribution" just worked well for installing my 
first ``Racket-based appliance''.

The two small problems I had were: (1) the "raco distribute" output tree 
contained paths from "define-runtime-path" that varied based on the 
absolute path of the build directory; and (2) when "define-runtime-path" 
was a directory, I couldn't exclude any files in that directory from 
being included in the distribution.

There might be a better way to do this, but the following Makefile 
worked for me (on GNU/Linux).  It just uses a separate build tree for 
"raco exe" and "raco distribute", controlling what files get into the 
build tree, and keeping the absolute path of the tree constant between 
runs so that the installed tree structure is constant between installs.

NAME        = rackout
MAIN_FILE   = $(NAME).rkt
EXE         = $(MAIN_FILE:.rkt=)
SOURCE_DIR  = $(CURDIR)
DIST_TREE   = dist-tree
BUILD_DIR   = /tmp/$(NAME)-build
BUILD_FILES = dvd-title.rkt \
               info.rkt \
               $(MAIN_FILE) \
               static-files/icons \
               static-files/jquery-1.7.1.min.js \
               static-files/jquery.mobile-1.1.1 \
               static-files/rackout.css \
               static-files/rackout.js
TEST_HOST   = rackout.lan

.PHONY:: help
help:
         @echo ""
         @echo "dist-tree       - Build a standalone RackOut dist-tree."
         @echo "update-test-box - Install dist-tree on \"$(TEST_HOST)\"."
         @echo "clean           - Clean temporary files and directories."
         @echo ""

.PHONY:: dist-tree
dist-tree:
         /bin/rm $(EXE) || exit 0
         /bin/rm -r $(DIST_TREE) $(BUILD_DIR) || exit 0
         mkdir $(BUILD_DIR)
         tar cf - --exclude-backups --exclude-vcs $(BUILD_FILES) | (cd 
$(BUILD_DIR) && tar xvf -)
         cd $(BUILD_DIR) && raco exe $(NAME).rkt
         find $(BUILD_DIR) \( -type d -exec chmod 0755 {} \; \) -o \( 
-type f -exec chmod 0644 {} \; \)
         chmod 0755 $(BUILD_DIR)/bin/* $(BUILD_DIR)/lib/plt/*
         cd $(BUILD_DIR) && raco distribute $(CURDIR)/$(DIST_TREE) $(EXE)
         /bin/rm -r $(BUILD_DIR)

.PHONY:: update-test-box
update-test-box:
         rsync -av -e ssh --rsync-path="sudo rsync" $(DIST_TREE)/. 
"$(TEST_HOST):/usr/local/$(NAME)/"

.PHONY:: clean
clean::
         /bin/rm *~ $(EXE)
         /bin/rm -r compiled $(DIST_TREE) $(BUILD_DIR) || exit 0

Neil V.


Posted on the users mailing list.