Skip to content

Commit

Permalink
No longer make guesses when determining who provides a given feature
Browse files Browse the repository at this point in the history
The new function `epkg-provided-by' returns the package that provides
a given feature.  It replaces `epkg--required', which did the same
thing, but also also guessed the package for certain features, those
involving autoload, version, and test libraries, in case the Epkg
database did not contain any information on the feature.  The new
function doesn't do that because this is no longer necessary now that
all those features are accounted for in the database.
  • Loading branch information
tarsius committed Jan 31, 2017
1 parent 1a9b7ef commit f2daece
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# -*- mode: org -*-

* v2.2.0 UNRELEASED
* v2.2.0 2017/01/31

- The new function ~epkg-provided-by~ returns the package that provides
a given feature. It replaces ~epkg--required~, which did the same
thing, but also also guessed the package for certain features, those
involving autoload, version, and test libraries, in case the Epkg
database did not contain any information on the feature. The new
function doesn't do that because this is no longer necessary now
that all those features are accounted for in the database.

- ~epkg-required~ is now defined as a generic function. Previously,
due to a copy-paste error, ~epkg-provided~ was instead defined as
Expand Down
37 changes: 7 additions & 30 deletions epkg.el
Original file line number Diff line number Diff line change
Expand Up @@ -327,43 +327,20 @@ PACKAGE is the name of a package, a string."
package)
(-lambda ((feature hard))
(let ((feature* (if hard feature (symbol-name feature))))
(if-let ((package* (epkg--required package feature)))
(unless (equal package* package)
(if-let ((elt (assoc package* deps)))
(if-let ((provider (epkg-provided-by feature)))
(unless (equal provider package)
(if-let ((elt (assoc provider deps)))
(push feature* (cdr elt))
(push (list package* feature*) deps)))
(push (list provider feature*) deps)))
(push (list nil feature*) deps)))))
(cl-sort (mapcar (-lambda ((package . features))
(cons package (sort features #'string<)))
deps)
#'string< :key #'car)))

(cl-defmethod epkg--required ((package string) feature)
(or (epkg--required (if (symbolp feature) feature (intern feature)))
(let ((string (if (stringp feature) feature (symbol-name feature))))
;; Some packages require `NAME-autoloads' or `NAME-loaddefs',
;; others require `OTHER-autoloads' or `OTHER-loaddefs'. Assume
;; that building the package which provides `NAME' or `OTHER'
;; also generates a file which provides the autoloads feature.
(or (and (string-equal string (concat package "-autoloads")) package)
(and (string-equal string (concat package "-loaddefs")) package)
(and (string-suffix-p "-autoloads" string)
(epkg--required (intern (substring string 0 -10))))
(and (string-suffix-p "-loaddefs" string)
(epkg--required (intern (substring string 0 -9))))
;; Some packages require `NAME-version'. Assume that when
;; `NAME' is build, a file which provides `NAME-version' is
;; also generated.
(and (string-equal string (concat package "-version")) package)
;; We ignore files ending with `-test' or `-tests' to avoid
;; dependencies that are only required to run the tests. In
;; rare cases `NAME' does require `NAME-test', which might
;; then lead to unsatisfied, because unlisted, dependencies.
;; Nevertheless we assume that `NAME-test' is part of `NAME'.
(and (string-equal string (concat package "-test")) package)
(and (string-equal string (concat package "-tests")) package)))))

(cl-defmethod epkg--required ((feature symbol))
(cl-defmethod epkg-provided-by ((feature symbol))
"Return the package providing FEATURE.
FEATURE has to be a symbol. The returned value is a string."
(let ((packages (mapcar #'car
(epkg-sql [:select package :from provided
:where (= feature $s1)
Expand Down

0 comments on commit f2daece

Please sign in to comment.