diff --git a/Makefile b/Makefile index a980a1d..11cfb5a 100644 --- a/Makefile +++ b/Makefile @@ -22,10 +22,14 @@ scsh-blurbs := $(shell find scsh \ -maxdepth 2 -mindepth 2 \ -name BLURB) -targets := DETAILS COPYING pkg-def.scm +.PHONY: version-check +version-check : + build/version-check.scm + +targets := DETAILS COPYING pkg-def.scm version-check .PHONY: all -all : $(targets) +all : $(targets) check-versions DETAILS : $(s48-authors) $(s48-blurbs) $(scsh-authors) $(scsh-blurbs) \ build/details.scm build/dirs.scm build/header.scm diff --git a/build/version-check.scm b/build/version-check.scm new file mode 100755 index 0000000..87696df --- /dev/null +++ b/build/version-check.scm @@ -0,0 +1,59 @@ +#! /bin/sh +exec scsh -o filenames -s "$0" "$@" +!# + +;;; This file is part of the Scheme Untergrund Library. For copyright +;;; information, see the file COPYING which comes with the +;;; distribution. + +(load "build/common.scm") +(load "build/dirs.scm") + +(define version-re + (rx "version" + (+ " ") + (submatch (+ numeric)) + (* "." (submatch (+ numeric))))) + +(define string->version + (lambda (v) + (let* ((match (regexp-search version-re v)) + (major (string->number (match:substring match 1))) + (minor (match:substring match 2))) + (if minor + (list major (string->number minor)) + (list major))))) + +(define ok '#t) + +(define check + (lambda (dir) + (call-with-input-file + (string-append dir "/pkg-def.scm") + (lambda (port) + (let try-again () + (let ((form (read port))) + (cond ((eof-object? form) + (error "can't find package version")) + ((and (pair? form) + (eq? (car form) 'define-package)) + (let ((name (cadr form)) + (version-pkg-def (caddr form)) + (version-news + (call-with-input-file + (string-append dir "/NEWS") + (lambda (news-port) + (string->version (read-line news-port)))))) + (if (not (equal? version-pkg-def version-news)) + (let () + (display "version mismatch in: ") + (display name) + (newline) + (set! ok '#f))))) + (else + (try-again))))))))) + +(for-each check scsh-dirs) +(for-each check s48-dirs) + +(exit (if ok 0 1)) \ No newline at end of file