source: project/chicken/branches/prerelease/scripts/setversion @ 13240

Last change on this file since 13240 was 13240, checked in by felix winkelmann, 11 years ago

merged trunk svn rev. 13239 into prerelease

File size: 1.8 KB
Line 
1#!/bin/sh
2#| setversion - Bump version-number -*- Scheme -*-
3exec csi -s "$0" "$@"
4|#
5
6(use srfi-1 utils posix)
7
8(define buildversion (->string (car (read-file "buildversion"))))
9(define buildbinaryversion (car (read-file "buildbinaryversion")))
10
11(define files '("README" "manual/The User's Manual"))
12
13(define-syntax rx
14  (syntax-rules ()
15    ((_ r) (force (delay (regexp r))))))
16
17(define (patch which rx subst)
18  (cond ((and (list? which) (= 2 (length which)))
19         (let ((from (car which))
20               (to (cadr which)))
21           (print "patching " from " ...")
22           (with-output-to-file to
23             (lambda ()
24               (with-input-from-file from
25                 (lambda ()
26                   (let loop ()
27                     (let ((ln (read-line)))
28                       (unless (eof-object? ln)
29                         (write-line (string-substitute rx subst ln #t))
30                         (loop) ) ) ) ) ) ) ) ) )
31        (else
32         (let ((tmp (create-temporary-file)))
33           (patch (list which tmp) rx subst)
34           (system* "mv ~S ~S" tmp which) ) ) ) )
35
36(define (parse-version v)
37  (string-match (rx "(\\d+)\\.(\\d+)\\.(\\d+)(.*)") v) )
38
39(define (main args)
40  (cond ((member "-set" args) =>
41         (lambda (a) (set! buildversion (cadr a))) )
42        ((not (member "-noinc" args))
43         (let* ((v (parse-version buildversion))
44                (maj (cadr v))
45                (min (caddr v))
46                (pl (cadddr v))
47                (huh (car (cddddr v))))
48           (set! buildversion (conc maj "." min "." (add1 (string->number pl)) huh)) ) ) )
49  (with-output-to-file "buildversion" (cut display buildversion))
50  (with-output-to-file "version.scm"
51    (lambda ()
52      (write `(define-constant +build-version+ ,buildversion))
53      (newline) ) )
54  (system* "cat version.scm")
55  (let ([vstr (sprintf "version ~A" buildversion)])
56    (for-each (cut patch <> (rx "version [0-9][-.0-9a-zA-Z]+") vstr) files) )
57  (with-output-to-file "DONE" (cut print "- version is " buildversion))
58  0)
59
60(main (command-line-arguments))
Note: See TracBrowser for help on using the repository browser.