Commit 308392cc authored by Eric Timmons's avatar Eric Timmons
Browse files

client updates

Add command `client install` to unpack the client (bundled inside the
executable) to the user's data directory.

`client source-registry.d` now searches relative to the executable and the user
data directory for the client.
parent c505922d
......@@ -7,6 +7,7 @@
(:use #:cl
#:clpm-cli/commands/client/cat
#:clpm-cli/commands/client/common
#:clpm-cli/commands/client/install
#:clpm-cli/commands/client/rc
#:clpm-cli/commands/client/repl
#:clpm-cli/commands/client/source-registry.d))
......
;;;; clpm client install
;;;;
;;;; This software is part of CLPM. See README.org for more information. See
;;;; LICENSE for license information.
(uiop:define-package #:clpm-cli/commands/client/install
(:use #:cl
#:clpm-cli/common-args
#:clpm-cli/commands/client/common
#:clpm-cli/interface-defs)
(:import-from #:uiop
#:*stdout*)
(:import-from #:clpm))
(in-package #:clpm-cli/commands/client/install)
(define-string *help-text*
"Install the CLPM client to your user data directory. If you use the client
installed this way you will want to update your ASDF config every time you
upgrade CLPM.")
(defparameter *client-install-ui*
(adopt:make-interface
:name "clpm client install"
:summary "Common Lisp Package Manager"
:usage "client install [options]"
:help *help-text*
:contents (list *group-common*)))
(define-cli-command (("client" "install") *client-install-ui*) (args options)
(declare (ignore args options))
(let ((pathname (clpm:client-user-data-pathname)))
(clpm:install-client-to-user-data)
(format t "CLPM Client installed to ~A~%" (uiop:native-namestring
(uiop:pathname-directory-pathname pathname)))
t))
......@@ -10,6 +10,7 @@
#:clpm-cli/interface-defs
#:named-readtables)
(:import-from #:uiop
#:*stderr*
#:*stdout*)
(:import-from #:cl-interpol)
(:import-from #:clpm))
......@@ -36,9 +37,14 @@ Place the outputs of this command in a file such as
(define-cli-command (("client" "source-registry.d") *client-source-registry.d-ui*) (args options)
(declare (ignore args options))
(write-string #?";; -*- mode: common-lisp; -*-
(if (clpm:client-asd-pathname)
(write-string #?";; -*- mode: common-lisp; -*-
;; Auto generated by CLPM version ${(clpm:clpm-version)}
(:directory #P\"${(uiop:pathname-directory-pathname (clpm:client-asd-pathname))}\")
"
*stdout*)
t)
*stdout*)
(progn
(write-string "Unable to find the CLPM client. Consider installing it to your user data directory with `clpm client install`
"
*stderr*)
(uiop:quit 1))))
......@@ -13,10 +13,11 @@
(:import-from #:alexandria)
(:import-from #:flexi-streams
#:make-in-memory-input-stream)
(:export #:*clpm-client-asd-pathname*
#:*clpm-client-concatenated-source*
(:export #:*clpm-client-concatenated-source*
#:*clpm-client-tarball-contents*
#:client-asd-pathname))
#:client-asd-pathname
#:client-user-data-pathname
#:install-client-to-user-data))
(in-package #:clpm/client)
......@@ -26,17 +27,33 @@
(defparameter *clpm-client-concatenated-source*
(uiop:read-file-string (asdf:output-file 'asdf:concatenate-source-op :clpm-client)))
(defun unpack-client ()
(let ((dir-pathname (clpm-data-pathname `("client"
,(concatenate 'string "clpm-client-" (clpm-version)))
:ensure-directory t)))
(unless (probe-file dir-pathname)
(defun client-installed-pathname ()
"Return the pathname where we would expect to find the clpm client if it were
installed in the expected place relative to the clpm executable."
(let ((clpm-pathname sb-ext:*runtime-pathname*))
(merge-pathnames (make-pathname :directory '(:relative :up "share" "clpm" "client")
:name "clpm-client"
:type "asd")
(uiop:pathname-directory-pathname clpm-pathname))))
(defun client-user-data-pathname ()
"Return the pathname to the clpm-client.asd file in the user's data
directory."
(clpm-data-pathname `("client"
,(concatenate 'string "clpm-client-" (clpm-version))
"clpm-client.asd")))
(defun install-client-to-user-data ()
"Install the client to the user data folder if it doesn't already exist."
(let* ((asd-pathname (client-user-data-pathname))
(dir-pathname (uiop:pathname-directory-pathname asd-pathname)))
(unless (probe-file asd-pathname)
(unarchive 'gzipped-tar-archive (make-in-memory-input-stream *clpm-client-tarball-contents*)
dir-pathname :strip-components 1))
(merge-pathnames "clpm-client.asd" dir-pathname)))
dir-pathname :strip-components 1))))
(defun client-asd-pathname ()
"Return the pathname to the client .asd file."
(if *clpm-client-tarball-contents*
(unpack-client)
(asdf:system-source-file :clpm-client)))
"Return the pathname to the client .asd file. First tries to find the client
relative the the clpm executable. If that fails, it looks to the user data dir
to see if the client is installed there."
(or (probe-file (client-installed-pathname))
(probe-file (client-user-data-pathname))))
......@@ -26,7 +26,9 @@
#:bundle-source-registry
#:bundle-update)
;; From client
(:export #:client-asd-pathname)
(:export #:client-asd-pathname
#:client-user-data-pathname
#:install-client-to-user-data)
;; From clpi
(:export #:make-release-jsown)
;; 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