]> code.delx.au - gnu-emacs-elpa/blob - admin/archive-contents.el
Add 'packages/diff-hl/' from commit '80abec80ea5c060470a34e2d2ed593f1bb9dc5eb'
[gnu-emacs-elpa] / admin / archive-contents.el
1 ;;; archive-contents.el --- Auto-generate an Emacs Lisp package archive. -*- lexical-binding:t -*-
2
3 ;; Copyright (C) 2011, 2012, 2013 Free Software Foundation, Inc
4
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
11
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 ;;; Commentary:
21
22 ;;; Code:
23
24 (eval-when-compile (require 'cl))
25 (require 'lisp-mnt)
26 (require 'package)
27 (require 'pcase)
28
29 (defconst archive-contents-subdirectory-regexp
30 "\\([^.].*?\\)-\\([0-9]+\\(?:[.][0-9]+\\|\\(?:pre\\|beta\\|alpha\\)[0-9]+\\)*\\)")
31
32 (defconst archive-re-no-dot "\\`\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"
33 "Regular expression matching all files except \".\" and \"..\".")
34
35 (defun archive--version-to-list (vers)
36 (when vers
37 (let ((l (version-to-list vers)))
38 ;; Signal an error for things like "1.02" which is parsed as "1.2".
39 (assert (equal vers (package-version-join l)) nil
40 "Unsupported version syntax %S" vers)
41 l)))
42
43 (defun archive--convert-require (elt)
44 (list (car elt)
45 (archive--version-to-list (car (cdr elt)))))
46
47 (defun archive--strip-rcs-id (str)
48 "Strip RCS version ID from the version string STR.
49 If the result looks like a dotted numeric version, return it.
50 Otherwise return nil."
51 (when str
52 (when (string-match "\\`[ \t]*[$]Revision:[ \t]+" str)
53 (setq str (substring str (match-end 0))))
54 (condition-case nil
55 (if (archive--version-to-list str)
56 str)
57 (error str))))
58
59 (defun archive--delete-elc-files (dir &optional only-orphans)
60 "Recursively delete all .elc files in DIR.
61 Delete backup files also."
62 (dolist (f (directory-files dir t archive-re-no-dot))
63 (cond ((file-directory-p f)
64 (archive--delete-elc-files f))
65 ((or (and (string-match "\\.elc\\'" f)
66 (not (and only-orphans
67 (file-readable-p (replace-match ".el" t t f)))))
68 (backup-file-name-p f))
69 (delete-file f)))))
70
71 (defun batch-make-archive ()
72 "Process package content directories and generate the archive-contents file."
73 (let ((packages '(1))) ; format-version.
74 (dolist (dir (directory-files default-directory nil archive-re-no-dot))
75 (condition-case v
76 (if (not (file-directory-p dir))
77 (message "Skipping non-package file %s" dir)
78 (let* ((pkg (file-name-nondirectory dir))
79 (autoloads-file (expand-file-name (concat pkg "-autoloads.el") dir))
80 simple-p)
81 ;; Omit autoloads and .elc files from the package.
82 (if (file-exists-p autoloads-file)
83 (delete-file autoloads-file))
84 (archive--delete-elc-files dir)
85 ;; Test whether this is a simple or multi-file package.
86 (setq simple-p (archive--simple-package-p dir pkg))
87 (push (if (car simple-p)
88 (apply #'archive--process-simple-package
89 dir pkg (cdr simple-p))
90 (if simple-p
91 (apply #'archive--write-pkg-file
92 dir pkg (cdr simple-p)))
93 (archive--process-multi-file-package dir pkg))
94 packages)))
95 ((debug error) (error "Error in %s: %S" dir v))))
96 (with-temp-buffer
97 (pp (nreverse packages) (current-buffer))
98 (write-region nil nil "archive-contents"))))
99
100 (defconst archive--revno-re "[0-9a-f]+")
101
102 (defun archive-prepare-packages (srcdir)
103 "Prepare the `packages' directory inside the Git checkout.
104 Expects to be called from within the `packages' directory.
105 \"Prepare\" here is for subsequent construction of the packages and archive,
106 so it is meant to refresh any generated files we may need.
107 Currently only refreshes the ChangeLog files."
108 (setq srcdir (file-name-as-directory (expand-file-name srcdir)))
109 (let* ((wit ".changelog-witness")
110 (prevno (with-temp-buffer
111 (ignore-errors (insert-file-contents wit))
112 (if (looking-at (concat archive--revno-re "$"))
113 (match-string 0)
114 (error "Can't find previous revision name"))))
115 (new-revno
116 (or (with-temp-buffer
117 (let ((default-directory srcdir))
118 (call-process "git" nil '(t) nil "rev-parse" "HEAD")
119 (goto-char (point-min))
120 (when (looking-at (concat archive--revno-re "$"))
121 (match-string 0))))
122 (error "Couldn't find the current revision's name")))
123 (pkgs '()))
124 (unless (equal prevno new-revno)
125 (with-temp-buffer
126 (let ((default-directory srcdir))
127 (unless (zerop (call-process "git" nil '(t) nil "diff"
128 "--dirstat=cumulative,0"
129 prevno))
130 (error "Error signaled by git diff --dirstat %d" prevno)))
131 (goto-char (point-min))
132 (while (re-search-forward "^[ \t.0-9%]* packages/\\([-[:alnum:]]+\\)/$"
133 nil t)
134 (push (match-string 1) pkgs))))
135 (let ((default-directory (expand-file-name "packages/")))
136 (dolist (pkg pkgs)
137 (condition-case v
138 (if (file-directory-p pkg)
139 (archive--make-changelog pkg (expand-file-name "packages/"
140 srcdir)))
141 (error (message "Error: %S" v)))))
142 (write-region new-revno nil wit nil 'quiet)
143 ;; Also update the ChangeLog of external packages.
144 (let ((default-directory (expand-file-name "packages/")))
145 (dolist (dir (directory-files "."))
146 (and (not (member dir '("." "..")))
147 (file-directory-p dir)
148 (let ((index (expand-file-name
149 (concat "packages/" dir "/.git/index")
150 srcdir))
151 (cl (expand-file-name "ChangeLog" dir)))
152 (and (file-exists-p index)
153 (or (not (file-exists-p cl))
154 (file-newer-than-file-p index cl))))
155 (archive--make-changelog
156 dir (expand-file-name "packages/" srcdir)))))
157 ))
158
159 (defun archive--simple-package-p (dir pkg)
160 "Test whether DIR contains a simple package named PKG.
161 Return a list (SIMPLE VERSION DESCRIPTION REQ EXTRAS), where
162 SIMPLE is non-nil if the package is indeed simple;
163 VERSION is the version string of the simple package;
164 DESCRIPTION is the brief description of the package;
165 REQ is a list of requirements;
166 EXTRAS is an alist with additional metadata.
167 Otherwise, return nil."
168 (let* ((pkg-file (expand-file-name (concat pkg "-pkg.el") dir))
169 (mainfile (expand-file-name (concat pkg ".el") dir))
170 (files (directory-files dir nil "\\.el\\'")))
171 (setq files (delete (concat pkg "-pkg.el") files))
172 (setq files (delete (concat pkg "-autoloads.el") files))
173 (cond
174 ((and (not (file-exists-p pkg-file))
175 (file-exists-p mainfile))
176 (with-temp-buffer
177 (insert-file-contents mainfile)
178 (goto-char (point-min))
179 (if (not (looking-at ";;;.*---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$"))
180 (error "Can't parse first line of %s" mainfile)
181 ;; Grab the other fields, which are not mandatory.
182 (let* ((description (match-string 1))
183 (version
184 (or (archive--strip-rcs-id (lm-header "package-version"))
185 (archive--strip-rcs-id (lm-header "version"))
186 (error "Missing `version' header")))
187 (requires-str (lm-header "package-requires"))
188 (pt (lm-header "package-type"))
189 (simple (if pt (equal pt "simple") (= (length files) 1)))
190 (url (or (lm-header "url")
191 (format "http://elpa.gnu.org/packages/%s.html" pkg)))
192 (req
193 (if requires-str
194 (mapcar 'archive--convert-require
195 (car (read-from-string requires-str))))))
196 (list simple version description req (list (cons :url url)))))))
197 ((not (file-exists-p pkg-file))
198 (error "Can find single file nor package desc file in %s" dir)))))
199
200 (defun archive--process-simple-package (dir pkg vers desc req extras)
201 "Deploy the contents of DIR into the archive as a simple package.
202 Rename DIR/PKG.el to PKG-VERS.el, delete DIR, and return the descriptor."
203 ;; Write DIR/foo.el to foo-VERS.el and delete DIR
204 (rename-file (expand-file-name (concat pkg ".el") dir)
205 (concat pkg "-" vers ".el"))
206 ;; Add the content of the ChangeLog.
207 (let ((cl (expand-file-name "ChangeLog" dir)))
208 (with-current-buffer (find-file-noselect (concat pkg "-" vers ".el"))
209 (goto-char (point-max))
210 (re-search-backward "^;;;.*ends here")
211 (re-search-backward "^(provide")
212 (skip-chars-backward " \t\n")
213 (insert "\n\n;;;; ChangeLog:\n\n")
214 (let* ((start (point))
215 (end (copy-marker start t)))
216 (insert-file-contents cl)
217 (goto-char end)
218 (unless (bolp) (insert "\n"))
219 (while (progn (forward-line -1) (>= (point) start))
220 (insert ";; ")))
221 (set (make-local-variable 'backup-inhibited) t)
222 (basic-save-buffer) ;Less chatty than save-buffer.
223 (kill-buffer)))
224 (delete-directory dir t)
225 (cons (intern pkg) (vector (archive--version-to-list vers)
226 req desc 'single extras)))
227
228 (defun archive--make-changelog (dir srcdir)
229 "Export Git log info of DIR into a ChangeLog file."
230 (message "Refreshing ChangeLog in %S" dir)
231 (let ((default-directory (file-name-as-directory (expand-file-name dir))))
232 (with-temp-buffer
233 (set-buffer-multibyte nil)
234 (let ((coding-system-for-read 'binary)
235 (coding-system-for-write 'binary))
236 (if (file-readable-p "ChangeLog") (insert-file-contents "ChangeLog"))
237 (let ((old-md5 (md5 (current-buffer))))
238 (erase-buffer)
239 (let ((default-directory
240 (file-name-as-directory (expand-file-name dir srcdir))))
241 (call-process "git" nil (current-buffer) nil
242 "log" "--date=short"
243 "--format=%cd %aN <%ae>%n%n%w(80,8,8)%B%n"
244 "."))
245 (tabify (point-min) (point-max))
246 (goto-char (point-min))
247 (while (re-search-forward "\n\n\n+" nil t)
248 (replace-match "\n\n"))
249 (if (equal old-md5 (md5 (current-buffer)))
250 (message "ChangeLog's md5 unchanged for %S" dir)
251 (write-region (point-min) (point-max) "ChangeLog" nil 'quiet)))))))
252
253 (defun archive--alist-to-plist (alist)
254 (apply #'nconc (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist)))
255
256 (defun archive--plist-to-alist (plist)
257 (let (alist)
258 (while plist
259 (let ((value (cadr plist)))
260 (when value
261 (push (cons (car plist) value)
262 alist)))
263 (setq plist (cddr plist)))
264 alist))
265
266 (defun archive--process-multi-file-package (dir pkg)
267 "Deploy the contents of DIR into the archive as a multi-file package.
268 Rename DIR/ to PKG-VERS/, and return the descriptor."
269 (let* ((exp (archive--multi-file-package-def dir pkg))
270 (vers (nth 2 exp))
271 (req-exp (nth 4 exp))
272 (req (mapcar 'archive--convert-require
273 (if (eq 'quote (car-safe req-exp)) (nth 1 req-exp)
274 (when req-exp
275 (error "REQ should be a quoted constant: %S"
276 req-exp)))))
277 (extras (archive--plist-to-alist (nthcdr 5 exp))))
278 (unless (equal (nth 1 exp) pkg)
279 (error (format "Package name %s doesn't match file name %s"
280 (nth 1 exp) pkg)))
281 (rename-file dir (concat pkg "-" vers))
282 (cons (intern pkg) (vector (archive--version-to-list vers)
283 req (nth 3 exp) 'tar extras))))
284
285 (defun archive--multi-file-package-def (dir pkg)
286 "Return the `define-package' form in the file DIR/PKG-pkg.el."
287 (let ((pkg-file (expand-file-name (concat pkg "-pkg.el") dir)))
288 (with-temp-buffer
289 (unless (file-exists-p pkg-file)
290 (error "File not found: %s" pkg-file))
291 (insert-file-contents pkg-file)
292 (goto-char (point-min))
293 (read (current-buffer)))))
294
295 (defun archive--refresh-pkg-file ()
296 (let* ((dir (directory-file-name default-directory))
297 (pkg (file-name-nondirectory dir))
298 (simple-p (archive--simple-package-p dir pkg)))
299 (if simple-p
300 (progn
301 ;; (message "Refreshing pkg description of %s" pkg)
302 (apply 'archive--write-pkg-file dir pkg (cdr simple-p)))
303 ;; (message "Not refreshing pkg description of %s" pkg)
304 )))
305
306 (defun archive--write-pkg-file (pkg-dir name version desc requires extras)
307 (let ((pkg-file (expand-file-name (concat name "-pkg.el") pkg-dir))
308 (print-level nil)
309 (print-quoted t)
310 (print-length nil))
311 (write-region
312 (concat (format ";; Generated package description from %s.el\n"
313 name)
314 (prin1-to-string
315 (nconc
316 (list 'define-package
317 name
318 version
319 desc
320 (list 'quote
321 ;; Turn version lists into string form.
322 (mapcar
323 (lambda (elt)
324 (list (car elt)
325 (package-version-join (cadr elt))))
326 requires)))
327 (archive--alist-to-plist extras)))
328 "\n")
329 nil
330 pkg-file)))
331
332 ;;; Make the HTML pages for online browsing.
333
334 (defun archive--html-header (title)
335 (format "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">
336 <html>
337 <head>
338 <title>%s</title>
339 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
340 </head>
341 <body>
342 <h1 align=\"center\">%s</h1>\n"
343 title title))
344
345 (defun archive--html-bytes-format (bytes) ;Aka memory-usage-format.
346 (setq bytes (/ bytes 1024.0))
347 (let ((units '(;; "B"
348 "kB" "MB" "GB" "TB")))
349 (while (>= bytes 1024)
350 (setq bytes (/ bytes 1024.0))
351 (setq units (cdr units)))
352 (cond
353 ;; ((integerp bytes) (format "%4d%s" bytes (car units)))
354 ((>= bytes 100) (format "%4.0f%s" bytes (car units)))
355 ((>= bytes 10) (format "%4.1f%s" bytes (car units)))
356 (t (format "%4.2f%s" bytes (car units))))))
357
358 (defun archive--get-prop (prop name srcdir mainsrcfile)
359 (let ((kprop (intern (format ":%s" (downcase prop)))))
360 (or
361 (let ((pkgdescfile (expand-file-name (format "%s-pkg.el" name)
362 srcdir)))
363 (when (file-readable-p pkgdescfile)
364 (with-temp-buffer
365 (insert-file-contents pkgdescfile)
366 (let ((desc (read (current-buffer))))
367 (plist-get (cdr desc) kprop)))))
368 (when (file-readable-p mainsrcfile)
369 (with-temp-buffer
370 (insert-file-contents mainsrcfile)
371 (lm-header prop))))))
372
373 (defun archive--get-section (hsection fsection srcdir mainsrcfile)
374 (when (consp fsection)
375 (while (cdr-safe fsection)
376 (setq fsection
377 (if (file-readable-p (expand-file-name (car fsection) srcdir))
378 (car fsection)
379 (cdr fsection))))
380 (when (consp fsection) (setq fsection (car fsection))))
381 (cond
382 ((file-readable-p (expand-file-name fsection srcdir))
383 (with-temp-buffer
384 (insert-file-contents (expand-file-name fsection srcdir))
385 (buffer-string)))
386 ((file-readable-p mainsrcfile)
387 (with-temp-buffer
388 (insert-file-contents mainsrcfile)
389 (let ((start (lm-section-start hsection)))
390 (when start
391 (insert
392 (prog1
393 (buffer-substring start (lm-section-end hsection))
394 (erase-buffer)))
395 (emacs-lisp-mode)
396 (goto-char (point-min))
397 (delete-region (point) (line-beginning-position 2))
398 (uncomment-region (point-min) (point-max))
399 (when (looking-at "^\\([ \t]*\n\\)+")
400 (replace-match ""))
401 (goto-char (point-max))
402 (skip-chars-backward " \t\n")
403 (delete-region (point) (point-max))
404 (buffer-string)))))))
405
406 (defun archive--quote (txt)
407 (replace-regexp-in-string "<" "&lt;"
408 (replace-regexp-in-string "&" "&amp;" txt)))
409
410 (defun archive--insert-repolinks (name srcdir mainsrcfile url)
411 (if url
412 (insert (format "<p>Origin: <a href=%S>%s</a></p>\n"
413 url (archive--quote url)))
414 (let* ((externals
415 (with-temp-buffer
416 (insert-file-contents
417 (expand-file-name "../../../elpa/externals-list" srcdir))
418 (read (current-buffer))))
419 (external (eq :external (nth 1 (assoc name externals))))
420 (git-sv "http://git.savannah.gnu.org/")
421 (urls (if external
422 '("cgit/emacs/elpa.git/?h=externals/"
423 "gitweb/?p=emacs/elpa.git;a=shortlog;h=refs/heads/externals/")
424 '("cgit/emacs/elpa.git/tree/packages/"
425 "gitweb/?p=emacs/elpa.git;a=tree;f=packages/"))))
426 (insert (format
427 (concat "<p>Browse repository: <a href=%S>%s</a>"
428 " or <a href=%S>%s</a></p>\n")
429 (concat git-sv (nth 0 urls) name)
430 'CGit
431 (concat git-sv (nth 1 urls) name)
432 'Gitweb)))))
433
434 (defun archive--html-make-pkg (pkg files)
435 (let* ((name (symbol-name (car pkg)))
436 (latest (package-version-join (aref (cdr pkg) 0)))
437 (srcdir (expand-file-name name "../../build/packages"))
438 (mainsrcfile (expand-file-name (format "%s.el" name) srcdir))
439 (desc (aref (cdr pkg) 2)))
440 (with-temp-buffer
441 (insert (archive--html-header (format "GNU ELPA - %s" name)))
442 (insert (format "<p>Description: %s</p>\n" (archive--quote desc)))
443 (let* ((file (cdr (assoc latest files)))
444 (attrs (file-attributes file)))
445 (insert (format "<p>Latest: <a href=%S>%s</a>, %s, %s</p>\n"
446 file (archive--quote file)
447 (format-time-string "%Y-%b-%d" (nth 5 attrs))
448 (archive--html-bytes-format (nth 7 attrs)))))
449 (let ((maint (archive--get-prop "Maintainer" name srcdir mainsrcfile)))
450 (when maint
451 (insert (format "<p>Maintainer: %s</p>\n" (archive--quote maint)))))
452 (archive--insert-repolinks name srcdir mainsrcfile
453 (cdr (assoc :url (aref (cdr pkg) 4))))
454 (let ((rm (archive--get-section
455 "Commentary" '("README" "README.rst"
456 ;; Most README.md files seem to be currently
457 ;; worse than the Commentary: section :-(
458 ;; "README.md"
459 "README.org")
460 srcdir mainsrcfile)))
461 (when rm
462 (write-region rm nil (concat name "-readme.txt"))
463 (insert "<h2>Full description</h2><pre>\n" (archive--quote rm)
464 "\n</pre>\n")))
465 (unless (< (length files) 2)
466 (insert (format "<h2>Old versions</h2><table cellpadding=\"3\" border=\"1\">\n"))
467 (dolist (file files)
468 (unless (equal (pop file) latest)
469 (let ((attrs (file-attributes file)))
470 (insert (format "<tr><td><a href=%S>%s</a></td><td>%s</td><td>%s</td>\n"
471 file (archive--quote file)
472 (format-time-string "%Y-%b-%d" (nth 5 attrs))
473 (archive--html-bytes-format (nth 7 attrs)))))))
474 (insert "</table>\n"))
475 (let ((news (archive--get-section
476 "News" '("NEWS" "NEWS.rst" "NEWS.md" "NEWS.org")
477 srcdir mainsrcfile)))
478 (when news
479 (insert "<h2>News</h2><pre>\n" (archive--quote news) "\n</pre>\n")))
480 (insert "</body>\n")
481 (write-region (point-min) (point-max) (concat name ".html")))))
482
483 (defun archive--html-make-index (pkgs)
484 (with-temp-buffer
485 (insert (archive--html-header "GNU ELPA Packages"))
486 (insert "<table cellpadding=\"3\" border=\"1\">\n")
487 (insert "<tr><th>Package</th><th>Version</th><th>Description</th></tr>\n")
488 (dolist (pkg pkgs)
489 (insert (format "<tr><td><a href=\"%s.html\">%s</a></td><td>%s</td><td>%s</td></tr>\n"
490 (car pkg) (car pkg)
491 (package-version-join (aref (cdr pkg) 0))
492 (aref (cdr pkg) 2))))
493 (insert "</table></body>\n")
494 (write-region (point-min) (point-max) "index.html")))
495
496 (defun batch-html-make-index ()
497 (let ((packages (make-hash-table :test #'equal))
498 (archive-contents
499 (with-temp-buffer
500 (insert-file-contents "archive-contents")
501 (goto-char (point-min))
502 ;; Skip the first element which is a version number.
503 (cdr (read (current-buffer))))))
504 (dolist (file (directory-files default-directory nil))
505 (cond
506 ((member file '("." ".." "elpa.rss" "index.html" "archive-contents")))
507 ((string-match "\\.html\\'" file))
508 ((string-match "-readme\\.txt\\'" file)
509 (let ((name (substring file 0 (match-beginning 0))))
510 (puthash name (gethash name packages) packages)))
511 ((string-match "-\\([0-9][^-]*\\)\\.\\(tar\\|el\\)\\'" file)
512 (let ((name (substring file 0 (match-beginning 0)))
513 (version (match-string 1 file)))
514 (push (cons version file) (gethash name packages))))
515 (t (message "Unknown file %S" file))))
516 (dolist (pkg archive-contents)
517 (archive--html-make-pkg pkg (gethash (symbol-name (car pkg)) packages)))
518 ;; FIXME: Add (old?) packages that are in `packages' but not in
519 ;; archive-contents.
520 (archive--html-make-index archive-contents)))
521
522 ;;; Maintain external packages.
523
524 (defconst archive--elpa-git-url "git://git.sv.gnu.org/emacs/elpa")
525
526 (defun archive-add/remove/update-externals ()
527 (let ((exts (with-current-buffer (find-file-noselect "externals-list")
528 (goto-char (point-min))
529 (read (current-buffer)))))
530 (let ((default-directory (expand-file-name "packages/")))
531 ;; Remove "old/odd" externals.
532 (dolist (dir (directory-files "."))
533 (cond
534 ((member dir '("." "..")) nil)
535 ((assoc dir exts) nil)
536 ((file-directory-p (expand-file-name (format "%s/.git" dir)))
537 (let ((status
538 (with-temp-buffer
539 (let ((default-directory (file-name-as-directory
540 (expand-file-name dir))))
541 (call-process "git" nil t nil "status" "--porcelain")
542 (buffer-string)))))
543 (if (zerop (length status))
544 (progn (delete-directory dir 'recursive t)
545 (message "Deleted all of %s" dir))
546 (message "Keeping leftover unclean %s:\n%s" dir status))))))
547 (pcase-dolist (`(,dir ,kind ,_url) exts)
548 (cond
549 ((eq kind :subtree) nil) ;Nothing to do.
550 ((not (eq kind :external))
551 (message "Unknown external package kind `%S' for %s" kind dir))
552 ((not (file-exists-p dir))
553 (let* ((branch (concat "externals/" dir))
554 (output
555 (with-temp-buffer
556 ;; FIXME: Use git-new-workdir!
557 (call-process "git" nil t nil "clone"
558 "--reference" ".." "--branch" branch
559 archive--elpa-git-url dir)
560 (buffer-string))))
561 (message "Cloning branch %s:\n%s" dir output)))
562 ((not (file-directory-p (concat dir "/.git")))
563 (message "%s is in the way of an external, please remove!" dir))
564 (t
565 (let ((default-directory (file-name-as-directory
566 (expand-file-name dir))))
567 (with-temp-buffer
568 (message "Running git pull in %S" default-directory)
569 (call-process "git" nil t nil "pull")
570 (message "Updated %s:%s" dir (buffer-string))))
571 ))))))
572
573 (provide 'archive-contents)
574 ;;; archive-contents.el ends here