emacscollective / borg

Assimilate Emacs packages as Git submodules
https://emacsmirror.net/manual/borg
GNU General Public License v3.0
255 stars 28 forks source link

Auto install a package's dependent tree #100

Closed lld2001 closed 3 years ago

lld2001 commented 3 years ago

I need to automatically install a package. A package's dependent tree may be lengthy such as ivy. Maybe there are some tricks that I haven't read.

tarsius commented 3 years ago

A package's dependent tree may be lengthy such as ivy.

Most of these dependencies are not mandatory and that's one of the reasons why borg does not automatically install dependencies: often it is up to the user to decide which packages to install. In this case for example you may choose not to install hydra, in which case it would be advisable to add ivy-hydra.el to submodule.ivy.no-byte-compile in .gitmodules.

lld2001 commented 3 years ago

Thanks for your tips.

I'm migrating to borg from Doom private config which contain 244 packages right now. I know many of them can be excluded. But inspect every single package and it's dependency may lead me crazy.

Could you give me some suggestions about this migrating work.

lld2001 commented 3 years ago

Do you share your dotemacs publicly? I can't find it in your github repos.

tarsius commented 3 years ago

Could you give me some suggestions about this migrating work.

Compile a list of all package that are installed in your old configuration. Loop over that borg-assimilateing each one. There will be many warnings and errors. Loop again, there should be way fewer warnings now.

Do you share your dotemacs publicly?

No. It's not really very interesting. It's based on the all branch of the emacs.g repository.

lld2001 commented 3 years ago

Thank you. I use this snippet to clone all dependency.

(let* (pkg url)
  (dolist (el '(all-list of my packages ))
    (setq pkg (epkg (symbol-name el)))
    (setq url (and pkg
                   (if (or (epkg-git-package-p pkg)
                           (epkg-github-package-p pkg)
                           (epkg-orphaned-package-p pkg)
                           (epkg-gitlab-package-p pkg))
                       (eieio-oref pkg 'url)
                     (eieio-oref pkg 'mirror-url))))
    (when url
      (pcase-dolist (`(,orig . ,base) borg-rewrite-urls-alist)
        (when (string-prefix-p orig url)
          (setq url (concat base (substring url (length orig)))))))
    (when url
      (condition-case err
          (borg-assimilate (symbol-name el) url)
        ;; The handler.
        (error                        ; Condition.
         ;; Display the usual message for this error.
         (print el)
             (message "%s" (error-message-string err))
         )))))

But the treemacs did not correctly build. No .elc generated. The borg-assimilated finished normally.

(08:27:06) Building treemacs

Initializing drones...done (194 drones in 2.045s)
 Creating e:/emacs/.emacs.d/lib/treemacs/treemacs-autoloads.el...
Done (Total of 0 files compiled)

Process emacs ... --eval (borg-build "treemacs") finished
lld2001 commented 3 years ago

Maybe the load-path of treemacs is not correctly set.

(borg-load-path "treemacs")  ;;("e:/emacs/.emacs.d/lib/treemacs/")
                                            ;; should be e:/emacs/.emacs.d/lib/treemacs/src/elisp 
                                            ;; there are some src located in  e:/emacs/.emacs.d/lib/treemacs/src/extra
(defun borg-load-path (clone)
  "Return the `load-path' for the clone named CLONE."
  (let ((repo (borg-worktree clone))
        (path (borg-get-all clone "load-path")))
    (if  path
        (mapcar (lambda (d) (expand-file-name d repo)) path)
      (let ((elisp (expand-file-name "elisp" repo))
            (lisp (expand-file-name "lisp" repo)))
        (list (cond ((file-exists-p elisp) elisp)
                    ((file-exists-p lisp) lisp)
                    (t repo)))))))

In treemacs package, there's an extra src directory.