From eb2fe9a655748626987831d6abc116753174df6d Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 29 Oct 2020 07:23:08 -0700 Subject: [PATCH] install.sh: install a frozen Girocco::Config.pm file Take advantage of the new Girocco::Dumper FreezeConfig functionality and emit a frozen Girocco::Config.pm file during the installation process that contains solely variable assignments plus umask sanitation. In addition provide all of the computed var_...=... variable settings in the frozen Girocco::Config.pm as well to make them available from within perl code. This change provides a minor efficiency gain when loading the Girocco::Config after installation. Signed-off-by: Kyle J. McKay --- install.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index c048458..d03869e 100755 --- a/install.sh +++ b/install.sh @@ -641,8 +641,26 @@ else fi [ -n "$cfg_mob" ] || rm -f "$basedir"/html/mob.html -# Put the correct Config in place -[ "$GIROCCO_CONF" = "Girocco::Config" ] || cp "$(echo "$GIROCCO_CONF" | sed 's#::#/#g; s/$/.pm/')" "$basedir/Girocco/Config.pm" +# Put the frozen Config in place +VARLIST="$(get_girocco_config_var_list varonly)" && export VARLIST +perl -I"$PWD" -MGirocco::Dumper=FreezeConfig -MScalar::Util=looks_like_number -e ' + my $usemod = $ARGV[0]; + my $f = sub { return () unless $_[0] =~ /^(var_[^=\s]+)=(.*)$/; + my ($k,$v) = ($1,$2); + $v =~ s/([\@\%])/\\$1/gos; + $v = "\"".$v."\"" unless substr($v,0,1) eq "\"" || looks_like_number($v); + my $e = eval $v; + [$k, $e] }; + my @vars = map({&$f($_)} split(/\n+/, $ENV{VARLIST})); + my $s = sub { my $conf = shift; + foreach (@vars) { + my ($k,$v) = @{$_}; + eval "\$${conf}::$k=\$v"; + } + }; + print FreezeConfig($usemod, undef, $s); +' -- "$GIROCCO_CONF" >"$basedir/Girocco/Config.pm" +unset VARLIST # Create symbolic links to selected binaries ln -s "$cfg_git_bin" "$basedir/bin/git" -- 2.11.4.GIT