Changeset 11473 in project


Ignore:
Timestamp:
07/30/08 04:12:04 (12 years ago)
Author:
Ivan Raikov
Message:

Switched to using versions library.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • maintenance/chicken-versions.scm

    r10280 r11473  
    11#!/usr/bin/csi -script
    22
    3 (use posix regex utils web-scheme (srfi 1 13))
     3(use versions posix regex utils web-scheme (srfi 1 13))
    44
    55(define snapshots-dir "/var/www/localhost/htdocs/dev-snapshots")
     
    1212
    1313
    14 ; Convert a string with a version (such as "1.22.0") to a list of the
    15 ; numbers (such as (1 22 0)). If one of the version components cannot
    16 ; be converted to a number, then it is kept as a string.
    17 
    18 (define (version-string->numbers string)
    19   (map (lambda (x) (or (string->number x) (->string x)))
    20        (string-split string ".")))
    21 
    22 (define (numbers->version-string numbers)
    23   (string-intersperse (map ->string numbers) "."))
    24 
    25 ; Given two lists with numbers corresponding to a software version (as returned
    26 ; by version-string->numbers), check if the first is greater than the second.
    27 
    28 (define (version-numbers> a b)
    29   (match (list a b)
    30          ((() _)   #f)
    31          ((_  ())  #t)
    32          (((a1 . an) (b1 . bn))
    33           (cond ((and (number? a1) (number? b1))
    34                  (cond ((> a1 b1) #t) ((= a1 b1) (version-numbers> an bn)) (else #f)))
    35                 ((and (string? a1) (string? b1)) 
    36                  (cond ((string> a1 b1) #t) ((string= a1 b1) (version-numbers> an bn)) (else #f)))
    37                 (else (version-numbers> (cons (->string a1) an) (cons (->string b1) bn)))))
    38          (else (error 'version-numbers> "invalid revisions: " a b))))
    39 
    4014
    4115(let ((data (with-input-from-pipe
     
    4721              (map (lambda (item)
    4822                     (and-let* ((version (string-match  ".*/chicken-([0-9]\\.[0-9]+\\.*[0-9]*)\\.tar\\.gz" item))
    49                                 (version (version-string->numbers (cadr version)))
     23                                (version (string->version (cadr version)))
    5024                                (date (string-match  ".*/([0-9]{4}/[0-9]{2}/[0-9]{2})/.*" item))
    5125                                (date (cadr date)))
    5226                               (cons version date)))
    5327                   data))
    54              (versions (safe-take (sort (delete-duplicates (map car versions/dates)) version-numbers>) 20))
     28             (versions (safe-take (sort (delete-duplicates (map car versions/dates)) version>?) 20))
    5529             (linux-bin (lambda (version) (string-append "chicken-" version "-linux-x86.tar.gz")))
    5630             (win-bin (lambda (version) (string-append "chicken-" version"-mingw32-x86.zip ")))
     
    6943                                                    (string> (cdr a) (cdr b))))))
    7044                               (version (car latest))
    71                                (version-string (numbers->version-string version))
     45                               (version-string (version->string version))
    7246                               (date (cdr latest))
    7347                               (link-to (lambda (file text)
Note: See TracChangeset for help on using the changeset viewer.