summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2016-08-23 06:35:44 -0700
committerSean Whitton <spwhitton@spwhitton.name>2016-08-23 06:35:44 -0700
commita0ea0e9e1958a4054643f0a6e6557c5d42454614 (patch)
tree50e86bf34bb775eeea99e48edc8ff42b2c65a2d7
parent0d9d6dc0b38472abbb5e843728c583871e1f424e (diff)
parent110ccb2e2ed2ecf25061a2d3886c620a1cb40d8b (diff)
Merge tag 'debian/1.1' into jessie-bpo
dh-elpa Debian release 1.1 # gpg: Signature made Fri 12 Aug 2016 07:54:38 PM MST # gpg: using RSA key 0x0F56D0553B6D411B # gpg: Good signature from "Sean Whitton <spwhitton@spwhitton.name>" [ultimate] # Primary key fingerprint: 8DC2 487E 51AB DD90 B5C4 753F 0F56 D055 3B6D 411B
-rw-r--r--debian/changelog7
-rw-r--r--dh-elpa.el51
-rwxr-xr-xdh_elpa.in12
3 files changed, 61 insertions, 9 deletions
diff --git a/debian/changelog b/debian/changelog
index f15aa65..4b911d9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+dh-elpa (1.1) unstable; urgency=medium
+
+ * Attempt to sanitise versions from DEB_* env vars so that Emacs accepts
+ them as ELPA package version strings.
+
+ -- Sean Whitton <spwhitton@spwhitton.name> Fri, 12 Aug 2016 19:51:04 -0700
+
dh-elpa (1.0~bpo8+1) UNRELEASED; urgency=medium
* Rebuild for jessie-backports.
diff --git a/dh-elpa.el b/dh-elpa.el
index 6137ab2..094913e 100644
--- a/dh-elpa.el
+++ b/dh-elpa.el
@@ -108,19 +108,58 @@ 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")))
- (version-upstream (null-empty-string
- (getenv "DEB_VERSION_UPSTREAM"))))
+ (let* ((upstream-version (null-empty-string
+ (getenv "DEB_UPSTREAM_VERSION")))
+ (version-upstream (null-empty-string
+ (getenv "DEB_VERSION_UPSTREAM")))
+ (version (if upstream-version upstream-version version-upstream))
+ (sanitised-version (dhelpa-sanitise-version version)))
+ ;; sanity check #1
(if (and upstream-version
version-upstream
(not (string= upstream-version version-upstream)))
(error "The DEB_UPSTREAM_VERSION and DEB_VERSION_UPSTREAM
environment variables are both set, but they disagree.")
- (if upstream-version upstream-version version-upstream))))
+ ;; sanity check #2
+ (unless (ignore-errors (version-to-list sanitised-version))
+ (error (concat "E: The Debian version " version " cannot be used as an ELPA version.
+See dh_elpa(1) HINTS for how to deal with this.")))
+ ;; if we got this far, return it
+ sanitised-version)))
+
+;;;###autoload
+(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."
diff --git a/dh_elpa.in b/dh_elpa.in
index 67cd9d8..5e5828b 100755
--- a/dh_elpa.in
+++ b/dh_elpa.in
@@ -326,9 +326,10 @@ substvars
If dh_elpa can't determine the package version by looking at *.el
files (usually because upstream has failed to include the proper
-headers), it will fallback to the DEB_UPSTREAM_VERSION and
-DEB_VERSION_UPSTREAM environment variables. An easy way to set one of
-these is just to prepend the following to your rules file:
+headers or *-pkg.el file), it will fallback to the
+DEB_UPSTREAM_VERSION and DEB_VERSION_UPSTREAM. An easy way to set one
+of these based on your latest Debian changelog entry is just to
+prepend the following to your rules file:
=over 4
@@ -337,3 +338,8 @@ these is just to prepend the following to your rules file:
=back
+Certain Debian upstream version strings cannot be translated into
+version strings Emacs will accept (see the docstring for the Emacs
+function `version-to-list' for details). dh_elpa will error out if
+the version cannot be translated. You should resort to patching in a
+Package-Version header or adding a *-pkg.el file.