-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
build.el
47 lines (45 loc) · 1.78 KB
/
build.el
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
(require 'lisp-mnt)
(defun write-readme (commentary dir)
(with-current-buffer (find-file-noselect (format "%s/README" dir))
(insert commentary)
(goto-char (point-min))
(save-excursion
(when (re-search-forward "^;;; Commentary:\n" nil t)
(replace-match ""))
(when (re-search-forward "^\\(;;;\\) .*\\(\n\\)" nil t)
(replace-match "==" nil t nil 1)
(replace-match " ==\n" nil t nil 2))
(goto-char (point-min))
(while (re-search-forward "^\\(;; ?\\)" nil t)
(replace-match ""))
(goto-char (point-min))
(when (re-search-forward "\\`\\( *\n\\)+" nil t)
(replace-match "")))
(delete-trailing-whitespace)
(save-buffer 0)))
(defun build ()
(with-current-buffer (find-file-noselect "robe.el")
(ignore-errors (make-directory "build"))
(let* ((name "robe")
(version (lm-version))
(summary (lm-summary))
(depends (lm-header "package-requires"))
(commentary (lm-commentary))
(default-directory (concat default-directory "build/"))
(dir (format "%s-%s" name version)))
(when (file-exists-p dir)
(delete-directory dir t))
(make-directory dir)
(dolist (file (directory-files ".." t (format "%s.*\\.el\\'" name)))
(copy-file file dir))
(copy-directory "../lib" dir)
(write-readme commentary dir)
(with-temp-buffer
(insert (format "(define-package \"%s\" \"%s\"\n \"%s\"\n '%s)"
name version summary depends))
(write-region (point-min) (point-max)
(format "%s/%s-pkg.el" dir name)))
(with-temp-buffer
(call-process "tar" nil (current-buffer) nil "-cvf"
(format "%s.tar" dir) dir)
(princ (buffer-string))))))