|author||Sean Whitton <email@example.com>||2016-08-12 11:54:51 -0700|
|committer||Sean Whitton <firstname.lastname@example.org>||2016-08-12 11:54:51 -0700|
sanitise versions from env vars
Diffstat (limited to 'dh-elpa.el')
1 files changed, 35 insertions, 3 deletions
@@ -108,13 +108,18 @@ DEB_VERSION_UPSTREAM environment variables are set."))
"Return the package version as found in standard DEB_* environment variables.
Try DEB_UPSTREAM_VERSION first, then DEB_VERSION_UPSTREAM.
-Signal an error if these are both set and they disagree."
+Signal an error if these are both set and they disagree.
+Versions taken from environment variables are run through
;; If one of these environment variables is the empty string, it's
;; as good as unset, so we replace that with the nil value.
(let ((upstream-version (null-empty-string
- (getenv "DEB_UPSTREAM_VERSION")))
+ (getenv "DEB_UPSTREAM_VERSION"))))
- (getenv "DEB_VERSION_UPSTREAM"))))
+ (getenv "DEB_VERSION_UPSTREAM")))))
(if (and upstream-version
(not (string= upstream-version version-upstream)))
@@ -122,6 +127,33 @@ Signal an error if these are both set and they disagree."
environment variables are both set, but they disagree.")
(if upstream-version upstream-version version-upstream))))
+(defun dhelpa-sanitise-version (version)
+ "Sanitise a Debian version VERSION such that it will work with Emacs.
+Our goal is to ensure that ELPA package versions are sorted
+correctly relative to other versions of the package the user
+might have installed in their home directory.
+To do this:
+- we remove all indication of backporting, since that is a matter
+ of Debian packaging and shouldn't affect the ELPA package
+- we replace '~' with '-' -- Emacs interprets '-rc', '-git' and
+ '-pre' similar to how dpkg interprets '~rc', '~git' and
+ '~pre' (see `version-to-list')
+This will not give the right answer in all cases (for example
+'~foo' where 'foo' is not one of the strings Emacs recognises as
+a pre-release). The Debian package maintainer should patch the
+upstream source to include a proper Package-Version: header in
+such a case."
+ (when version
+ "~" "-"
+ (replace-regexp-in-string "~bpo.*$" "" version))))
(defun null-empty-string (str)
"If STR is a string of length zero, return nil. Otherwise, return STR."
(if (and (stringp str)