Opened 15 years ago

Closed 15 years ago

#4272 closed defect (fixed)

BUG: darwin support for Perl module Filesys::DiskSpace

Reported by: vincent-opdarw@… Owned by: mww@…
Priority: Normal Milestone:
Component: ports Version: 1.0
Keywords: Cc: markd@…
Port:

Description

In the port p5-filesys-diskspace, filename lib/perl5/vendor_perl/5.8.7/Filesys/DiskSpace.pm, ($ O eq 'freebsd') should be replaced by ($ O eq 'freebsd' | | $ O eq 'darwin'), otherwise one gets incorrect values.

Attachments (1)

DiskSpace.pm.patch (653 bytes) - added by vincent-opdarw@… 15 years ago.
Patch that adds darwin support and removes 2 unused variables.

Download all attachments as: .zip

Change History (17)

Changed 15 years ago by vincent-opdarw@…

Attachment: DiskSpace.pm.patch added

Patch that adds darwin support and removes 2 unused variables.

comment:1 Changed 15 years ago by mww@…

Owner: changed from darwinports-bugs@… to sal@…

please assign to maintainer;

comment:2 Changed 15 years ago by sal@…

Owner: changed from sal@… to vincent-opdarw@…

This patch should probably be submitted to the module developer. In my opinion, we want to have as little code difference between our version of a program and the version we download. I am willing to change my stance, however, if people disagree.

comment:3 Changed 15 years ago by vincent-opdarw@…

I sent a patch to the developer and submitted a bug on CPAN: http://rt.cpan.org/NoAuth/Bug.html?id=14118 but didn't get any reply. I doubt this will be fixed one day upstream, after seeing that another patch was submitted two years ago, but the bug is still open. Several modules on CPAN are no longer maintained.

comment:4 Changed 15 years ago by mww@…

Owner: changed from vincent-opdarw@… to mww@…
Summary: darwin support for Perl module Filesys::DiskSpaceBUG: darwin support for Perl module Filesys::DiskSpace

comment:5 Changed 15 years ago by markd@…

Cc: markd@… added

Since this module hasn't been updated since 1999 and no response to the bug report to CPAN will likely ever come, I think we can commit this if it makes it more useful on darwin. I'm not sure how to test this module in operation. Vincent, do you still want this committed? If so I'll pull the trigger.

comment:6 Changed 15 years ago by vincent-opdarw@…

Yes, since the bug is critical, it should be committed. To test it:

perl -MFilesys::DiskSpace -e 'print "Used: ".(df("/"))[2]."\n"'

should give the same value as the Used field of "df /".

comment:7 Changed 15 years ago by markd@…

(In reply to comment #6)

perl -MFilesys::DiskSpace -e 'print "Used: ".(df("/"))[2]."\n"'

Sorry but I'm not a perl scripter. There must be a minor error in the test script and the man pages don't help me much. I get: -bash: command substitution: line 1: syntax error near unexpected token `(' -bash: command substitution: line 1: `print "Used: ".(df("/"))[2]."\n"'

I'm sure the patch is fine but I since it's been so long and no one else has looked at this I want to be sure I don't screw it up. :)

comment:8 Changed 15 years ago by vincent-opdarw@…

(In reply to comment #7)

Sorry but I'm not a perl scripter. There must be a minor error in the test script and the man pages don't help me much. I get: -bash: command substitution: line 1: syntax error near unexpected token `(' -bash: command substitution: line 1: `print "Used: ".(df("/"))[2]."\n"'

It seems that you did something wrong when typing the command; just copy-paste it. A command substitution in bash starts with either a $ or a backquote, and there's no such character in the command.

comment:9 Changed 15 years ago by markd@…

(In reply to comment #8)

It seems that you did something wrong when typing the command; just copy-paste it. A command substitution in bash starts with either a $ or a backquote, and there's no such character in the command.

when I copy/paste I get: Cannot use df on this machine (untested or unsupported). at -e line 1

Here is the relevant DiskSpace.pm after install the install with the patch.

$res = syscall (&main::SYS_statfs, $dir, $fmt);

# statfs...

if ($ O eq 'freebsd' | | $ O eq 'darwin') {

# only tested with FreeBSD 3.0. Should also work with 4.0. (undef, $bsize, undef, $blocks, $bfree, $bavail, $files, $ffree) =

unpack "L8", $fmt;

$type = 0; # read it from 'f_type' field ?

comment:10 Changed 15 years ago by vincent-opdarw@…

You can enter the debugger with the -d option:

perl -d -MFilesys::DiskSpace -e 'print "Used: ".(df("/"))[2]."\n"'

Things you can do from the debugger are:

print $ O

to print out the OS name (this should be "darwin"),

print "@INC"

to print out the module paths, and

print $INC{'Filesys/DiskSpace.pm'}

gives you where the module has been found (in case you have several module versions installed).

comment:11 Changed 15 years ago by vincent-opdarw@…

And also

require "sys/syscall.ph"

This may be the thing that's missing.

comment:12 Changed 15 years ago by markd@…

DB<1> print $ O

darwin

DB<2> print $INC{'Filesys/DiskSpace.pm'}

/opt/local/lib/perl5/vendor_perl/5.8.8/Filesys/DiskSpace.pm

DB<3> require "sys/syscall.ph"

Can't locate sys/syscall.ph in @INC (did you run h2ph?) (@INC contains: /opt/local/lib/perl5/5.8.8/darwin-2level /opt/local/lib/perl5/5.8.8 /opt/local/lib/perl5/site_perl/5.8.8/darwin-2level /opt/local/lib/perl5/site_perl/5.8.8 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/5.8.8/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.8 /opt/local/lib/perl5/vendor_perl .) at (eval 8)opt/local/lib/perl5/5.8.8/perl5db.pl:628 line 2.

So Sys::Syscall is required then? Weird since there is no port for that in the tree. I'm running on a clean box with no non-DP perl modules. I'll slap a p5-sys-syscall port together later and try it again. If that does it I'll make diskspace depend upon it.

comment:13 Changed 15 years ago by vincent-opdarw@…

Concerning the sys/syscall.ph problem, I posted a message about it a few months ago:

Date: Wed, 3 Aug 2005 02:41:09 +0200 From: Vincent Lefevre <vincent@…> To: darwinports@… Subject: missing perl header files (for perl5.8) Message-ID: <20050803004109.GA10909@…>

But there was only one reply. I don't think it should be a variant, do to the limitations of variants (one can't depend on a variant...). I can see two solutions:

  • h2ph is run in destroot of the perl port.
  • One creates a new port just for that; it should depend on perl, and p5-filesys-diskspace should depend on this new port.

In my case, I did:

$ cd /usr/include $ sudo h2ph sys/*

to convert all the headers from /usr/include/sys. The problem is that h2ph doesn't create the directories automatically. To be sure to use the right directory, this can probably be done in 2 passes:

  1. Run h2ph, redirecting the standard error stream.
  2. If it complains about a missing directory, create it with mkdir -p and rerun h2ph.

Note that there may already be an existing Sys directory if some Sys::* module has already been installed. As HFS+ is a case-insensitive file system, this subdirectory will be reused for ".ph" files. This is ugly, but it doesn't seem to lead to any problem in practice.

comment:14 Changed 15 years ago by markd@…

I think running h2ph and converting headers outside of ${prefix} would not follow the DP sandbox principle of not messing with stuff outside of ${prefix}.

comment:15 Changed 15 years ago by vincent-opdarw@…

(In reply to comment #14)

I think running h2ph and converting headers outside of ${prefix} would not follow the DP sandbox principle of not messing with stuff outside of ${prefix}.

I don't think so. /usr/include/sys/*.h are headers that are part of the system, e.g. the kernel concerning "syscall.h". But DP does use the kernel; it wouldn't run without it. This is similar when DP ports are compiled: such system headers are used by the compiler.

Of course, h2ph shouldn't be run blindly in a more general directory such as /usr/include, since it may contain library headers that are replaced by DP's ones.

comment:16 Changed 15 years ago by markd@…

Resolution: fixed
Status: newclosed

Using h2ph as you said worked fine. I committed the patch and added a ui_msg to alert the user that h2ph needs to be run. Thanks!

Note: See TracTickets for help on using tickets.