summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog7
-rw-r--r--dh-elpa.el38
2 files changed, 42 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index c3ce091..eb5f1ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+dh-elpa (1.1) UNRELEASED; urgency=medium
+
+ * Attempt to convert versions from DEB_* env vars to Emacs version
+ strings.
+
+ -- Sean Whitton <spwhitton@spwhitton.name> Fri, 12 Aug 2016 11:51:14 -0700
+
dh-elpa (1.0) unstable; urgency=medium
[ Sean Whitton ]
diff --git a/dh-elpa.el b/dh-elpa.el
index 6137ab2..6264fd9 100644
--- a/dh-elpa.el
+++ b/dh-elpa.el
@@ -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
+`dhelpa-sanitise-version'."
;; 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")))
+ (dhelpa-sanitise-version
+ (getenv "DEB_UPSTREAM_VERSION"))))
(version-upstream (null-empty-string
- (getenv "DEB_VERSION_UPSTREAM"))))
+ (dhelpa-sanitise-version
+ (getenv "DEB_VERSION_UPSTREAM")))))
(if (and upstream-version
version-upstream
(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
+ content
+
+- 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
+ "~" "-"
+ (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)