hi,

Probably many of U building .ebuild  are tired of SKELL-ing .ebuilds manualy.. i.e.
create nececary directories, copy skel.ebuild to your portage-working dir, then delete 
all the coments edit the file....etc..
so was I :") even i dont do ebuild so often... and below is a script to simplify this 
process ..(It requires only perl and Curses::UI to work, File::Path is core module)..
What exactly the script does...

- reads the skel.ebuild file
- removes the comments and new lines
- shows a dialog where u fill the data about the ebuild, such as - ebuild name, 
version, category, url, description and other details
- fill the values to the specified places..
- create the required directories if needed
- saving the ebuild file.

- license and category is specified trought select boxes
- the script is aware of PORTDIR_OVERLAY if specied in make.conf..
- New fields can be easly added - take a look at fillWidgets() sub.
- it needs some final touches by someone which understand better .ebuild construction..
- -regexp on ebuildVersion may need some refining
- shortcuts Ctrl-G for generation, Ctrl-X for exit
- fast selection/search inside select-boxes use this keysequence   "->/"

Screenshot as attachment if allowed...
I'll be glad if someone add this as .ebuild to portage... or into some other package..

====================the mkebuild script==============================


#!/usr/bin/perl
#Created by : raptor
#
use strict;
use File::Path;
our $pDir = '/usr/portage';
our $myPDir = qx{grep '^\s*PORTDIR_OVERLAY=' /etc/make.conf};
chop $myPDir;
$myPDir =~ s/^.*PORTDIR_OVERLAY=//;

our $skel = "$pDir/skel.ebuild";
our $skelTxt = qx{grep -v '^.*#' $skel};#get the skel.ebuild & remove comments
our (%widgets, %w, $cui);
our %v = ( #build select box data
    category => [ map { $_ =~ s!$pDir/(.+)$!$1!; $_} grep /-/,  <$pDir/*> ], 
    licenses => [ map { $_ =~ s!$pDir/licenses/(.+)$!$1!; $_} <$pDir/licenses/*> ],
);

sub fillWidgets {
 %widgets = (
    category => { type => 'Popupmenu', order => 1, -values => $v{category}, -selected 
=> 0 },
    ebuildName => { -text => 'foobar', order => 2 },
    ebuildVersion => { -text => '99.99-r99', order => 3, -regexp => 
'/\d\d?\.\d\d?-r\d\d?/' },
    DESCRIPTION => { -text => '', order => 11 },    
    HOMEPAGE => { -text => 'http://', order => 12, -pos => 8 },
    SRC_URI => { -text => 'ftp://foo.bar.com/${P}.tar.gz', order => 13 },
    LICENSE => { type => 'Popupmenu', order => 14, -values => $v{licenses},-selected 
=> 87 },
    SLOT => { -text => '0', order => 15 },
    KEYWORDS => { -text => '~x86', order => 16 },
    IUSE => { -text => '', order => 17 },
    DEPEND => { -text => '', order => 18 },
    S => { -text => '${WORKDIR}/${P}', order => 19, -pos => 16 },
 )
}

sub check {
    if ( ! $w{ebuildVersion}{-text} || $w{ebuildVersion}{-text} eq 
$widgets{ebuildVersion}{-text}) {
        $cui->error('Pls specify .ebuild version. Ex: 1.0-r1'); 
$w{ebuildVersion}->focus; return
    }
    if ( ! $w{ebuildName}{-text} || $w{ebuildName}{-text} eq 
$widgets{ebuildName}{-text}) {
        $cui->error('Pls specify .ebuild name'); $w{ebuildName}->focus; return
    }
    unless ($w{category}{-selected}) {
        $cui->error('Pls specify category'); $w{category}->focus; return
    }
    return 1
}

sub generate {
    for my $k (sort {$widgets{$w{$a}->userdata}{order} <=> 
$widgets{$w{$b}->userdata}{order} } keys %w) {
        my $val;
        unless ($widgets{$k}{type}) {#edit box
            $val = $w{$k}{-text};
        } else {#select-box
            $val = $widgets{$k}{values}[$w{$k}{-selected}];
        }
        if ($val) { $skelTxt =~ s/$k="(.*)"/$k="$val"/  }#fill the value
        else { $skelTxt =~ s/$k="(.*)"// }#if no value wipe
    }
    $skelTxt =~ s/\n{1,}/\n/gm;#wipe out all empty lines
    my $cat = $widgets{category}{-values}[$w{category}{-selected}];;
    my $ebuild = ($myPDir || $pDir) . "/$cat/$w{ebuildName}{-text}";
    mkpath $ebuild;
    $ebuild .= "/$w{ebuildName}{-text}-$w{ebuildVersion}{-text}.ebuild";
    $cui->dialog("Ebuild generated in :\n$ebuild");
    open FILE, ">$ebuild" or die print "oops :$!\n";
    print FILE $skelTxt;
    close FILE;
}

sub ok{
    return unless check;
    generate;
    exit
}
sub cancel {
    exit
}


#===================main==================
#rint $skelTxt;
use Curses::UI;
fillWidgets;
$cui = new Curses::UI;
my $win = $cui->add( 'win', 'Window', -title => 'Make ebuild', -pad => 2, -border => 
1, -vscrollbar => 'right');
my $btn = $win->add( 'buttons', 'Buttonbox', -x => 2, -y => -2, 
    -buttons => [ 
        { -label => '[Generate]', -value => '1', -onpress => \&ok, -shortcut => 'g' }, 
        { -label => '[Exit]', -value => '0', -onpress => \&cancel, -shortcut => 'x' } 
    ]
);

my ($i, $y);
my $x = 1;
for my $w (sort {$widgets{$a}{order} <=> $widgets{$b}{order} } keys %widgets) {
    if ($y == 7) {$x += 45; $y = 0}; 
    my $type = $widgets{$w}{type} || 'TextEntry';
    my $title = $widgets{$w}{title} || $w;

    $w{$w} = $win->add( $w, $type, -x => $x, -y => $y*3 ,
        -border => 1, -width => 40, -userdata => $w, -title => $title, 
        (map { $_ => $widgets{$w}{$_} } grep /^-/, keys %{$widgets{$w}})
    );

    $i++; $y++;
};

$cui->set_binding(\&cancel,"\cx");
$cui->set_binding(\&ok,"\cg");
$w{category}->focus;
$cui->MainLoop;


--
[EMAIL PROTECTED] mailing list

Reply via email to