App-Tel

 view release on metacpan or  search on metacpan

local/lib/perl5/inc/Module/Install.pm  view on Meta::CPAN

package inc::Module::Install;

# This module ONLY loads if the user has manually installed their own
# installation of Module::Install, and are some form of MI author.
#
# It runs from the installed location, and is never bundled
# along with the other bundled modules.
#
# So because the version of this differs from the version that will
# be bundled almost every time, it doesn't have it's own version and
# isn't part of the synchronisation-checking.

use strict;
use vars qw{$VERSION};
BEGIN {
	# While this version will be overwritten when Module::Install
	# loads, it remains so Module::Install itself can detect which
	# version an author currently has installed.
	# This allows it to implement any back-compatibility features
	# it may want or need to.
	$VERSION = '1.16';
}

if ( -d './inc' ) {
	my $author = $^O eq 'VMS' ? './inc/_author' : './inc/.author';
	if ( -d $author ) {
		my $modified_at = (stat($author))[9];
		if ((time - $modified_at) > 24 * 60 * 60) {
			# inc is a bit stale; there may be a newer Module::Install
			_check_update($modified_at);
		}
		$Module::Install::AUTHOR = 1;
		require File::Path;
		File::Path::rmtree('inc');
	}
} else {
	$Module::Install::AUTHOR = 1;
}

unshift @INC, 'inc' unless $INC[0] eq 'inc';
local $^W;
require Module::Install;

sub _check_update {
	my $modified_at = shift;

	# XXX: We have several online services to get update information
	# including search.cpan.org. They are more reliable than the
	# 02packages.details.txt.gz on the local machine. We might be
	# better to depend on those services... but on which?

	my $cpan_version = 0;
	if (0) {  # XXX: should be configurable?
		my $url = "http://search.cpan.org/dist/Module-Install/META.yml";
		eval "require YAML::Tiny; 1" or return;

		if (eval "require LWP::UserAgent; 1") {
			my $ua = LWP::UserAgent->new(
				timeout   => 10,
				env_proxy => 1,
			);
			my $res = $ua->get($url);
			return unless $res->is_success;
			my $yaml = eval { YAML::Tiny::Load($res->content) } or return;
			$cpan_version = $yaml->{version};
		}
	}
	else {
		# If you don't want to rely on the net...
		require File::Spec;
		$cpan_version = _check_update_local($modified_at) or return;



( run in 0.860 second using v1.01-cache-2.11-cpan-437f7b0c052 )