[rt.cpan.org #72082] $FindBin::Bin issue on Moudel::ScanDeps 1.04

2011-11-02 Thread Roderich Schupp via RT
Wed Nov 02 14:31:28 2011: Request 72082 was acted upon.
Transaction: Correspondence added by RSCHUPP
   Queue: Module-ScanDeps
 Subject: $FindBin::Bin issue on Moudel::ScanDeps 1.04
   Broken in: (no value)
Severity: (no value)
   Owner: RSCHUPP
  Requestors: mdengf...@gmail.com
  Status: open
 Ticket URL: https://rt.cpan.org/Ticket/Display.html?id=72082 


On 2011-11-01 21:36:00, mdengf...@gmail.com wrote:
 Yes, the patch works for the FindBin case now. scandeps.pl can output the
 correct modules.

Thanks for confirming. 
Fix is contained in 1.05, just uploaded to CPAN.

Cheers, Roderich


[rt.cpan.org #72082] $FindBin::Bin issue on Moudel::ScanDeps 1.04

2011-11-01 Thread Roderich Schupp via RT
Tue Nov 01 18:11:09 2011: Request 72082 was acted upon.
Transaction: Correspondence added by RSCHUPP
   Queue: Module-ScanDeps
 Subject: $FindBin::Bin issue on Moudel::ScanDeps 1.04
   Broken in: (no value)
Severity: (no value)
   Owner: RSCHUPP
  Requestors: mdengf...@gmail.com
  Status: open
 Ticket URL: https://rt.cpan.org/Ticket/Display.html?id=72082 


OK, I see what's happening: 

When you call scandeps.pl with option
-c (or -x) it creates a temporary file that contains the text
of the file to scan plus some prologue code. This prologue code
will be called at the end of compilation (-c) or execution (-x)
and just dumps the contents of %INC, $INC etc. scandeps.pl runs
an inferior perl on this temporary file and reads back the information.

This temporary file used to be created in your working directory,
so if your script is also located there, FindBin for your script
and for the temp file would come to the same result.

In 1.04 I changed it so that the temp file is created in your
platform's temp directory. That explains why you see /tmp/lib
in @INC in the error message.

Can you try the attached patch? It makes FindBin return
the correct result by setting $0 to the path of your script.

Cheers, Roderich



Index: lib/Module/ScanDeps.pm
===
--- lib/Module/ScanDeps.pm	(revision 1285)
+++ lib/Module/ScanDeps.pm	(working copy)
@@ -1241,14 +1241,23 @@
 my ($feed_fh, $feed_file) = File::Temp::tempfile();
 my $dump_file = $feed_file.out;
 
+require Data::Dumper;
+
+# fake $0 (to $file) so that FindBin works as expected
+# NOTE: We don't directly assign to $0 as it has magic (that may
+# fail, cf. perlvar(1)), instead we alias *0 to a package variable
+# holding the correct value.
+print $feed_fh BEGIN { , 
+   Data::Dumper-Dump([ $file ], [ Module::ScanDeps::DataFeed::_0 ]),
+   *0 = \\\$Module::ScanDeps::DataFeed::_0; }\n;
+
 print $feed_fh $do_compile ? INIT {\n : END {\n;
 # NOTE: When compiling the block will run _after_ all CHECK blocks
 # (but _before_ the first INIT block) and will terminate the program.
 # When executing the block will run as the first END block and 
 # the programs continues.
 
-# correctly escape filenames
-require Data::Dumper;
+# correctly escape strings containing filenames
 print $feed_fh map { my $_ } Data::Dumper-Dump(
[ $INC{Module/ScanDeps/DataFeed.pm}, $dump_file ],
[ qw( datafeedpm dump_file ) ]);


Re: [rt.cpan.org #72082] $FindBin::Bin issue on Moudel::ScanDeps 1.04

2011-11-01 Thread DengFeng Mao via RT
Tue Nov 01 21:36:00 2011: Request 72082 was acted upon.
Transaction: Correspondence added by mdengf...@gmail.com
   Queue: Module-ScanDeps
 Subject: Re: [rt.cpan.org #72082] $FindBin::Bin issue on Moudel::ScanDeps 
1.04
   Broken in: (no value)
Severity: (no value)
   Owner: RSCHUPP
  Requestors: mdengf...@gmail.com
  Status: open
 Ticket URL: https://rt.cpan.org/Ticket/Display.html?id=72082 


Yes, the patch works for the FindBin case now. scandeps.pl can output the
correct modules.
Really appreciate your quick response.

Thanks
Dengfeng

2011/11/2 Roderich Schupp via RT bug-module-scand...@rt.cpan.org

 URL: https://rt.cpan.org/Ticket/Display.html?id=72082 

 OK, I see what's happening:

 When you call scandeps.pl with option
 -c (or -x) it creates a temporary file that contains the text
 of the file to scan plus some prologue code. This prologue code
 will be called at the end of compilation (-c) or execution (-x)
 and just dumps the contents of %INC, $INC etc. scandeps.pl runs
 an inferior perl on this temporary file and reads back the information.

 This temporary file used to be created in your working directory,
 so if your script is also located there, FindBin for your script
 and for the temp file would come to the same result.

 In 1.04 I changed it so that the temp file is created in your
 platform's temp directory. That explains why you see /tmp/lib
 in @INC in the error message.

 Can you try the attached patch? It makes FindBin return
 the correct result by setting $0 to the path of your script.

 Cheers, Roderich






-- 
-
Market is wrong, But I am right!



[rt.cpan.org #72082] $FindBin::Bin issue on Moudel::ScanDeps 1.04

2011-10-31 Thread DengFeng Mao via RT
Tue Nov 01 01:21:49 2011: Request 72082 was acted upon.
Transaction: Ticket created by mdengf...@gmail.com
   Queue: Module-ScanDeps
 Subject: $FindBin::Bin issue on Moudel::ScanDeps 1.04
   Broken in: (no value)
Severity: (no value)
   Owner: Nobody
  Requestors: mdengf...@gmail.com
  Status: new
 Ticket URL: https://rt.cpan.org/Ticket/Display.html?id=72082 


Hi, Experts

I got some issue on Module::ScanDeps 1.04. But not on Module::ScanDeps
1.02.
There is a simple test.pl file. You can get the its content in below
'cat' command. On the host hostA, the version of Module::ScanDeps is 1.02.
 The 'scandeps.pl' can output the correct result.
For the same test.pl file. On the hostBm the version of
Module::ScanDeps is 1.04, The 'scandeps.pl' command get some issue.
It seems the '$FindBin::Bin' was redirected to '/tmp' instead of the
correct folder.  So it caused some modules can't be used correctly.


Thanks in advance.

Dengfeng


===
   hostA
===
hostA [216]: ls
lib  test.pl
hostA [217]: cat test.pl

use FindBin;
use lib $FindBin::Bin/lib;

use MYMODULE;

print Hello World!\n

hostA [218]: perl -V
Summary of my perl5 (revision 5 version 12 subversion 3) configuration:

  Platform:
osname=linux, osvers=2.6.18-164.el5, archname=x86_64-linux-thread-multi
uname='linux hostA 2.6.18-164.el5 #1 smp tue aug 18 15:51:48 edt 2009
x86_64 x86_64 x86_64 gnulinux '
config_args='-Dcc=gcc -Dusethreads -Duse64bitall
-Dprefix=/home/dfmao/perl-5.12.3/linuxR_x86 -de'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
  Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing
-pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include'
ccversion='', gccversion='4.1.2 20080704 (Red Hat 4.1.2-46)',
gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
  Linker and Libraries:
ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.5'
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
USE_64_BIT_ALL
USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API
  Built under linux
  Compiled at Jul  7 2011 10:01:50
  @INC:

/home/dfmao/perl-5.12.3/linuxR_x86/lib/site_perl/5.12.3/x86_64-linux-thread-multi
/home/dfmao/perl-5.12.3/linuxR_x86/lib/site_perl/5.12.3
/home/dfmao/perl-5.12.3/linuxR_x86/lib/5.12.3/x86_64-linux-thread-multi
/home/dfmao/perl-5.12.3/linuxR_x86/lib/5.12.3
.
hostA [219]: perl -MModule::ScanDeps -e 'print $Module::ScanDeps::VERSION'
1.02

hostA [220]: scandeps.pl  -c test.pl
'MYMODULE'  = 'undef',
'Archive::Zip::Archive' = '1.30',
'Archive::Zip::DirectoryMember' = '1.30',
'Archive::Zip::FileMember'  = '1.30',
'Archive::Zip::Member'  = '1.30',
'Archive::Zip::NewFileMember'   = '1.30',
'Archive::Zip::StringMember'= '1.30',
'Archive::Zip::ZipFileMember'   = '1.30',
'URI::URL'  = '5.03',
'Expect'= '1.21',
'HTTP::Request' = '5.827',
'HTTP::Date'= '5.831',
'URI::http' = 'undef',
'LWP::UserAgent'= '5.835',
'LWP::Authen::Digest'   = 'undef',
'LWP::Authen::Ntlm' = '5.835',
'LWP::Protocol::GHTTP'  = 'undef',
'LWP::Protocol::cpan'   = 'undef',
'LWP::Protocol::data'   = 'undef',
'LWP::Protocol::file'   = 'undef',
'LWP::Protocol::ftp'= 'undef',
'LWP::Protocol::gopher' = 'undef',
'LWP::Protocol::https'  = 'undef',
'LWP::Protocol::https10'= 'undef',
'LWP::Protocol::loopback'   = 'undef',
'LWP::Protocol::mailto'