Mercurial > octave
changeset 21616:32cd60419b61
pkg: add support for [a-z.+-~] characters on package version number string.
* pkg/private/get_description.m: currently pkg enforces a x.y.z (major,
minor, and patch) numeric style for the string representing a package
version. In addition, it will silently append a ".0" if the string is
missing the patch version which causes weird errors for downstream
packagers. However, there seems to be no reason in the code for this
limitation which prevents 'x.y.z+' or 'x.y.z-rcN'. A real limitation we
will have is that version string will be used in the package filepath.
This change just expands the valid characters for the version string.
It does not change the requirement when installing packages with the
-forge option though (but Octave forge packages only have the x.y.z
version string anyway).
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Tue, 12 Apr 2016 19:11:27 +0100 |
parents | 9ccd64201b4d |
children | 1fff60b89786 |
files | scripts/pkg/private/get_description.m |
diffstat | 1 files changed, 21 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/pkg/private/get_description.m Tue Apr 12 17:46:20 2016 +0100 +++ b/scripts/pkg/private/get_description.m Tue Apr 12 19:11:27 2016 +0100 @@ -69,7 +69,11 @@ error ("description is missing needed field %s", f{1}); endif endfor - desc.version = fix_version (desc.version); + + if (! is_valid_pkg_version_string (desc.version)) + error ("invalid version string '%s'", desc.version); + endif + if (isfield (desc, "depends")) desc.depends = fix_depends (desc.depends); else @@ -79,22 +83,6 @@ endfunction -## Make sure the version string v is a valid x.y.z version string -## Examples: "0.1" => "0.1.0", "monkey" => error(...). -function out = fix_version (v) - if (regexp (v, '^\d+(\.\d+){1,2}$') == 1) - parts = ostrsplit (v, '.', true); - if (numel (parts) == 2) - out = [v ".0"]; - else - out = v; - endif - else - error ("bad version string: %s", v); - endif -endfunction - - ## Make sure the depends field is of the right format. ## This function returns a cell of structures with the following fields: ## package, version, operator @@ -119,21 +107,33 @@ if (! any (strcmp (operator, {">", ">=", "<=", "<", "=="}))) error ("unsupported operator: %s", operator); endif - version = fix_version (nm.ver); + if (! is_valid_pkg_version_string (nm.ver)) + error ("invalid dependency version string '%s'", nm.ver); + endif + else ## If no version is specified for the dependency ## we say that the version should be greater than ## or equal to "0.0.0". - else package = tolower (strtrim (dep)); operator = ">="; - version = "0.0.0"; + nm.ver = "0.0.0"; endif deps_cell{i} = struct ("package", package, "operator", operator, - "version", version); + "version", nm.ver); else error ("incorrect syntax for dependency '%s' in the DESCRIPTION file\n", dep); endif endfor endfunction + +function [valid] = is_valid_pkg_version_string (str) + ## We are limiting ourselves to this set of characters because the + ## version will appear on the filepath. The portable character, according + ## to http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_278 + ## is [A-Za-z0-9\.\_\-]. However, this is very limited. We expand this + ## set with the characters supported by Debian with the exception of ":" + ## (we do not support ":" (colon) because that's the Octave path separator. + valid = numel (regexp (str, '[^0-9a-zA-Z\.\+\-\~]')) == 0; +endfunction