introduce decide-download

This commit is contained in:
SANO Masatoshi 2016-10-07 01:38:05 +09:00
parent 28e2bb516a
commit e09cf5c321
8 changed files with 52 additions and 90 deletions

View file

@ -24,31 +24,14 @@
(cons t argv))
(defun abcl-bin-download (argv)
(loop for repeat = nil
do (set-opt "as" (version argv))
(set-opt "download.uri" (format nil "~@{~A~}" (abcl-bin-uri)
(version argv) "/abcl-bin-" (version argv)".tar.gz"))
(set-opt "download.archive"
(let ((pos (position #\/ (get-opt "download.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir)))))
(handler-case
(if (or (not (probe-file (get-opt "download.archive")))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive:~A~%" (get-opt "download.uri"))
;;TBD proxy support... and other params progress bar?
(download (get-opt "download.uri") (get-opt "download.archive")))
(format t "~&Skip downloading ~A~%specify download.force=t to download it again.~%"
(get-opt "download.uri")))
(uiop/run-program:subprocess-error ()
(format t "Failure~%")
(setf repeat t)))
while (and repeat
(incf (getf argv :version-not-specified))
(> (length (funcall *version-func*))
(getf argv :version-not-specified))))
(cons (not (get-opt "without-install")) argv))
(set-opt "as" (version argv))
(set-opt "download.uri" (format nil "~@{~A~}" (abcl-bin-uri)
(version argv) "/abcl-bin-" (version argv)".tar.gz"))
(set-opt "download.archive"
(let ((pos (position #\/ (get-opt "download.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir)))))
`((,(get-opt "download.archive") ,(get-opt "download.uri"))))
(defun abcl-bin-expand (argv)
(format t "~%Extracting archive:~A~%" (get-opt "download.archive"))
@ -90,7 +73,7 @@
(push `("abcl-bin" . (,(decide-version 'abcl-bin-get-version)
abcl-bin-argv-parse
abcl-bin-download
,(decide-download 'abcl-bin-download)
abcl-bin-expand
abcl-bin-script
setup))

View file

@ -21,27 +21,20 @@
(defun allegro-argv-parse (argv)
(format *error-output* "~&Installing allegro/~A...~%" (getf argv :version))
(set-opt "as" (getf argv :version))
(cons t argv))
(defun allegro-download (argv)
(let ((uname (allegro-uname))
(uname-m (allegro-uname-m)))
(set-opt "as" (getf argv :version))
(set-opt "download.uri" (format nil "~@{~A~}" (allegro-uri)
"/acl" (getf argv :version) "/" uname uname-m "/acl" (getf argv :version)
"-" uname "x-" uname-m (cond ((equal uname "macos") ".dmg")
((equal uname "linu") ".bz2"))))
(set-opt "download.archive" (let ((pos (position #\/ (get-opt "download.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir))))))
(if (or (not (probe-file (get-opt "download.archive")))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive:~A~%" (get-opt "download.uri"))
(download (get-opt "download.uri") (get-opt "download.archive")))
(format t "~&Skip downloading ~A~%specify download.force=t to download it again.~%"
(get-opt "download.uri")))
(cons t argv))
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir)))))
`((,(get-opt "download.archive") ,(get-opt "download.uri")))))
(defun allegro-expand (argv)
(format t "~%Extracting archive:~A~%" (get-opt "download.archive"))
@ -86,10 +79,10 @@
(cons t argv))
(push `("allegro" . (,(decide-version 'allegro-get-version)
allegro-argv-parse
allegro-download
allegro-expand
setup))
allegro-argv-parse
,(decide-download 'allegro-download)
allegro-expand
setup))
*install-cmds*)
(push `("allegro" . ,(list 'allegro-help)) *help-cmds*)

View file

@ -36,16 +36,8 @@
".zip"".tar.gz")))
(set-opt "download.archive" (let ((pos (position #\/ (get-opt "download.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir))))))
(if (or (not (probe-file (get-opt "download.archive")))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive:~A~%" (get-opt "download.uri"))
;;TBD proxy support... and other params progress bar?
(download (get-opt "download.uri") (get-opt "download.archive")))
(format t "~&Skip downloading ~A~%specify download.force=t to download it again.~%"
(get-opt "download.uri")))
(cons (not (get-opt "without-install")) argv))
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir)))))
`((,(get-opt "download.archive") ,(get-opt "download.uri")))))
(defun ccl-bin-expand (argv)
(format t "~%Extracting archive:~A~%" (get-opt "download.archive"))
@ -78,7 +70,7 @@
(push `("ccl-bin" . (,(decide-version 'ccl-bin-get-version)
ccl-bin-argv-parse
ccl-bin-download
,(decide-download 'ccl-bin-download)
ccl-bin-expand
setup))
*install-cmds*)

View file

@ -31,14 +31,7 @@
(set-opt "download.archive" (let ((pos (position #\/ (get-opt "download.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir)))))
(if (or (not (probe-file (get-opt "download.archive")))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive: ~A~%" (get-opt "download.uri"))
(download (get-opt "download.uri") (get-opt "download.archive")))
(format t "~&Skip downloading ~A.~%Specify 'download.force=t' to download it again.~%"
(get-opt "download.uri")))
(cons t argv))
`((,(get-opt "download.archive") ,(get-opt "download.uri"))))
(defun clisp-lib (argv)
(when (and (find :linux *features*)
@ -131,7 +124,7 @@
(push `("clisp" . (,(decide-version 'clisp-get-version)
clisp-argv-parse
start
clisp-download
,(decide-download 'clisp-download)
clisp-lib
clisp-expand
clisp-patch

View file

@ -43,17 +43,8 @@
(set-opt "download.extra.archive" (let ((pos (position #\/ (get-opt "download.extra.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.extra.uri") (1+ pos))) (homedir)))))
(loop for archive in (list (get-opt "download.archive") (get-opt "download.extra.archive"))
for uri in (list (get-opt "download.uri") (get-opt "download.extra.uri"))
do (if (or (not (probe-file archive))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive:~A~%" uri)
;;TBD proxy support... and other params progress bar?
(download uri archive))
(format t "~&Skip downloading ~A~%specify download.force=t to download it again.~%"
uri)))
(cons (not (get-opt "without-install")) argv))
`((,(get-opt "download.archive") ,(get-opt "download.uri"))
(,(get-opt "download.extra.archive") ,(get-opt "download.extra.uri"))))
(defun cmu-bin-expand (argv)
(loop for archive in (list (get-opt "download.archive") (get-opt "download.extra.archive"))
@ -84,7 +75,7 @@
(push `("cmu-bin" . (,(decide-version 'cmu-bin-get-version)
cmu-bin-argv-parse
cmu-bin-download
,(decide-download 'cmu-bin-download)
cmu-bin-expand
setup))
*install-cmds*)

View file

@ -49,14 +49,7 @@
(set-opt "download.archive" (let ((pos (position #\/ (get-opt "download.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir)))))
(if (or (not (probe-file (get-opt "download.archive")))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive: ~A~%" (get-opt "download.uri"))
(download (get-opt "download.uri") (get-opt "download.archive")))
(format t "~&Skip downloading ~A.~%Specify 'download.force=t' to download again.~%"
(get-opt "download.uri")))
(cons (not (get-opt "without-install")) argv))
`((,(get-opt "download.archive") ,(get-opt "download.uri"))))
(defun ecl-expand (argv)
(format t "~%Extracting archive:~A~%" (get-opt "download.archive"))
@ -128,7 +121,7 @@
,(decide-version 'ecl-get-version)
ecl-argv-parse
start
ecl-download
,(decide-download 'ecl-download)
ecl-expand
ecl-config
ecl-make

View file

@ -79,14 +79,7 @@
(set-opt "download.archive" (let ((pos (position #\/ (get-opt "download.uri") :from-end t)))
(when pos
(merge-pathnames (format nil "archives/~A" (subseq (get-opt "download.uri") (1+ pos))) (homedir)))))
(if (or (not (probe-file (get-opt "download.archive")))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive: ~A~%" (get-opt "download.uri"))
(download (get-opt "download.uri") (get-opt "download.archive")))
(format t "~&Skip downloading ~A.~%Specify 'download.force=t' to download again.~%"
(get-opt "download.uri")))
(cons t argv))
`((,(get-opt "download.archive") ,(get-opt "download.uri"))))
(defun sbcl-expand (argv)
(format t "~%Extracting archive:~A~%" (get-opt "download.archive"))
@ -311,7 +304,7 @@
#+win32 sbcl-msys
sbcl-start
start
sbcl-download
,(decide-download 'sbcl-download)
sbcl-expand
sbcl-patch
sbcl-config

View file

@ -79,6 +79,30 @@
(getf argv :version-not-specified) 0)))
(cons t argv)))
(defun decide-download (func)
(lambda (argv)
(loop for repeat = nil
for list = (funcall func argv)
do (handler-case
(loop for (archive uri) in list
do (if (or (not (probe-file archive))
(get-opt "download.force"))
(progn
(format t "~&Downloading archive:~A:" uri)
;;TBD proxy support... and other params progress bar?
(download uri archive)
(format t "OK~%"))
(format t "~&Skip downloading ~A~%specify download.force=t to download it again.~%"
uri)))
(uiop/run-program:subprocess-error ()
(format t "NG~%")
(setf repeat t)))
while (and repeat
(incf (getf argv :version-not-specified))
(> (length (funcall *version-func*))
(getf argv :version-not-specified))))
(cons (not (get-opt "without-install")) argv)))
(defun install-running-p (argv)
;;TBD
(declare (ignore argv))