This problem was solved ages ago. I saw the implemention in Steve Purcell's emacs.d about ten years ago.
The solution uses only Emacs built in package system.
Once it's set up, you don't need manually run M-x package-install-file
from time to time. It won't change your daily workflow to install/upgrade packages.
Step 1, create a local package repository containing old version of packages.
Add file archive-contents
and "magit-1.4.2.tar" into ~/.emacs.d/localelpa
, archive-contents
is like,
(1
(magit . [(1 4 2) nil "blah blah" tar])
)
Step 2, add below content into ~/.emacs.d/init.el
,
(push (cons "localelpa" "~/.emacs.d/localelpa/") package-archives)
(defun my-package--add-to-archive-contents-hack (orig-func &rest args)
(let* ((package (nth 0 args))
(archive (nth 1 args))
(pkg-name (car package))
;; (version (package--ac-desc-version (cdr package)))
(add-to-p (or (string= archive "localelpa")
(not (string-match-p "^magit" (format "%s" pkg-name))))))
(if add-to-p (apply orig-func args))))
(advice-add 'package--add-to-archive-contents :around #'my-package--add-to-archive-contents-hack)
magit-1.x
vsmagit-2.x
). I suspect that you'll have to use an alternative approach for installation. I'm not too familiar with the package manager, though, so someone else may know better.