From 002a342c0de978d1a6ae013111e3137c68bed88c Mon Sep 17 00:00:00 2001 From: Donald Curtis Date: Sat, 25 Jan 2014 21:04:00 -0800 Subject: [PATCH] Add stable package building Makefile and services --- Makefile | 21 ++++++++++++++------- service/builder-stable | 25 +++++++++++++++++++++++++ service/reporter-stable | 24 ++++++++++++++++++++++++ service/syncer-stable | 15 +++++++++++++++ 4 files changed, 78 insertions(+), 7 deletions(-) create mode 100755 service/builder-stable create mode 100755 service/reporter-stable create mode 100755 service/syncer-stable diff --git a/Makefile b/Makefile index 7618b953..bc1e8958 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,12 @@ WEBROOT := $$HOME/www EMACS ?= emacs SLEEP ?= 0 SANDBOX := ./sandbox +ifdef STABLE +PKGDIR := ./packages-stable +endif +STABLE ?= nil + +EVAL := $(EMACS) ## 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"))') @@ -48,7 +54,8 @@ clean-sandbox: fi sync: - rsync -avz --delete $(PKGDIR) $(HTMLDIR)/* $(WEBROOT)/ + rsync -avz --delete $(PKGDIR)/ $(WEBROOT)/packages + rsync -avz --safe-links --delete $(HTMLDIR)/* $(WEBROOT)/ chmod -R go+rx $(WEBROOT)/packages/* @@ -56,21 +63,21 @@ clean: clean-working clean-packages clean-json clean-sandbox packages: $(RCPDIR)/* -packages/archive-contents: packages/*.entry +packages/archive-contents: $(PKGDIR)/*.entry @echo " • Updating $@ ..." $(EVAL) '(package-build-dump-archive-contents)' cleanup: - $(EVAL) '(package-build-cleanup)' + $(EVAL) '(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name "$(PKGDIR)/" pb/this-dir))) (package-build-cleanup))' ## Json rules -html/archive.json: packages/archive-contents +html/archive.json: $(PKGDIR)/archive-contents @echo " • Building $@ ..." - $(EVAL) '(package-build-archive-alist-as-json "html/archive.json")' + $(EVAL) '(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name "$(PKGDIR)/" pb/this-dir))) (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")' + $(EVAL) '(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name "$(PKGDIR)/" pb/this-dir))) (package-build-recipe-alist-as-json "html/recipes.json"))' json: html/archive.json html/recipes.json @@ -83,7 +90,7 @@ $(RCPDIR)/.dirstamp: .FORCE $(RCPDIR)/%: .FORCE @echo " • Building recipe $(@F) ..." - - $(TIMEOUT) $(EVAL) "(package-build-archive '$(@F))" + - $(TIMEOUT) $(EVAL) "(let ((package-build-stable $(STABLE)) (package-build-archive-dir (expand-file-name \"$(PKGDIR)\" pb/this-dir))) (package-build-archive '$(@F)))" @echo " ✓ Wrote $$(ls -lsh $(PKGDIR)/$(@F)-*) " @echo " Sleeping for $(SLEEP) ..." diff --git a/service/builder-stable b/service/builder-stable new file mode 100755 index 00000000..53c11ecb --- /dev/null +++ b/service/builder-stable @@ -0,0 +1,25 @@ +#!/bin/bash -e + +export HOME=/home/melpa +cd ${HOME}/melpa + +export MELPA_BRANCH=stable +export STABLE=t + +source $HOME/melpa/scripts/env + +## git pull +cd ${MELPA_HOME} +git fetch origin +git checkout ${MELPA_BRANCH} +git reset --hard origin/${MELPA_BRANCH} +git pull origin ${MELPA_BRANCH} +echo + +# Build all the packages. +scripts/parallel_build_all + +echo '{"completed":' `date "+%s"` '}' > /home/melpa/www/build-status.json + +# Sleep for an hour before rebuilding. +sleep 1h diff --git a/service/reporter-stable b/service/reporter-stable new file mode 100755 index 00000000..0305397c --- /dev/null +++ b/service/reporter-stable @@ -0,0 +1,24 @@ +#!/bin/bash -e + +# Service for reporting missing and old packages. + +export HOME=/home/melpa + +BODY=`mktemp` + +cd ${HOME}/melpa + +echo "To: MP " > ${BODY} +echo "Subject: [MELPA] `date "+%Y%m%d %H:%M %z"`" >> ${BODY} +echo >> ${BODY} +echo "# Old Packages" >> ${BODY} +echo >> ${BODY} +emacs --no-site-file --batch -l package-build.el --eval '(setq package-archive-dir (expand-file-name "packages-stable" pb/this-dir)))' scripts/expired >> ${BODY} +echo >> ${BODY} +echo "# Missing Packages" >> ${BODY} +echo >> ${BODY} +emacs --no-site-file --batch -l package-build.el --eval '(setq package-archive-dir (expand-file-name "packages-stable" pb/this-dir)))' sscripts/missing >> ${BODY} + +/usr/sbin/sendmail -t < ${BODY} + +sleep 12h diff --git a/service/syncer-stable b/service/syncer-stable new file mode 100755 index 00000000..2d1c75ba --- /dev/null +++ b/service/syncer-stable @@ -0,0 +1,15 @@ +#!/bin/bash -e + +export STABLE=t + +export HOME=/home/melpa +cd ${HOME}/melpa +[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" + +make cleanup +make json +make html +make sync + +# Sync every 5 minutes. +sleep 5m