Skip to content

Commit

Permalink
Deprecate legacy build functions
Browse files Browse the repository at this point in the history
- Melpa stopped using `package-build--build-single-file-package' a
  while ago.  It is better to consistently use a "NAME-pkg.el" file
  to distribute the metadata of each individual packages, instead
  of adding complexity by patching the "NAME.pkg" file when there
  is only a single library.

- Melpa stopped using `package-build--build-multi-file-package'
  recently, in favor of `package-build--build-package'.  While the
  former also extracted metadata from "NAME-pkg.el", the latter only
  uses "NAME.el".  This makes sense because only very few packages
  provide a "NAME-pkg.el" file, when it does exist it often contains
  outdated information, and [Non]GNU ELPA also ignores these files.
  • Loading branch information
tarsius committed Dec 12, 2024
1 parent 4492f2e commit 760cf53
Showing 1 changed file with 31 additions and 35 deletions.
66 changes: 31 additions & 35 deletions package-build.el
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ then that overrides the value set here."
:group 'package-build
:type 'hook
:options (list #'package-build-tag-version
#'package-build-header-version
#'package-build-pkg-version))
#'package-build-header-version))

(defcustom package-build-snapshot-version-functions
(list #'package-build-timestamp-version)
Expand Down Expand Up @@ -184,25 +183,12 @@ If nil (the default), then all packages are build."
#'package-build--build-package
"Low-level function used to build a package.
The default, `package-build--build-package', builds all packages the
same way. Metadata is extracted from the library whose name matches
the name of the package. The `NAME-pkg.el' file is not used as an
input. The package is distributed as a tarball, containing at least
that library and a generated `NAME-pkg.el' file.
Melpa still uses `package-build--build-multi-file-package'.
Like the above function it uses a tarball for all packages, but it
extracts metadata from both the main library and the `NAME-pkg.el'
file, with non-nil values from the latter taking precedence.
In the distant past, either `package-build--multi-file-package' or
`package-build--single-file-package' were used by Melpa, depending on
the number of libraries. Set this variable to nil to do that again."
The default, `package-build--build-package', extracts metadata from
the library whose name matches the name of the package, and creates
a tarball, containing at least that library and \"NAME-pkg.el\", which
is generated."
:group 'package-build
:type '(choice (const package-build--build-package)
(const package-build--build-multi-file-package)
(const nil)
function))
:type '(choice (const package-build--build-package) function))

(defcustom package-build-run-recipe-org-exports nil
"Whether to export the files listed in the `:org-exports' recipe slot.
Expand Down Expand Up @@ -550,6 +536,8 @@ Return (COMMIT-HASH COMMITTER-DATE VERSION-STRING REVDESC) or nil."
(defun package-build-pkg-version (rcp)
"Determine version specified in the \"NAME-pkg.el\" file.
Return (COMMIT-HASH COMMITTER-DATE VERSION-STRING REVDESC) or nil."
(declare (obsolete "extract version from tag and/or main library instead."
"Package-Build 5.0.0"))
(and-let* ((file (package-build--pkgfile rcp)))
(let ((regexp (package-build--version-regexp rcp))
commit date version)
Expand Down Expand Up @@ -1262,6 +1250,8 @@ is the same as the value of `export_file_name'."

(defun package-build--extract-from-package (rcp files)
"Store information from the \"*-pkg.el\" file from FILES in RCP."
(declare (obsolete "exclusively extract metadata from main library instead."
"Package-Build 5.0.0"))
(let* ((name (oref rcp name))
(file (concat name "-pkg.el"))
(file (or (car (rassoc file files)) file)))
Expand Down Expand Up @@ -1558,20 +1548,15 @@ in `package-build-archive-dir'."
(targets (oref rcp make-targets)))
(package-build--message "Running make %s" (string-join targets " "))
(apply #'package-build--call-sandboxed rcp "make" targets))
(let ((files (package-build-expand-files-spec rcp t)))
(cond
((= (length files) 0)
(package-build--error rcp
"Unable to find files matching recipe patterns"))
(package-build-build-function
(funcall package-build-build-function rcp files))
((= (length files) 1)
(package-build--build-single-file-package rcp files))
(t
(package-build--build-multi-file-package rcp files)))
(when package-build-badge-data
(package-build--write-badge-image
name version package-build-archive-dir))))
(if-let ((files (package-build-expand-files-spec rcp t)))
(funcall (or package-build-build-function
'package-build--legacy-build)
rcp files)
(package-build--error rcp
"Unable to find files matching recipe patterns"))
(when package-build-badge-data
(package-build--write-badge-image
name version package-build-archive-dir)))
(package-build--cleanup rcp))))

(defun package-build--build-package (rcp files)
Expand All @@ -1594,7 +1579,16 @@ in `package-build-archive-dir'."
(delete-directory tmpdir t nil)))
(package-build--write-archive-entry rcp)))

(defun package-build--legacy-build (rcp files)
(declare (obsolete package-build--build-package "Package-Build 5.0.0"))
(with-suppressed-warnings ((obsolete package-build--build-single-file-package
package-build--build-multi-file-package))
(if (= (length files) 1)
(package-build--build-single-file-package rcp files)
(package-build--build-multi-file-package rcp files))))

(defun package-build--build-single-file-package (rcp files)
(declare (obsolete package-build--build-package "Package-Build 5.0.0"))
(oset rcp tarballp nil)
(pcase-let* (((eieio name version) rcp)
(file (caar files))
Expand All @@ -1613,6 +1607,7 @@ in `package-build-archive-dir'."
(package-build--write-archive-entry rcp)))

(defun package-build--build-multi-file-package (rcp files)
(declare (obsolete package-build--build-package "Package-Build 5.0.0"))
(pcase-let* (((eieio name version) rcp)
(tmpdir (file-name-as-directory (make-temp-file name t)))
(target (expand-file-name (concat name "-" version) tmpdir)))
Expand All @@ -1621,7 +1616,8 @@ in `package-build-archive-dir'."
(package-build--error name
"%s[-pkg].el matching package name is missing" name))
(package-build--extract-from-library rcp files)
(package-build--extract-from-package rcp files)
(with-suppressed-warnings ((obsolete package-build--extract-from-package))
(package-build--extract-from-package rcp files))
(unless package-build--inhibit-build
(unwind-protect
(progn
Expand Down

0 comments on commit 760cf53

Please sign in to comment.