Subject: bug#63337: [PATCH] package-vc--build-documentation: Fix relative @include statements

From: Philip Kaludercic <[email-masked]>
Date: Fri, 12 May 2023 06:51:19 +0000

Joseph Turner <[email-masked]> writes:

> Philip Kaludercic <[email-masked]> writes:
>
>> Ok, do you have a few example repositories that we can use to test edge-cases?
>
> I first noticed this issue when attempting to build the docs for
> org-transclusion. Besides that, we could select a few package specs
> containing :make at random from
> https://git.savannah.gnu.org/cgit/emacs/elpa.git/tree/elpa-packages ?

One issue I still notice in this case is that if the file doesn't exist,
the issue is raised by `insert-file-contents' which aborts the entire
installation.  Does checking the existence of the file, and continuing
on if this is not the case make sense:

diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index e9794eac783..1c1492d87b2 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -353,28 +353,30 @@ package-vc--build-documentation
          (default-directory (file-name-directory file-name))
          (output (expand-file-name (format "%s.info" pkg-name)))
          clean-up)
-    (when (string-match-p "\\.org\\'" file)
-      (require 'ox)
-      (require 'ox-texinfo)
-      (with-temp-buffer
-        (insert-file-contents file-name)
-        (setq file (make-temp-file "ox-texinfo-"))
-        (org-export-to-file 'texinfo file)
-        (setq clean-up t)))
-    (with-current-buffer (get-buffer-create " *package-vc doc*")
-      (erase-buffer)
-      (cond
-       ((/= 0 (call-process "makeinfo" nil t nil
-                            "--no-split" file "-o" output))
-        (message "Failed to build manual %s, see buffer %S"
-                 file (buffer-name)))
-       ((/= 0 (call-process "install-info" nil t nil
-                            output (expand-file-name "dir")))
-        (message "Failed to install manual %s, see buffer %S"
-                 output (buffer-name)))
-       ((kill-buffer))))
-    (when clean-up
-      (delete-file file))))
+    (if (not (file-exists-p file-name))
+        (message "Documentation file %S for %s not found" file pkg-name)
+      (when (string-match-p "\\.org\\'" file)
+        (require 'ox)
+        (require 'ox-texinfo)
+        (with-temp-buffer
+          (insert-file-contents file-name)
+          (setq file (make-temp-file "ox-texinfo-"))
+          (org-export-to-file 'texinfo file)
+          (setq clean-up t)))
+      (with-current-buffer (get-buffer-create " *package-vc doc*")
+        (erase-buffer)
+        (cond
+         ((/= 0 (call-process "makeinfo" nil t nil
+                              "--no-split" file "-o" output))
+          (message "Failed to build manual %s, see buffer %S"
+                   file (buffer-name)))
+         ((/= 0 (call-process "install-info" nil t nil
+                              output (expand-file-name "dir")))
+          (message "Failed to install manual %s, see buffer %S"
+                   output (buffer-name)))
+         ((kill-buffer))))
+      (when clean-up
+        (delete-file file)))))
 
 (defun package-vc-install-dependencies (requirements)
   "Install missing dependencies, and return missing ones.

> Joseph