0

At my work (Windows 7), we don't have access to elpa or melpa, but we have a network drive which contains emacs packages that have been manually downloaded and approved.

Using code similar to the following (heavily based on https://emacs.stackexchange.com/a/17408/5142) Emacs users are able to have a MELPA-like experience.

(require 'package)
(setq myelpa-msde "//network/fsf/emacs-plugins/"
      myelpa (expand-file-name "myelpa/" user-emacs-directory)
      package-archives `(("myelpa" . ,myelpa))
      use-package-always-ensure t)
(package-initialize)
(unless (file-exists-p myelpa)
  (require 'package-x)
  (setq package-archive-upload-base myelpa)
  (mkdir myelpa)
  (dolist (file (directory-files myelpa-msde 'fqn "\\.*[.]\\(el\\|tar\\)"))
    (message "Preparing %s" file)
    (package-upload-file file)
    (when (string= (file-name-extension file) "tar")
      (copy-file file myelpa 'force)))
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)

However, look at that again

    (when (string= (file-name-extension file) "tar")
      (copy-file file myelpa 'force)))

without this hack, any tar file that gets uploaded to the "myelpa" local repository is corrupt (it seems to be a file containing just the directory listing of the original tar). The package index is updated correctly, so I was able to apply this workaround by just force copying the tarball again.

Is this a bug in Emacs or am I doing it wrong? According to https://www.gnu.org/software/emacs/manual/html_node/elisp/Package-Archives.html I would have thought this would be considered a "multi file package" and just work.

  • Have you tried to re-use MELPAs build scripts? I think they might fit your purpose better than package-x – lunaryorn Dec 25 '15 at 9:18
  • @lunaryorn what do they do that my (working) script above doesn't do? – fommil Dec 25 '15 at 22:25
1

I've just run up against just this issue. It seems to me that what package-upload-file does is go to the buffer containing the tar file, set a string variable to the contents of the buffer by calling function buffer-substring-no-properties, then copy that string into your repository.

Trouble is, your tar-file buffer is in tar-mode, and so its contents are simply a listing of the items in the tar-file. And that listing is what gets copied, not the actual tar data. (My Emacs is version 24.5.1.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.