#!/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
#
########globals##############
$command;
$script_name;
#############################
#main()
if (@ARGV < 1) #check number of args passed in.
{
print "You're missing an argument \n";
print "\n";
print "Usage: ./build_e_cvs_anon.pl <command> \n";
print "\n";
print "===================================== \n";
print "\n";
print "==============OPTIONS================ \n";
print "\n";
print "right now the only option is 'skipcvs' This will begin building without running cvs co first \n";
print "\n";
}
else
{
#assign args passed in to variables
$command = $ARGV[0];
}
# 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;
&$command(); #call specified argument
#############################
#testing skipping CVS
#############################
sub install
{
# 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/e17") || die("Could not change to specified root dir: $root_dir/e17");
#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";
chdir("$root_dir/e17") || die("Could not change to specified root dir: $root_dir/e17");
print "checkout e_modules \n";
system("cvs -z3 -q -d $cvs_srv co e_modules");
print "checkout complete\n";
print "Now building e17\n";
}#end install
sub skipcvs
{
$script_name ="skipcvs";
}
###
## 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","|");
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/e17" . "/" . $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");
}
#end skipcvs