From 8a013f1f16fd4730c24839127afdf46f96a45b0b Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Mon, 10 Oct 2011 11:30:17 +0200 Subject: Allow regexp for version in .appup In order to avoid duplication of upgrade instructions in .appup files, we now allow regular expressions to specify the UpFrom and DownTo versions. To be considered a regular expression, the version identifier must be specified as a binary, e.g. <<"2\\.1\\.[0-9]+">> will match versions 2.1.x, where x is any number. --- lib/sasl/src/systools_relup.erl | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'lib/sasl/src') diff --git a/lib/sasl/src/systools_relup.erl b/lib/sasl/src/systools_relup.erl index 682f5f5cc9..5cfbc3aadf 100644 --- a/lib/sasl/src/systools_relup.erl +++ b/lib/sasl/src/systools_relup.erl @@ -451,13 +451,29 @@ get_script_from_appup(Mode, TopApp, BaseVsn, Ws, RUs) -> %% XXX Why is this a warning only? [{bad_vsn, {TopVsn, TopApp#application.vsn}}| Ws] end, - case lists:keysearch(BaseVsn, 1, VsnRUs) of - {value, {_, RU}} -> + case search_for_version(BaseVsn, length(BaseVsn), VsnRUs) of + {ok, RU} -> {RUs ++ [RU], Ws1}; - _ -> + error -> throw({error, ?MODULE, {no_relup, FName, TopApp, BaseVsn}}) end. +search_for_version(BaseVsn,_,[{BaseVsn,RU}|_]) -> + {ok,RU}; +search_for_version(BaseVsn,Size,[{Vsn,RU}|VsnRUs]) when is_binary(Vsn) -> + case re:run(BaseVsn,Vsn,[unicode,{capture,first,index}]) of + {match,[{0,Size}]} -> + {ok, RU}; + _ -> + search_for_version(BaseVsn,Size,VsnRUs) + end; +search_for_version(BaseVsn,Size,[_|VsnRUs]) -> + search_for_version(BaseVsn,Size,VsnRUs); +search_for_version(_,_,[]) -> + error. + + + %% Primitives for the "lists of release names" that we upgrade from %% and to. -- cgit v1.2.3