From 5f310e5b9e7afbd5badb17178349fefaaabfacce Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 30 Jun 2016 23:32:40 -0400 Subject: Bug 1283930 - Add Makefile.PL & local/lib/perl5 support to bmo/master + local symlink to data/ directory --- Bugzilla/Install/Util.pm | 52 ++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 22 deletions(-) (limited to 'Bugzilla/Install/Util.pm') diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index 5f6c8bceb..231ef8efc 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -1,22 +1,9 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. # -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Bugzilla Bug Tracking System. -# -# The Initial Developer of the Original Code is Everything Solved. -# Portions created by Everything Solved are Copyright (C) 2006 -# Everything Solved. All Rights Reserved. -# -# Contributor(s): Max Kanat-Alexander +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. package Bugzilla::Install::Util; @@ -24,16 +11,16 @@ package Bugzilla::Install::Util; # module may require *only* Bugzilla::Constants and built-in # perl modules. +use 5.10.1; use strict; +use warnings; use Bugzilla::Constants; use Encode; -use ExtUtils::MM (); use File::Basename; use File::Spec; use POSIX qw(setlocale LC_CTYPE); -use Safe; use Scalar::Util qw(tainted); use Term::ANSIColor qw(colored); use PerlIO; @@ -47,17 +34,20 @@ our @EXPORT_OK = qw( extension_requirement_packages extension_template_directory extension_web_directory + i_am_persistent indicate_progress install_string include_languages success template_include_path - vers_cmp init_console ); sub bin_loc { my ($bin, $path) = @_; + # This module is not needed most of the time and is a bit slow, + # so we only load it when calling bin_loc(). + require ExtUtils::MM; # If the binary is a full path... if ($bin =~ m{[/\\]}) { @@ -275,6 +265,15 @@ sub indicate_progress { } } +sub feature_description { + my ($feature_name) = @_; + eval { + my $meta = _cache()->{cpan_meta} //= Bugzilla::Install::Requirements::load_cpan_meta(); + + return $meta->feature($feature_name)->description + } or warn $@; +} + sub install_string { my ($string_id, $vars) = @_; _cache()->{install_string_path} ||= template_include_path(); @@ -543,11 +542,20 @@ sub no_checksetup_from_cgi { # Used by install_string sub _get_string_from_file { my ($string_id, $file) = @_; - + # If we already loaded the file, then use its copy from the cache. + if (my $strings = _cache()->{strings_from_file}->{$file}) { + return $strings->{$string_id}; + } + + # This module is only needed by checksetup.pl, + # so only load it when needed. + require Safe; + return undef if !-e $file; my $safe = new Safe; $safe->rdo($file); my %strings = %{$safe->varglob('strings')}; + _cache()->{strings_from_file}->{$file} = \%strings; return $strings{$string_id}; } -- cgit v1.2.3-24-g4f1b