racket/collects/planet/planet-archives.rkt
Eli Barzilay 9c352f5704 More svn -> git changes.
Some mentions of svn/subversion are replaced with git, and some patterns
for paths to ignore include ".git*".  (Note ".mailmap" not added, might
need to.)
2010-05-17 05:41:04 -04:00

61 lines
2.1 KiB
Racket

(module planet-archives mzscheme
(require "private/planet-shared.ss"
mzlib/file
"config.ss"
"cachepath.ss")
(provide repository-tree
get-installed-planet-archives
get-hard-linked-packages
get-all-planet-packages
get-planet-cache-path)
(define (repository-tree)
(define (id x) x)
(filter-tree-by-pattern
(directory->tree
(CACHE-DIR)
(lambda (x)
(not (regexp-match? #rx"/(?:[.]git.*|[.]svn|CVS)$" (path->string x))))
4)
(list id id id string->number string->number)))
;; get-installed-planet-dirs : -> listof (list path[absolute, dir] string string (listof string) nat nat)
;; directories of all normally-installed planet archives [excluding hard links]
(define (get-installed-planet-archives)
(with-handlers ((exn:fail:filesystem:no-directory? (lambda (e) '())))
(tree-apply
(lambda (rep-name owner package maj min)
(let ((x (list
(build-path (CACHE-DIR) owner package (number->string maj) (number->string min))
owner
package
'()
maj
min)))
x))
(repository-tree)
3)))
;; get-hard-linked-packages : -> listof (list path[absolute, dir] string string (listof string) nat nat)
;; directories of all hard-linked packages
(define (get-hard-linked-packages)
(map
(lambda (row)
(map (lambda (f) (f row))
(list assoc-table-row->dir
(lambda (r) (car (assoc-table-row->path r)))
assoc-table-row->name
(lambda (r) (cdr (assoc-table-row->path r)))
assoc-table-row->maj
assoc-table-row->min)))
(get-hard-link-table)))
;; get-all-planet-packages : -> listof (list path[absolute, dir] string string (listof string) nat nat)
;; get every planet package, regardless of origin
(define (get-all-planet-packages)
(append (get-installed-planet-archives)
(get-hard-linked-packages)))
)