65

GitHub - redguardtoo/elpa-mirror: Create local emacs package repository. 15 seco...

 6 years ago
source link: https://github.com/redguardtoo/elpa-mirror
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

elpa-mirror

Create local Emacs package repository from installed packages so package upgrade never breaks.

  • Emacs Lisp compile file (*.elc) is not portable for different versions of Emacs. So emacs.d copied from higher version of Emacs might crash in lower version of Emacs
  • Package installation is fast. 15 seconds to install 115 packages
  • The repository could be hosted on USB/Dropbox/GitHub. So you can install packages behind corp firewall
  • Tested with Emacs 25, 26, 27, 28 on OSX/Cygwin/Windows10/Linux

Install

CLI program tar is required. It’s already installed on Windows10/Linux/macOS.

  • Download elpa-mirror.el to somewhere (say ~/.emacs.d/site-lisp/elpa-mirror/)
  • Add below code into your ~/.emacs,
(add-to-list 'load-path "~/.emacs.d/site-lisp/elpa-mirror")
(require 'elpa-mirror)

Usage

M-x elpamr-create-mirror-for-installed to create local repository.

To update existing local repository, run M-x elpamr-create-mirror-for-installed again.

BTW, you can run elpa-mirror.el as a independent script,

mkdir -p ~/myelpa && emacs --batch -l ~/.emacs.d/init.el -l ~/any-directory-you-prefer/elpa-mirror.el --eval='(setq elpamr-default-output-directory "~/myelpa")' --eval='(elpamr-create-mirror-for-installed)'

To use the local repository ~/myelpa/, insert below code into your ~/.emacs,

;; myelpa is the ONLY repository now, dont forget trailing slash in the directory
(setq package-archives '(("myelpa" . "~/myelpa/")))

Repository on Dropbox

Insert below code into ~/.emacs:

;; add-to-list will not override default elpa.
;; So now you have two repositories.
;; One is GNU elpa. Another is myelpa
(add-to-list 'package-archives
             '("myelpa" . "https://dl.dropboxusercontent.com/u/858862/myelpa/"))

Repository on GitHub

My repository is https://github.com/redguardtoo/myelpa.

Insert below code into .emacs:

;; add-to-list will not override default elpa.
;; So now you have two repositories.
;; One is GNU elpa. Another is myelpa
(add-to-list 'package-archives
             '("myelpa" . "https://raw.githubusercontent.com/redguardtoo/myelpa/master/"))

Exclude packages

See elpamr-exclude-packages.

Exclude files/directories in package directory

See elpamr-tar-command-exclude-patterns.

elpamr-exclude-patterns-filter-function lets users define a filter function to exclude files and directories per package. The function returns the result to replace elpamr-tar-command-exclude-patterns.

Below setup adds directory “bin/” into package “vagrant-tramp”.

(setq elpamr-exclude-patterns-filter-function
      (lambda (package-dir)
        (let ((patterns elpamr-tar-command-exclude-patterns))
          (when (string-match "vagrant-tramp" package-dir)
            (setq patterns (remove "*/bin" patterns)))
          patterns)))

Change output directory,

(setq elpamr-default-output-directory "~/myelpa")

Report a Bug

Reproduce the bug, report it at https://github.com/redguardtoo/elpa-mirror, and attach the contents of the *elpa-mirror log* buffer.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK