On Sun, Dec 5, 2010 at 5:07 AM, Gabor Szabo <szab...@gmail.com> wrote:
> Isn't there a CPAN module that can do what the DISTRO constant provides?
> If not, then IMHO there should be :)
>

For general OS mapping, File::Spec has a scoped $module variable
mapped after a simple hash, but I'm assuming you meant figuring out
the specific linux distro, not the mac/windows part (as that's
provided by $^O already with little to no further effort). For that,
there is the old and buggy Linux::Distribution package, which could do
what you expect. Probe::MachineInfo::Distribution is also there, but
my money would be on Sys::Info::Driver::Linux::OS::Distribution, from
just a couple of months ago and aparently an improved version of the
original Linux::Distribution.

That said, do we really need to know about distros?

Cheers

garu

>
> On Mon, Nov 29, 2010 at 5:34 PM,  <s...@perlide.org> wrote:
>> Author: Sewi
>> See also: http://padre.perlide.org/changeset/13279
>> Date: 2010-11-29 07:34:47 -0800 (Mon, 29 Nov 2010)
>> New Revision: 13279
>>
>> Modified:
>>   trunk/Padre/lib/Padre/Constant.pm
>>   trunk/Padre/lib/Padre/Wx/Directory.pm
>> Log:
>> Update for r13277:
>>  - Add Padre::Constant::DISTRO
>>  - Re-enable the line when not on Ubuntu
>>
>>
>> Modified: trunk/Padre/lib/Padre/Constant.pm
>> ===================================================================
>> --- trunk/Padre/lib/Padre/Constant.pm   2010-11-29 14:51:53 UTC (rev 13278)
>> +++ trunk/Padre/lib/Padre/Constant.pm   2010-11-29 15:34:47 UTC (rev 13279)
>> @@ -13,6 +13,8 @@
>>  our $VERSION        = '0.75';
>>  our $BACKCOMPATIBLE = '0.57';
>>
>> +our $DISTRO;
>> +
>>  # Convenience constants for the operating system
>>  use constant WIN32 => !!( ( $^O eq 'MSWin32' ) or ( $^O eq 'cygwin' ) );
>>  use constant MAC => !!( $^O eq 'darwin' );
>> @@ -126,10 +128,35 @@
>>        init();
>>  }
>>
>> +sub DISTRO {
>> +       return $DISTRO if defined($DISTRO);
>> +
>> +       if (WIN32) {
>> +               $DISTRO = 'WIN';
>> +       }
>> +       elsif (MAC) {
>> +               $DISTRO = 'MAC';
>> +       } else {
>> +               # Try to identify the distro
>> +               if (open my $lsb_file,'<','/etc/lsb-release') {
>> +                       while (<$lsb_file>) {
>> +                               next unless /^DISTRIB_ID\=(.+?)[\r\n]/;
>> +                               if ($1 eq 'Ubuntu') {
>> +                                       $DISTRO = 'UBUNTU';
>> +                               }
>> +                               last;
>> +                       }
>> +               }
>> +       }
>> +
>> +       $DISTRO ||= 'UNKNOWN';
>>
>> +       return $DISTRO if defined($DISTRO);
>> +}
>>
> _______________________________________________
> Padre-dev mailing list
> Padre-dev@perlide.org
> http://mail.perlide.org/mailman/listinfo/padre-dev
>
_______________________________________________
Padre-dev mailing list
Padre-dev@perlide.org
http://mail.perlide.org/mailman/listinfo/padre-dev

Reply via email to