el-get-brew.el 2.96 KB
Newer Older
Julien Fantin's avatar
Julien Fantin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
;;; el-get --- Manage the external elisp bits and pieces you depend upon
;;
;; Copyright (C) 2010-2011 Dimitri Fontaine
;;
;; Author: Dimitri Fontaine <dim@tapoueh.org>
;; URL: http://www.emacswiki.org/emacs/el-get
;; GIT: https://github.com/dimitri/el-get
;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
;;
;; This file is NOT part of GNU Emacs.
;;
;; Install
;;     Please see the README.asciidoc file from the same distribution

(require 'el-get-apt-get)

(defcustom el-get-brew (executable-find "brew")
  "The brew executable."
  :group 'el-get
  :type 'directory)

(defcustom el-get-brew-base "/usr/local/bin"
  "Where to link the el-get symlink to, /<package> will get appended."
  :group 'el-get
  :type 'file)

(defcustom el-get-brew-install-hook nil
  "Hook run after brew install."
  :group 'el-get
  :type 'hook)

(defcustom el-get-brew-remove-hook nil
  "Hook run after brew remove."
  :group 'el-get
  :type 'hook)

(defun el-get-brew-install (package url post-install-fun)
  "brew install PACKAGE"
  (let* ((name (format "*brew install %s*" package))
	 (pkgname (el-get-as-string package))
	 (ok   (format "Package %s installed." package))
	 (ko   (format "Could not install package %s." package)))
    (el-get-start-process-list
     package
     `((:command-name ,name
		      :buffer-name ,name
                      :default-directory ,el-get-dir
		      :program ,el-get-brew
		      :args ("install" ,pkgname)
		      :message ,ok
		      :error ,ko))
     post-install-fun)))

(add-hook 'el-get-brew-install-hook 'el-get-dpkg-symlink)

56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
(defun el-get-brew-update (package url post-update-fun)
  "brew update PACKAGE"
  (let* ((name (format "*brew update %s*" package))
	 (pkgname (el-get-as-string package))
	 (ok   (format "Package %s updated." package))
	 (ko   (format "Could not update package %s." package)))
    (el-get-start-process-list
     package
     `((:command-name ,name
		      :buffer-name ,name
                      :default-directory ,el-get-dir
		      :program ,el-get-brew
		      :args ("upgrade" ,pkgname)
		      :message ,ok
		      :error ,ko))
     post-update-fun)))

Julien Fantin's avatar
Julien Fantin committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
(defun el-get-brew-remove (package url post-remove-fun)
  "brew remove PACKAGE. URL is there for API compliance."
  (let* ((name (format "*brew remove %s*" package))
         (pkgname (el-get-as-string package))
	 (ok   (format "Package %s removed." package))
	 (ko   (format "Could not remove package %s." package)))
    (el-get-start-process-list
     package
     `((:command-name ,name
		      :buffer-name ,name
                      :default-directory ,el-get-dir
		      :program ,el-get-brew
		      :args ("remove" ,pkgname)
		      :message ,ok
		      :error ,ko))
     post-remove-fun)))

(add-hook 'el-get-brew-remove-hook 'el-get-dpkg-remove-symlink)

92 93 94 95 96 97
(el-get-register-method :brew
  :install #'el-get-brew-install
  :update #'el-get-brew-update
  :remove #'el-get-brew-remove
  :install-hook #'el-get-brew-install-hook
  :remove-hook #'el-get-brew-remove-hook)
Julien Fantin's avatar
Julien Fantin committed
98 99

(provide 'el-get-brew)