Isn't there a CPAN module that can do what the DISTRO constant provides?
If not, then IMHO there should be :)

Gabor


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

Reply via email to