summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Bex <peter@more-magic.net>2012-01-27 20:45:49 +0100
committerPeter Bex <peter@more-magic.net>2012-01-27 20:45:49 +0100
commit40dc846436e0251aeaff4570e68c5889ac6ea387 (patch)
treedb3d17e25fcea8e6ab0059d7e5fca7120122f408
parentabfa3c32cec4409901050109ec2f94564794dc99 (diff)
parent909a9db0526e8edcce678ad9e5f92cf37794ffd8 (diff)
downloadhenrietta-cache-40dc846436e0251aeaff4570e68c5889ac6ea387.tar.gz
Merged in DerGuteMoritz/henrietta-cache (pull request #1)
-rw-r--r--henrietta-cache.scm36
1 files changed, 34 insertions, 2 deletions
diff --git a/henrietta-cache.scm b/henrietta-cache.scm
index 76276cb..f7914fe 100644
--- a/henrietta-cache.scm
+++ b/henrietta-cache.scm
@@ -18,6 +18,29 @@ EOF
(define *cache-directory* "cache")
(define *egg-list* "egg-locations")
(define *chicken-release* (##sys#fudge 41))
+(define *init-file* #f)
+
+(define download-release-success-hook
+ (make-parameter #f))
+
+(define download-release-error-hook
+ (make-parameter #f))
+
+(define hooks
+ `((download-release-success . ,download-release-success-hook)
+ (download-release-error . ,download-release-error-hook)))
+
+(define (run-hook hook-name . args)
+ (and-let* ((hook (or (alist-ref hook-name hooks)
+ (error "invalid hook" hook-name)))
+ (hook (hook)))
+ (condition-case
+ (apply hook args)
+ (exn ()
+ (print-error-message exn
+ (current-error-port)
+ (sprintf "Error running hook `~A'" hook-name))
+ (flush-output (current-error-port))))))
;; This works on raw URI strings, not URI objects (for now?)
(define (replace-uri-patterns uri patterns)
@@ -175,9 +198,11 @@ EOF
"Error downloading or extracting egg '~A' release ~A: "
egg-name egg-release)
(print-error-message exn (current-error-port))
- (flush-output (current-error-port)))
+ (flush-output (current-error-port))
+ (run-hook 'download-release-error egg-name egg-release))
(create-directory cache-dir #t)
- (download-release type uri cache-dir))))))
+ (download-release type uri cache-dir)
+ (run-hook 'download-release-success egg-name egg-release))))))
(cdr uri/releases))))
uris/releases)))
@@ -195,6 +220,9 @@ EOF
(with-input-from-request uri #f read-file)))
(define (update-egg-cache)
+ (when *init-file*
+ (load *init-file*))
+
(for-each
(lambda (egg)
(let* ((egg-name (car egg))
@@ -256,6 +284,10 @@ EOF
(unless (pair? (cdr args)) (usage 1))
(set! *egg-list* (cadr args))
(loop (cddr args)))
+ ((or (string=? arg "-i") (string=? arg "-init-file"))
+ (unless (pair? (cdr args)) (usage 1))
+ (set! *init-file* (cadr args))
+ (loop (cddr args)))
((and (positive? (string-length arg))
(char=? #\- (string-ref arg 0)))
(if (> (string-length arg) 2)