]> code.delx.au - gnu-emacs-elpa/blob - packages/load-relative/el-get-install.el
e175e28003ddcc08e2704e8c7683cb622152628c
[gnu-emacs-elpa] / packages / load-relative / el-get-install.el
1 (eval-when-compile
2 (defvar el-get-sources)
3 )
4
5 (declare-function el-get-post-install 'el-get)
6
7 (add-to-list 'load-path "~/.emacs.d/el-get/el-get")
8
9 ;;; el-get-install.el --- installer for the lazy
10 ;;
11 ;; Copyright (C) 2010 Dimitri Fontaine
12 ;;
13 ;; Author: Dimitri Fontaine <dim@tapoueh.org>
14 ;; URL: http://www.emacswiki.org/emacs/el-get.el
15 ;; Created: 2010-06-17
16 ;; Keywords: emacs package elisp install elpa git git-svn bzr cvs apt-get fink http http-tar
17 ;; Licence: WTFPL, grab your copy here: http://sam.zoy.org/wtfpl/
18 ;;
19 ;; This file is NOT part of GNU Emacs.
20 ;;
21 ;; bootstrap your el-get installation, the goal is then to use el-get to
22 ;; update el-get.
23 ;;
24 ;; So the idea is that you copy/paste this code into your *scratch* buffer,
25 ;; hit C-j, and you have a working el-get.
26
27 (let ((el-get-root
28 (file-name-as-directory
29 (or (bound-and-true-p el-get-dir)
30 (concat (file-name-as-directory user-emacs-directory) "el-get")))))
31
32 (when (file-directory-p el-get-root)
33 (add-to-list 'load-path el-get-root))
34
35 ;; try to require el-get, failure means we have to install it
36 (unless (require 'el-get nil t)
37 (unless (file-directory-p el-get-root)
38 (make-directory el-get-root t))
39
40 (let* ((package "el-get")
41 (buf (switch-to-buffer "*el-get bootstrap*"))
42 (pdir (file-name-as-directory (concat el-get-root package)))
43 (git (or (executable-find "git")
44 (error "Unable to find `git'")))
45 (url (or (bound-and-true-p el-get-git-install-url)
46 "http://github.com/dimitri/el-get.git"))
47 (default-directory el-get-root)
48 (process-connection-type nil) ; pipe, no pty (--no-progress)
49
50 ;; First clone el-get
51 (status
52 (call-process
53 git nil `(,buf t) t "--no-pager" "clone" "-v" url package)))
54
55 (unless (zerop status)
56 (error "Couldn't clone el-get from the Git repository: %s" url))
57
58 ;; switch branch if we have to
59 (let* ((branch (cond
60 ;; Check if a specific branch is requested
61 ((bound-and-true-p el-get-install-branch))
62 ;; Check if master branch is requested
63 ((boundp 'el-get-master-branch) "master")
64 ;; Read the default branch from the el-get recipe
65 ((plist-get (with-temp-buffer
66 (insert-file-contents-literally
67 (expand-file-name "recipes/el-get.rcp" pdir))
68 (read (current-buffer)))
69 :branch))
70 ;; As a last resort, use the master branch
71 ("master")))
72 (remote-branch (format "origin/%s" branch))
73 (default-directory pdir)
74 (bstatus
75 (if (string-equal branch "master")
76 0
77 (call-process git nil (list buf t) t "checkout" "-t" remote-branch))))
78 (unless (zerop bstatus)
79 (error "Couldn't `git checkout -t %s`" branch)))
80
81 (add-to-list 'load-path pdir)
82 (load package)
83 (let ((el-get-default-process-sync t) ; force sync operations for installer
84 (el-get-verbose t)) ; let's see it all
85 (el-get-post-install "el-get"))
86 (with-current-buffer buf
87 (goto-char (point-max))
88 (insert "\nCongrats, el-get is installed and ready to serve!")))))
89
90
91 (declare-function el-get 'el-get)
92
93 ;; now either el-get is `require'd already, or have been `load'ed by the
94 ;; el-get installer.
95 (setq
96 el-get-sources
97 '(el-get ; el-get is self-hosting
98 loc-changes ; loc marks in buffers
99 list-utils ; list utilities like list-utils-flatten
100 load-relative ; load emacs lisp relative to emacs source
101 test-simple ; simple test framework
102 ))
103
104 ;; install new packages and init already installed packages
105 (el-get 'sync '(test-simple))