From: Richard Levitte Date: Thu, 17 Oct 2019 14:03:06 +0000 (+0200) Subject: Configure: get version from the file 'VERSION' instead of 'opensslv.h' X-Git-Tag: openssl-3.0.0-alpha1~1109 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=20551b2e62ed8c2fa97e0106a0350f40f3422dd5;p=oweals%2Fopenssl.git Configure: get version from the file 'VERSION' instead of 'opensslv.h' 'VERSION' is a very easy file to parse, as opposed to a header file. We also have the benefit of holding the version information in one very well known place and can then generate all other version texts as we see fit, for example opensslv.h. Fixes #10203 Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/10205) --- diff --git a/Configure b/Configure index 3df3e0c96a..7ff8b06214 100755 --- a/Configure +++ b/Configure @@ -255,38 +255,39 @@ if (grep /^reconf(igure)?$/, @argvcopy) { $config{perlargv} = [ @argvcopy ]; # Collect version numbers -$config{major} = "unknown"; -$config{minor} = "unknown"; -$config{patch} = "unknown"; -$config{prerelease} = ""; -$config{build_metadata} = ""; -$config{shlib_version} = "unknown"; +my %version = (); collect_information( - collect_from_file(catfile($srcdir,'include/openssl/opensslv.h')), - qr/#\s+define\s+OPENSSL_VERSION_MAJOR\s+(\d+)/ => - sub { $config{major} = $1; }, - qr/#\s+define\s+OPENSSL_VERSION_MINOR\s+(\d+)/ => - sub { $config{minor} = $1; }, - qr/#\s+define\s+OPENSSL_VERSION_PATCH\s+(\d+)/ => - sub { $config{patch} = $1; }, - qr/#\s+define\s+OPENSSL_VERSION_PRE_RELEASE\s+"((?:\\.|[^"])*)"/ => - sub { $config{prerelease} = $1; }, - qr/#\s+define\s+OPENSSL_VERSION_BUILD_METADATA\s+"((?:\\.|[^"])*)"/ => - sub { $config{build_metadata} = $1; }, - qr/#\s+define\s+OPENSSL_SHLIB_VERSION\s+([\d\.]+)/ => - sub { $config{shlib_version} = $1; }, + collect_from_file(catfile($srcdir,'VERSION')), + qr/\s*(\w+)\s*=\s*(.*?)\s*$/ => + sub { + # Only define it if there is a value at all + $version{uc $1} = $2 if $2 ne ''; + }, + "OTHERWISE" => + sub { die "Something wrong with this line:\n$_\nin $srcdir/VERSION" }, ); -die "erroneous version information in opensslv.h: ", - "$config{major}.$config{minor}.$config{patch}, $config{shlib_version}\n" - if ($config{major} eq "unknown" - || $config{minor} eq "unknown" - || $config{patch} eq "unknown" - || $config{shlib_version} eq "unknown"); + +$config{major} = $version{MAJOR} // 'unknown'; +$config{minor} = $version{MINOR} // 'unknown'; +$config{patch} = $version{PATCH} // 'unknown'; +$config{prerelease} = + defined $version{PRE_RELEASE_TAG} ? "-$version{PRE_RELEASE_TAG}" : ''; +$config{build_metadata} = + defined $version{BUILD_METADATA} ? "+$version{BUILD_METADATA}" : ''; +$config{shlib_version} = $version{SHLIB_VERSION} // 'unknown'; +$config{release_date} = $version{RELEASE_DATE} // 'xx XXX xxxx'; $config{version} = "$config{major}.$config{minor}.$config{patch}"; $config{full_version} = "$config{version}$config{prerelease}$config{build_metadata}"; +die "erroneous version information in VERSION: ", + "$config{version}, $config{shlib_version}\n" + unless (defined $version{MAJOR} + && defined $version{MINOR} + && defined $version{PATCH} + && defined $version{SHLIB_VERSION}); + # Collect target configurations my $pattern = catfile(dirname($0), "Configurations", "*.conf"); diff --git a/VERSION b/VERSION new file mode 100644 index 0000000000..cba848cebe --- /dev/null +++ b/VERSION @@ -0,0 +1,7 @@ +MAJOR=3 +MINOR=0 +PATCH=0 +PRE_RELEASE_TAG=dev +BUILD_METADATA= +RELEASE_DATE= +SHLIB_VERSION=3 diff --git a/doc/internal/man7/VERSION.pod b/doc/internal/man7/VERSION.pod new file mode 100644 index 0000000000..4bc8ba6b93 --- /dev/null +++ b/doc/internal/man7/VERSION.pod @@ -0,0 +1,149 @@ +=pod + +=head1 NAME + +VERSION - OpenSSL version information + +=head1 SYNOPSIS + + MAJOR=3 + MINOR=0 + PATCH=0 + PRE_RELEASE_TAG=dev + BUILD_METADATA= + RELEASE_DATE= + SHLIB_VERSION=3 + +=head1 DESCRIPTION + +This file is a set of keyed information looking like simple variable +assignments. When given an empty value, they are seen as unassigned. +The keys that are recognised are: + +=over 4 + +=item B, B, B + +The three parts of OpenSSL's 3 numbered version number, MAJOR.MINOR.PATCH. +These are used to compose the values for the C macros B, +B, B. + +=item B + +This is the added pre-release tag, which is added to the version separated by +a dash. For a value C, the C macro B gets +the string C<-foo> (dash added). + +=item B + +Extra metadata to be used by anyone for their own purposes. This is added to +the version and possible pre-release tag, separated by a plus sign. For a +value C, the C macro B gets the string +C<+bar>. + +=item B + +Defined in releases. When not set, it gets the value C. + +=item B + +The shared library version, which is something other than the project version. + +=back + +It is a configuration error if B, B, B and B +don't have values. Configuration will stop in that case. + +=head2 Affected configuration data + +The following items in %config from F are affected: + +=over 4 + +=item $config{major}, $config{minor}, $config{patch}, $config{shlib_version} + +These items get their values from B, B, B, and +B, respectively. + +=item $config{prerelease} + +If B is assigned a value, $config{prerelease} gets that same value, +prefixed by a dash, otherwise the empty string. + +=item $config{build_metadata} + +If B is assigned a value, $config{build_metadata} gets that same +value, prefixed by a plus sign, otherwise the empty string. + +=item $config{release_date} + +If B is assigned a value, $config{release_date} gets that same +value, otherwise the string C. + +=item $config{version} + +The minimal version number, a string composed from B, B and +B, separated by periods. For C, C and C, +the string will be C<3.0.0>. + +=item $config{full_version} + +The fully loaded version number, a string composed from $config{version}, +$config{prerelease} and $config{build_metadata}. See See L for +a few examples. + +=back + +=head1 EXAMPLES + +=over 4 + +=item 1. + + MAJOR=3 + MINOR=0 + PATCH=0 + PRE_RELEASE_TAG=dev + BUILD_METADATA= + +The fully loaded version number ($config{full_version}) will be +C<3.0.0-dev>. + +=item 2. + + MAJOR=3 + MINOR=0 + PATCH=0 + PRE_RELEASE_TAG= + BUILD_METADATA=something + +The fully loaded version number ($config{full_version}) will be +C<3.0.0+something>. + +=item 3. + + MAJOR=3 + MINOR=0 + PATCH=0 + PRE_RELEASE_TAG=alpha3 + BUILD_METADATA=something + +The fully loaded version number ($config{full_version}) will be +C<3.0.0-alpha3+something>. + +=back + +=head1 SEE ALSO + +L + +=head1 COPYRIGHT + +Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. + +Licensed under the Apache License 2.0 (the "License"). You may not use +this file except in compliance with the License. You can obtain a copy +in the file LICENSE in the source distribution or at +L. + +=cut