From 95fb002b85897e71820c44519231975d883f87db Mon Sep 17 00:00:00 2001 From: David Steele Date: Tue, 27 Apr 2021 12:04:50 -0400 Subject: [PATCH] Preserve unused YAML fix for older Debian/Ubuntu distributions. This fix was not used since backports worked for older Debians and the old affected Ubuntus are EOL. Still, seems worth preserving just in case it comes up elsewhere. --- build/lib/pgBackRestBuild/Config/Data.pm | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/build/lib/pgBackRestBuild/Config/Data.pm b/build/lib/pgBackRestBuild/Config/Data.pm index d65448dd9..4d987e338 100644 --- a/build/lib/pgBackRestBuild/Config/Data.pm +++ b/build/lib/pgBackRestBuild/Config/Data.pm @@ -221,6 +221,73 @@ my $rhCommandDefine = $rhConfig->{'command'}; my $rhOptionGroupDefine = $rhConfig->{'optionGroup'}; my $rhConfigDefine = $rhConfig->{'option'}; +#################################################################################################################################### +# Fix errors introduced by YAML::XS::LoadFile. This is typically fixed by setting local $YAML::XS::Boolean = "JSON::PP", but older +# Debian/Ubuntu versions do not support this fix. Some booleans get set read only and others also end up as empty strings. There is +# no apparent pattern to what gets broken so it is important to be on the lookout for strange output when adding new options. +# +# ??? For now this code is commented out since packages for older Debians can be built using backports. It is being preserved just +# in case it is needed before the migration to C is complete. +#################################################################################################################################### +# sub optionDefineFixup +# { +# my $strKey = shift; +# my $rhDefine = shift; +# +# # Fix read-only required values so they are writable +# if (defined($rhDefine->{&CFGDEF_REQUIRED})) +# { +# my $value = $rhDefine->{&CFGDEF_REQUIRED} ? true : false; +# delete($rhDefine->{&CFGDEF_REQUIRED}); +# $rhDefine->{&CFGDEF_REQUIRED} = $value; +# } +# +# # If the default is an empty string set to false. This must be a mangled boolean since empty strings are not valid defaults. +# if (defined($rhDefine->{&CFGDEF_DEFAULT}) && $rhDefine->{&CFGDEF_DEFAULT} eq '') +# { +# delete($rhDefine->{&CFGDEF_DEFAULT}); +# $rhDefine->{&CFGDEF_DEFAULT} = false; +# } +# +# # If a depend list value is an empty string set it to false. This must be a mangled boolean since empty strings are not valid +# # depend list values. +# if (ref($rhDefine->{&CFGDEF_DEPEND}) && defined($rhDefine->{&CFGDEF_DEPEND}{&CFGDEF_DEPEND_LIST})) +# { +# my @stryList; +# +# for (my $iDependListIdx = 0; $iDependListIdx < @{$rhDefine->{&CFGDEF_DEPEND}{&CFGDEF_DEPEND_LIST}}; $iDependListIdx++) +# { +# if ($rhDefine->{&CFGDEF_DEPEND}{&CFGDEF_DEPEND_LIST}[$iDependListIdx] eq '') +# { +# push(@stryList, false); +# } +# else +# { +# push(@stryList, $rhDefine->{&CFGDEF_DEPEND}{&CFGDEF_DEPEND_LIST}[$iDependListIdx]); +# } +# } +# +# delete($rhDefine->{&CFGDEF_DEPEND}{&CFGDEF_DEPEND_LIST}); +# $rhDefine->{&CFGDEF_DEPEND}{&CFGDEF_DEPEND_LIST} = \@stryList; +# } +# } +# +# # Fix all options +# foreach my $strKey (sort(keys(%{$rhConfigDefine}))) +# { +# my $rhOption = $rhConfigDefine->{$strKey}; +# optionDefineFixup($strKey, $rhOption); +# +# # Fix all option commands +# if (ref($rhOption->{&CFGDEF_COMMAND})) +# { +# foreach my $strCommand (sort(keys(%{$rhOption->{&CFGDEF_COMMAND}}))) +# { +# optionDefineFixup("$strKey-$strCommand", $rhOption->{&CFGDEF_COMMAND}{$strCommand}); +# } +# } +# } + #################################################################################################################################### # Process command define defaults ####################################################################################################################################