Commit eb224c65 authored by Eric Timmons's avatar Eric Timmons
Browse files

cli less work: bundle install

parent 85931c6f
......@@ -5,19 +5,14 @@
(uiop:define-package #:clpm-cli/commands/bundle/install
(:use #:cl
#:alexandria
#:clpm/bundle
#:clpm-cli/commands/bundle/common
#:clpm-cli/common-args
#:clpm-cli/interface-defs
#:clpm/context
#:clpm/log)
(:import-from #:adopt))
#:clpm-cli/interface-defs)
(:import-from #:adopt)
(:import-from #:clpm))
(in-package #:clpm-cli/commands/bundle/install)
(setup-logger)
(define-string *help-string*
"Install a bundle described in a clpmfile.
......@@ -42,17 +37,8 @@ exist in the lock file.")
*option-yes*
*option-no-resolve*)))
(defun sexp-interaction-y-or-n-p ()
(uiop:with-safe-io-syntax ()
(prin1 :proceedp *standard-output*)
(terpri *standard-output*)
(finish-output *standard-output*)
(read *standard-input*)))
(define-cli-command (("bundle" "install") *bundle-install-ui*) (args options)
(declare (ignore args))
(let* ((clpmfile-pathname (bundle-clpmfile-pathname)))
(bundle-install clpmfile-pathname
:validate (make-diff-validate-fun :yesp (gethash :yes options))
:no-resolve (gethash :bundle-no-resolve options))
t))
(clpm:bundle-install :validate (make-diff-validate-fun :yesp (gethash :yes options))
:no-resolve (gethash :bundle-no-resolve options))
t)
......@@ -109,56 +109,38 @@ bound to PN's folder."
(terpri s)))))
(clpmfile-pathname clpmfile))
(defun bundle-install (clpmfile-designator &key (validate (constantly t)) no-resolve)
(defun bundle-install (&key clpmfile (validate (constantly t)) no-resolve)
"Given a clpmfile instance, install all releases from its lock file, creating
the lock file if necessary."
(let* ((*fetch-repo-automatically* (not (config-value :local)))
(clpmfile (get-clpmfile clpmfile-designator))
(lockfile-pathname (clpmfile-lockfile-pathname clpmfile))
(*vcs-project-override-fun* (make-vcs-override-fun (clpmfile-pathname clpmfile)))
(lockfile nil)
(changedp nil))
(unless (config-value :local)
(dolist (s (context-sources clpmfile))
(unless (source-can-lazy-sync-p s)
(sync-source s))))
(if (probe-file lockfile-pathname)
(setf lockfile (load-lockfile lockfile-pathname))
(setf lockfile (create-empty-lockfile clpmfile)))
(if no-resolve
(mapc #'install-release (context-releases lockfile))
(progn
;; Nuke the lockfile's requirements so that we pick up deletions from the
;; clpmfile.
(setf (context-requirements lockfile) nil)
(setf lockfile (install-requirements (context-requirements clpmfile)
:context lockfile
:validate (lambda (diff)
(aprog1 (funcall validate diff)
(setf changedp it)))
:update-projects (config-table-keys :bundle :local)))
(when changedp
(save-context lockfile))))
lockfile))
(defun bundle-output-translations (clpmfile-designator)
(let ((clpmfile-pathname (clpmfile-pathname (get-clpmfile clpmfile-designator))))
(case (config-value :bundle :output-translation)
((t)
`(:output-translations
:ignore-inherited-configuration
(t (:root ,@(rest (pathname-directory (clpm-cache-pathname '("bundle" "fasl-cache")
:ensure-directory t)))
,(urlencode (format nil "~{~A~^/~}" (rest (pathname-directory clpmfile-pathname))))
:implementation :**/ :*.*.*))))
(:local
`(:output-translations
:ignore-inherited-configuration
(t (,(uiop:pathname-directory-pathname clpmfile-pathname) ".clpm" "fasl-cache"
:implementation :**/ :*.*.*))))
(t
nil))))
(with-bundle-session (clpmfile)
(let* ((*fetch-repo-automatically* (not (config-value :local)))
(clpmfile (get-clpmfile clpmfile))
(lockfile-pathname (clpmfile-lockfile-pathname clpmfile))
(lockfile nil)
(changedp nil))
(unless (config-value :local)
(dolist (s (context-sources clpmfile))
(unless (source-can-lazy-sync-p s)
(sync-source s))))
(if (probe-file lockfile-pathname)
(setf lockfile (load-lockfile lockfile-pathname))
(setf lockfile (create-empty-lockfile clpmfile)))
(if no-resolve
(mapc #'install-release (context-releases lockfile))
(progn
;; Nuke the lockfile's requirements so that we pick up deletions from the
;; clpmfile.
(setf (context-requirements lockfile) nil)
(setf lockfile (install-requirements (context-requirements clpmfile)
:context lockfile
:validate (lambda (diff)
(aprog1 (funcall validate diff)
(setf changedp it)))
:update-projects (config-table-keys :bundle :local)))
(when changedp
(save-context lockfile))))
lockfile)))
(defun bundle-source-registry (clpmfile-designator
&key include-client-p ignore-missing-releases)
......@@ -195,7 +177,7 @@ the lock file if necessary."
(unless (probe-file lockfile-pathname)
;; There is no lock file currently. Just fall back to BUNDLE-INSTALL.
(return-from bundle-update
(bundle-install clpmfile :validate validate)))
(bundle-install :clpmfile clpmfile :validate validate)))
;; Load the existing lockfile
(setf lockfile (load-lockfile lockfile-pathname))
(unless (config-value :local)
......
......@@ -20,7 +20,8 @@
#:clpm/version)
;; From bundle
(:export #:bundle-exec
#:bundle-init)
#:bundle-init
#:bundle-install)
;; From client
(:export #:client-asd-pathname)
;; From config
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment