melpa/Makefile
Tomohiro Matsuyama 3399a134da Add sandbox rule for testing
Now `make sandbox' starts up Emacs in a sandbox environment for MELPA
packages.  This is useful for testing new or modified recipes.  Typical
usage is like:

    $ make recipes/RECIPE && make packages/archive-contents && make sandbox
2014-02-12 15:55:20 +09:00

105 lines
2.5 KiB
Makefile

SHELL := /bin/bash
PKGDIR := ./packages
RCPDIR := ./recipes
HTMLDIR := ./html
WORKDIR := ./working
WEBROOT := $$HOME/www
EMACS ?= emacs
SLEEP ?= 0
SANDBOX := ./sandbox
## Check for needing to initialize CL-LIB from ELPA
NEED_CL-LIB := $(shell $(EMACS) --no-site-file --batch --eval '(prin1 (version< emacs-version "24.3"))')
ifeq ($(NEED_CL-LIB), t)
EMACS := $(EMACS) --eval "(package-initialize)"
endif
EVAL := $(EMACS) --no-site-file --batch -l package-build.el --eval
TIMEOUT := $(shell which timeout && echo "-k 60 600")
all: packages packages/archive-contents json index
## General rules
html: index
index: json
@echo " • Building html index ..."
$(MAKE) -C $(HTMLDIR)
## Cleanup rules
clean-working:
@echo " • Removing package sources ..."
rm -rf $(WORKDIR)/*
clean-packages:
@echo " • Removing packages ..."
rm -rfv $(PKGDIR)/*
clean-json:
@echo " • Removing json files ..."
-rm -vf html/archive.json html/recipes.json
clean-sandbox:
@echo " • Removing sandbox files ..."
if [ -d '$(SANDBOX)' ]; then \
rm -rfv '$(SANDBOX)/elpa'; \
rmdir '$(SANDBOX)'; \
fi
sync:
rsync -avz --delete $(PKGDIR) $(HTMLDIR)/* $(WEBROOT)/
chmod -R go+rx $(WEBROOT)/packages/*
clean: clean-working clean-packages clean-json clean-sandbox
packages: $(RCPDIR)/*
packages/archive-contents: packages/*.entry
@echo " • Updating $@ ..."
$(EVAL) '(package-build-dump-archive-contents)'
cleanup:
$(EVAL) '(package-build-cleanup)'
## Json rules
html/archive.json: packages/archive-contents
@echo " • Building $@ ..."
$(EVAL) '(package-build-archive-alist-as-json "html/archive.json")'
html/recipes.json: $(RCPDIR)/.dirstamp
@echo " • Building $@ ..."
$(EVAL) '(package-build-recipe-alist-as-json "html/recipes.json")'
json: html/archive.json html/recipes.json
$(RCPDIR)/.dirstamp: .FORCE
@[[ ! -e $@ || "$$(find $(@D) -newer $@ -print -quit)" != "" ]] \
&& touch $@ || exit 0
## Recipe rules
$(RCPDIR)/%: .FORCE
@echo " • Building recipe $(@F) ..."
- $(TIMEOUT) $(EVAL) "(package-build-archive '$(@F))"
@echo " ✓ Wrote $$(ls -lsh $(PKGDIR)/$(@F)-*) "
@echo " Sleeping for $(SLEEP) ..."
sleep $(SLEEP)
@echo
## Sandbox
sandbox:
@echo " • Building sandbox ..."
mkdir -p $(SANDBOX)
$(EMACS) -Q \
--eval '(setq user-emacs-directory "$(SANDBOX)")' \
-l package \
--eval "(add-to-list 'package-archives '(\"melpa\" . \"http://melpa.milkbox.net/packages/\") t)" \
--eval "(add-to-list 'package-archives '(\"sandbox\" . \"$(shell pwd)/$(PKGDIR)/\") t)"
.PHONY: clean build index html json sandbox
.FORCE: