Subject: | enable Alien::wxWidgets to install from local wxWidgets archive file |
Hello there,
I was trying to install Alien::wxWidgets in a Windows 7 box inside a very restrictive network that does not allow be to download any file from Sourceforge.
Fortunately, I was able to download from another repository the tarball wxWidgets-2.8.12.tar.gz but Alien::wxWidgets always tries to download from the internet.
I made some modifications (see attached patch) that looks for an environment variable called WX_WIDGETS_LOCAL and will look for the tarball locally.
Unfortunately, I could not find out why changing only fetch_wxwidgets() does not accomplish the desired feature. The function could return $path, but that wouldn't help because the File::Fetch object wouldn't have the location of the tarball.
Due that, I added an additional verification of $ENV{WX_WIDGETS_LOCAL) in extract_wxwidgets() and that did the job.
I hope the patches helps, in my machine the installation of Alien::wxWidgets occurred smoothly after the change.
I used a Windows 7 service pack 1, 32 bits with Strawberry Perl v5.16.3.
Regards,
Alceu
Subject: | patch.txt |
--- ./Alien-wxWidgets-0.64/inc/My/Build/Base.pm 2013-04-13 05:15:38.000000000 -0300
+++ Base.pm 2013-08-23 13:59:10.159564100 -0300
@@ -9,6 +9,8 @@
use Fatal qw(open close unlink);
use Data::Dumper;
use File::Glob qw(bsd_glob);
+use File::Spec;
+use Config;
use Carp;
# use the system version of a module if present; in theory this could lead to
@@ -300,10 +302,27 @@
$self->_load_bundled_modules;
print "Fetching wxWidgets...\n";
- print "fetching from: ", $self->notes( 'build_data' )->{data}{url}, "\n";
- my $path = File::Fetch->new
- ( uri => $self->notes( 'build_data' )->{data}{url} )->fetch;
+ my $path;
+
+ if ((defined($ENV{WX_WIDGETS_LOCAL})) and (-e $ENV{WX_WIDGETS_LOCAL})) {
+
+ print "WX_WIDGETS_LOCAL environment variable is defined, trying to get file in $ENV{WX_WIDGETS_LOCAL}\n";
+
+ my $local_uri = File::Spec->catfile($ENV{WX_WIDGETS_LOCAL}, $self->notes( 'build_data' )->{data}{archive});
+ # :WORKAROUND:23/08/2013 13:53:07:: File::Fetch complains if receive MSWin32 directory separator
+ $local_uri =~ tr{\\}{/} if ($Config{osname} eq 'MSWin32');
+ $local_uri = 'file://' . $local_uri;
+
+ $path = File::Fetch->new ( uri => $local_uri );
+
+ } else {
+
+ print "fetching from: ", $self->notes( 'build_data' )->{data}{url}, "\n";
+ $path = File::Fetch->new ( uri => $self->notes( 'build_data' )->{data}{url} )->fetch();
+
+ }
+
die 'Unable to fetch archive' unless $path;
}
@@ -311,14 +330,24 @@
my $self = shift;
return if -d $self->notes( 'build_data' )->{data}{directory};
- my $archive = $self->notes( 'build_data' )->{data}{archive};
+
+ my $archive;
+
+ if ((defined($ENV{WX_WIDGETS_LOCAL})) and (-e $ENV{WX_WIDGETS_LOCAL})) {
+
+ $archive = File::Spec->catfile($ENV{WX_WIDGETS_LOCAL}, $self->notes( 'build_data' )->{data}{archive});
+
+ } else {
+
+ $archive = $self->notes( 'build_data' )->{data}{archive};
+
+ }
print "Extracting wxWidgets...\n";
$self->_load_bundled_modules;
- $Archive::Extract::PREFER_BIN = ( $^O =~ /^mswin/i ) ? 0 : 1;
- my $ae = Archive::Extract->new( archive => $archive );
-
+ $Archive::Extract::PREFER_BIN = ( $Config{osname} eq 'MSWin32' ) ? 0 : 1;
+ my $ae = Archive::Extract->new( archive => $archive );
die 'Error: ', $ae->error unless $ae->extract;
$self->patch_wxwidgets;