Permalink
Browse files

Show version numbers of installed packages.

  • Loading branch information...
wh5a committed Dec 31, 2009
1 parent 1ea2cd1 commit a82b9dacfc0549d60067e367c8efdcc4021c8b7e
Showing with 18 additions and 9 deletions.
  1. +16 −9 main.lisp
  2. +2 −0 term.lisp
View
@@ -2,7 +2,7 @@
(declaim (optimize (debug 3) (safety 2) (speed 1) (space 1)))
(defun package-installed-p (pkg-name &optional pkg-version) ; TODO groups
(defun package-installed-version (pkg-name &optional pkg-version) ; TODO groups
(map-cached-packages (lambda (db-name pkg)
(declare (ignore db-name))
(unless (stringp pkg) ; ignore groups
@@ -11,11 +11,11 @@
(when (and (equalp name pkg-name)
(or (null pkg-version)
(equalp pkg-version version)))
(return-from package-installed-p (values t :installed)))
(return-from package-installed-version (values version :installed)))
(when (member pkg-name provides
:test #'equalp
:key (compose #'first #'parse-dep))
(return-from package-installed-p (values t :provided))))))
(return-from package-installed-version (values version :provided))))))
:db-list (list *local-db*))
nil)
@@ -53,10 +53,17 @@
(with-term-colors/id :pkg-version
(format t "~A" version))
;; installation status
(when (package-installed-p name) ; TODO: version
(format t " ")
(with-term-colors/id :pkg-installed
(format t "[installed]")))
(let ((ver (package-installed-version name)))
(when ver
(format t " ")
(if (string< ver version)
(with-term-colors/id :pkg-old
(format t "[~A installed]" ver))
(if (string> ver version)
(with-term-colors/id :pkg-result-id
(format t "[~A installed]" ver))
(with-term-colors/id :pkg-installed
(format t "[installed]" ver))))))
;; out of date? (aur-only)
(when out-of-date-p
(format t " ")
@@ -166,7 +173,7 @@ Returns T upon successful installation, NIL otherwise."
(let ((db-name (or db-name (first (find-package-by-name pkg-name))))) ; FIXME: show all packages that provide PKG-NAME too (?)
(labels ((do-install ()
(cond
((and (package-installed-p pkg-name) (not force))
((and (package-installed-version pkg-name) (not force))
(info "Package ~S is already installed." pkg-name)
t)
((not db-name)
@@ -292,7 +299,7 @@ Returns T upon successful installation, NIL otherwise."
(labels ((do-remove ()
;; TODO: support removal of group, provides(?)
(cond
((not (package-installed-p pkg-name))
((not (package-installed-version pkg-name))
#+(or)(info "Package ~S is not installed, skipping removal." pkg-name)
nil)
(t
View
@@ -15,6 +15,7 @@
:pkg-version green
:pkg-installed (:fg green :invertp t)
:pkg-outofdate red
:pkg-old (:fg red :invertp t)
:pkg-description nil))
(defparameter *color-scheme-lightbg* '(:info black
@@ -27,6 +28,7 @@
:pkg-version green
:pkg-installed (:fg green :invertp t)
:pkg-outofdate red
:pkg-old (:fg red :invertp t)
:pkg-description nil))
(defvar *color-scheme* *color-scheme-darkbg*)

3 comments on commit a82b9da

@kingcons

This comment has been minimized.

Show comment
Hide comment
@kingcons

kingcons Jan 1, 2010

I'm thrilled you've gotten the versioning work started.

If you wouldn't mind, there are three small concerns I have with this patch. All involve the let on lines 56-66.

  1. One is the naming of "ver". We tend to use full names in the project, would you mind changing it to "installed-version"?
  2. Second, the nested WHENs and IFs are quite troubling. Is there some way we could refactor this into a cond, or at least a when followed by a cond?
    I.e. (let ((installed-version ...))
    (cond ((and ver (clause)) (effect))
    (...)
    (t ...))
  3. Why is ver being passed to the final FORMAT call... (format t "[installed]" ver)?

kingcons replied Jan 1, 2010

I'm thrilled you've gotten the versioning work started.

If you wouldn't mind, there are three small concerns I have with this patch. All involve the let on lines 56-66.

  1. One is the naming of "ver". We tend to use full names in the project, would you mind changing it to "installed-version"?
  2. Second, the nested WHENs and IFs are quite troubling. Is there some way we could refactor this into a cond, or at least a when followed by a cond?
    I.e. (let ((installed-version ...))
    (cond ((and ver (clause)) (effect))
    (...)
    (t ...))
  3. Why is ver being passed to the final FORMAT call... (format t "[installed]" ver)?
@wh5a

This comment has been minimized.

Show comment
Hide comment
@wh5a

wh5a Jan 2, 2010

Owner

Thanks for your comments. I have very limited knowledge about Common Lisp. I'm more comfortable with Haskell or ML. Anyways, paktahn is a very good opportunity for me to learn more about Lisp and Arch.

Some changes were just experiments or hacks. Only those I explicitly sent a pull request were intended to go upstream :)

  1. That's easy.
  2. Yeah, cond would be better. Is http://github.com/wh5a/paktahn/commit/1c079e6d43c8303c65a7461e25347ff56f0f7b11 what you had in mind?
  3. Obviously I shouldn't do copy-and-paste.
Owner

wh5a replied Jan 2, 2010

Thanks for your comments. I have very limited knowledge about Common Lisp. I'm more comfortable with Haskell or ML. Anyways, paktahn is a very good opportunity for me to learn more about Lisp and Arch.

Some changes were just experiments or hacks. Only those I explicitly sent a pull request were intended to go upstream :)

  1. That's easy.
  2. Yeah, cond would be better. Is http://github.com/wh5a/paktahn/commit/1c079e6d43c8303c65a7461e25347ff56f0f7b11 what you had in mind?
  3. Obviously I shouldn't do copy-and-paste.
@wh5a

This comment has been minimized.

Show comment
Hide comment
@wh5a

wh5a Jan 2, 2010

Owner

Damn, where did my comment go? Anyway, please check out http://github.com/wh5a/paktahn/commit/1c079e6d43c8303c65a7461e25347ff56f0f7b11

Owner

wh5a replied Jan 2, 2010

Damn, where did my comment go? Anyway, please check out http://github.com/wh5a/paktahn/commit/1c079e6d43c8303c65a7461e25347ff56f0f7b11

Please sign in to comment.