All pastes #34017 Raw Edit

Perl script

public text v1 · immutable
#34017 ·published 2005-12-18 02:16 UTC
rendered paste body
#!/usr/bin/perl -w


# build_e_cvs - builds your E CVS code based on
# a dependency file. can be used to build any  
# other set of dep oriented apps too.
#
# Author: Hisham 'CodeWarrior' Mardam Bey
# <hisham@hisham.cc>
#
# TODO:
# (*)  --start arg, start at a certain point.
# (*)  resume / crash detection.
# (*)  variable to choose which cvs server you want
#

# Variables

# Uncomment the csv server you would like to use.
#my $cvs_srv = ":pserver:anonymous\@thinktux.net/root";
my $cvs_srv = ":pserver:anonymous\@cvs.sourceforge.net:/cvsroot/enlightenment";

#my $root_dir = "$ENV{HOME}/cvs/e17";
my $root_dir = "$ENV{HOME}/e17\_cvs";
use strict;
use Cwd;

###
## Package used to hold apps and all of
## their associated commands.
###
package App;

sub new {
    my $this = {};
    $this->{app}         = "";
    $this->{configure}   = "";
    $this->{make}        = "";
    $this->{makeinstall} = "";
    $this->{confparams}  = "";
    $this->{name}        = "";
    $this->{descr}       = "";
    $this->{dir}         = "";
    shift;
    if(@_ ==  8) {
	$this->{app}         = shift;
	$this->{dir}         = shift;
	$this->{configure}   = shift;
	$this->{make}        = shift;
	$this->{makeinstall} = shift;
	$this->{confparams}  = shift;
	$this->{name}        = shift;
	$this->{descr}       = shift;
    }
    bless $this;
    return $this;    
} 
###
## Package to parse the config file containing
## the list of dependencies / apps.
 ###
package Parser;

sub new {
    my $this = {};
    shift;
    my $conf_file = shift;
    my $delim = shift;
    my $i = 0;
    
    $this->{apps} = ();
    
    open(CFG,$conf_file) || die("Could not open configuration file: $conf_file\n");
    while(<CFG>) {
	chomp;
	next if $_ =~ /(^#)|(^\s*$)/;
	my $line = $_;
	my @fields = split /\|/,$line;
	$this->{apps}[$i++] = new App(@fields);
    }
	
    bless $this;
    return $this;
} 
 
package main;

sub debug {

    if($main::debug) {
	print shift;
    }
}

our $debug = 1; # set to 0 for no messages.
my $verbose = ">/dev/null 2>&1"; # set to empty string for verbosity
my $parser = new Parser("deps","|");


# Checking out CVS
print "check out e17\n";

# Create $root_dir if it doesn't exist
system("mkdir -p $root_dir");

chdir("$root_dir/../") || die("Could not change to specified root: $root_dir/..");

#system("cvs -z3 -q -d :pserver:anonymous\@thinktux.net:/root co e17");
system("cvs -z3 -q -d $cvs_srv co e17");

(!$?) || die("Could not checkout e17\n");

print "checkout complete\n";

print "checkout misc\n";

chdir($root_dir) || die("Could not change to specified root dir: $root_dir");

#system("cvs -z3 -q -d :pserver:anonymous\@thinktux.net:/root co misc");
system("cvs -z3 -q -d $cvs_srv co misc");

(!$?) || die("Could not checkout misc\n");
print "checkout complete\n";

print "checkout e_modules";

system("cvs -z3 -q -d $cvs_srv co e_modules");

print "checkout complete\n";

print "Now building e17\n";

for (my $i = 0; $i < @{$parser->{apps}}; $i++) {
    my $app = $parser->{apps}[$i];
#    while( my($k,$v) = each (%{$app}) ) {
#	print "$k=$v","\n";
#    }
# >/dev/null 2>&1
    debug("Entering $root_dir/$app->{dir}\n");
    chdir($root_dir . "/" . $app->{dir}) || die("Failed at $app->{name}: Could not enter $root_dir/$app->{dir}\n");
    ### Temp hack to make clean
    debug("Running make clean\n");
    system("make clean $verbose");
    debug("Running ./$app->{configure} $app->{confparams}\n");
    (-e $app->{configure}) || die("Failed at $app->{name}: $app->{configure} not found.\n");
    system("./$app->{configure} $app->{confparams} $verbose");
    (!$?) || die("Failed at $app->{name}: Could not execute $app->{configure}\n");
    debug("Running $app->{make}\n");
    # (-e $app->{make}) || die("Failed at $app->{name}: $app->{make} not found.\n");
    system("$app->{make} $verbose");
    (!$?) || die("Failed at $app->{name}: Could not execute $app->{make}\n");
    # (-e $app->{makeinstall}) || die("Failed at $app->{name}: $app->{make} not found.\n");
    debug("Running $app->{makeinstall}\n");
    system("$app->{makeinstall} $verbose");
    (!$?) || die("Failed at $app->{name}: Could not execute $app->{makeinstall}\n");    
    unlink("/tmp/build_e_cvs.tmp");
    debug("Leaving $root_dir/$app->{dir}\n");
}