diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2016-07-19 12:10:08 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-07-19 12:10:08 -0700 |
commit | 345bb7b3203d870ef67f46467938965992c84024 (patch) | |
tree | f5156062ee69e709dd5db0dcfbf0bc0a4125a1e2 | |
parent | f0067363fdc4617ed64c2a7f666d8778c294ff44 (diff) |
try DEB_UPSTREAM_VERSION then DEB_VERSION_UPSTREAM
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | dh-elpa.el | 37 |
2 files changed, 36 insertions, 7 deletions
diff --git a/debian/changelog b/debian/changelog index 0d3610a..d2ac39e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,9 +15,9 @@ dh-elpa (1.0) UNRELEASED; urgency=medium * depend on libdebian-source-perl in preference to dh-make-perl, if the former is available. - [ Rémi Vanicat ] - * use DEB_VERSION_UPSTREAM as elpa version if there is no version line - in the main "*.el" file + [ Rémi Vanicat & Sean Whitton ] + * use DEB_UPSTREAM_VERSION or DEB_VERSION_UPSTREAM as elpa version if + there is no version line in the main "*.el" file -- Rémi Vanicat <vanicat@debian.org> Mon, 11 Jul 2016 15:29:38 +0200 @@ -68,7 +68,9 @@ If the buffer does not contain a conforming package, signal an error. If there is a package, narrow the buffer to the file's boundaries. -If there is no version information, use DEB_VERSION_UPSTREAM" +If there is no version information, try DEB_UPSTREAM_VERSION and +then DEB_VERSION_UPSTREAM, signalling an error if they are both +set and disagree." (goto-char (point-min)) (unless (re-search-forward "^;;; \\([^ ]*\\)\\.el ---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$" nil t) (error "Package lacks a file header")) @@ -87,12 +89,14 @@ If there is no version information, use DEB_VERSION_UPSTREAM" ;; probably wants us to use it. Otherwise try Version. (pkg-version (or (package-strip-rcs-id (lm-header "package-version")) - (package-strip-rcs-id (lm-header "version")) - (getenv "DEB_VERSION_UPSTREAM"))) + (package-strip-rcs-id (lm-header "version")) + (dhelpa-getenv-version))) (homepage (lm-homepage))) (unless pkg-version (error - "Package lacks a \"Version\" or \"Package-Version\" header")) + "Package lacks a \"Version\" or \"Package-Version\" +header, and neither of the DEB_UPSTREAM_VERSION and +DEB_VERSION_UPSTREAM environment variables are set.")) (package-desc-from-define file-name pkg-version desc (if requires-str @@ -101,6 +105,31 @@ If there is no version information, use DEB_VERSION_UPSTREAM" :kind 'single :url homepage)))) +(defun dhelpa-getenv-version () + "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." + ;; 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")))) + (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)))) + +(defun null-empty-string (str) + "If STR is a string of length zero, return nil. Otherwise, return STR." + (if (and (stringp str) + (zerop (length str))) + nil + str)) + (defun dhelpa-filter-deps-for-debian (deps) "Filter a list of package.el deps DEPS for Debian. |