Skip to content

Commit

Permalink
check for cpanm and sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed Jul 11, 2010
1 parent 0fd6499 commit aa782a5
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions cpang.pl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# create an hbox and put it in the vbox
my $hbox = Gtk2::HBox->new( FALSE, 5 );
$vbox->pack_start( $hbox, TRUE, TRUE, 5 );
$vbox->pack_start( $hbox, FALSE, TRUE, 5 );

# create a label and put it in the hbox
my $label = Gtk2::Label->new('Module name:');
Expand Down Expand Up @@ -54,10 +54,37 @@ sub click {
my $text = $entry->get_text() || q{};
if ($text) {
$entry->set_editable(0);
$entry->set_text('');

$terminal->fork_command(
'cpanm', [ 'cpanm', $text ], undef, '/tmp', FALSE, FALSE, FALSE
$terminal->show();
$status->pop (0);
$status->push (0, "Installing $text...");

my $cmd_result = $terminal->fork_command(
'cpanm', [ 'cpanm', $text ],
undef, '/tmp', FALSE, FALSE, FALSE,
);

if ( $cmd_result == -1 ) {
my $cmd_result = $terminal->fork_command(
'sudo', [ 'sudo', 'cpan', '-i', $text ],
undef, '/tmp', FALSE, FALSE, FALSE,
);

if ( $cmd_result == -1 ) {
print STDERR "Cannot find 'cpanm' command\n";
my $dialog = Gtk2::MessageDialog->new(
$window,
'destroy-with-parent',
'warning',
'ok',
'Cannot find "sudo", "cpan" or "cpanm" program',
);

$dialog->run;
$dialog->destroy;
}
}
}
}

0 comments on commit aa782a5

Please sign in to comment.