my $help = 0;
my $keepgoing = 0;
+my $virtualenv = "$ENV{'VIRTUAL_ENV'}";
my $build_root = $ENV{TIZEN_BUILD_ROOT};
my $localrepo = "$build_root/local/repos";
my $order_dir = "$build_root/local/order";
my $cache_dir = "$build_root/local/cache";
my $groupfile="$build_root/meta/group.xml";
-my $virtualenv = "$ENV{'VIRTUAL_ENV'}";
my $build_dir = "$virtualenv/usr/lib/build";
my $config_filename = "$build_root/meta/local.yaml";
my $dist_configs = "$build_root/meta/dist";
-my $man = 0;
+my $exclude_from_file = "$build_root/meta/exclude";
my $cleanonce = 0;
my $debug = 0;
my $incremental = 0;
my $overwrite = 0;
my $MAX_THREADS = 1;
my $suffix = "";
-my $exclude_from_file = "$build_root/meta/exclude";
my @tobuild = ();
my @tofind = ();
my %to_build = ();
my @done = ();
my @skipped = ();
+my @original_specs = ();
my @cleaned : shared = ();
my @errors :shared;
"help|?" => \$help,
"keepgoing" => \$keepgoing,
"localrepo=s" => \$localrepo,
- "man" => \$man,
"overwrite" => \$overwrite,
"suffix=s" => \$suffix,
"debug" => \$debug,
"threads=s" => \$MAX_THREADS,
);
+my $Config = LoadFile($config_filename);
+my @package_repos = ();
+foreach my $r (@{$Config->{Repositories}}) {
+ my $uri = URI->new($r->{Url});
+ if ( $r->{Password} && $r->{Username} ) {
+ $uri->userinfo($r->{Username} . ":" . $r->{Password});
+ }
+ if ($uri->scheme ne "file") {
+ push(@package_repos, $uri);
+ }
+}
+
+my $pkg_path = "$build_root/local/sources/$dist";
+my $cache_path = "$build_root/local/sources/$dist/cache";
+
+
sub mkdir_p($) {
my $path = shift;
my $err_msg;
print GREEN, "$msg\n", RESET;
}
+my $config = Build::read_config_dist($dist, $arch, $dist_configs);
+
if ( $exclude_from_file ne "" && -e $exclude_from_file ) {
debug("using $exclude_from_file for package exclusion");
open FILE, "<", $exclude_from_file or die $!;
mkdir_p($order_dir);
mkdir_p "$localrepo/$dist/$arch/logs/success";
mkdir_p "$localrepo/$dist/$arch/logs/fail";
+mkdir_p($cache_path);
my @packs = @ARGV;
my $package_path = "";
# FIXME
+
my @archs = ("i586", "i686", "noarch");
my $archpath;
foreach my $ap (@archs) {
$archpath .= $ap.":";
}
-my $Config = LoadFile($config_filename);
-my @package_repos = ();
-foreach my $r (@{$Config->{Repositories}}) {
- my $uri = URI->new($r->{Url});
- if ( $r->{Password} && $r->{Username} ) {
- $uri->userinfo($r->{Username} . ":" . $r->{Password});
- }
- if ($uri->scheme ne "file") {
- push(@package_repos, $uri);
- }
-}
-
-
if ( -d "packaging" && -d ".git" ) {
- $path = cwd();
-}
-
-if ( $path eq "" ) {
- $package_path = "$build_root/packages";
+ $package_path = cwd();
} else {
- $package_path = $path;
+ if ( $path eq "" ) {
+ $package_path = "$build_root/packages";
+ } else {
+ $package_path = $path;
+ }
}
-
-print "Start building packages from: " . $package_path . " ($style)\n";
-
if ($binarylist ne "") {
$buildall = 1;
}
-if ($buildall || @packs == 0 ) {
- if ($style eq "git") {
- File::Find::find({wanted => \&git_wanted}, $package_path );
- } elsif ($style eq "obs") {
- File::Find::find({wanted => \&obs_wanted}, $package_path );
- }
-} else {
- if (@packs == 0 && $path eq "") {
- print "Please provide a list of packages to build.";
- exit 1;
- }
-}
-
sub git_wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
/^packaging\z/s &&
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
-d _
- && fill_packs_from_git($name);
+ && fill_packs_from_git($name, $config);
}
$name =~ m/\.osc/ || push(@packs, $name);
}
-sub fill_packs_from_git() {
+
+sub fill_packs_from_git {
my $name = shift;
my $base = dirname($name);
+ my $prj = basename($base);
if ( ! -e "$base/.git" ) {
debug("$base is not a git checkout");
return;
}
- my $prj = basename($base);
if ( (grep $_ eq $prj, @exclude) ) {
return;
}
debug("working on $base");
- my $pkg_path = "$build_root/local/sources/$dist";
- my $cache_path = "$build_root/local/sources/$dist/cache";
- mkdir_p($cache_path);
my $pattern = "$name/*.spec";
my @specs = glob $pattern;
my $spec = "";
} else {
return;
}
- my $config = Build::read_config_dist($dist, $arch, $dist_configs);
+ push (@original_specs, $spec);
+}
+
+
+sub prepare_git {
+ my $config = shift;
+ my $spec = shift;
+
+ my $packaging = dirname($spec);
+ my $base = dirname($packaging);
+ my $prj = basename($base);
+
my $pack = Build::Rpm::parse($config, $spec);
my $pkg_name = $pack->{name};
my $pkg_version = $pack->{version};
sub parse_packs {
- my @packs = @_;
+ my ($config, @packs) = @_;
+ print Dumper($config);
+
my %packs = ();
foreach my $spec (@packs) {
- my $config = Build::read_config_dist($dist, $arch, $dist_configs);
- my $path_to_spec = "";
- if ( -e $spec ) {
- $path_to_spec = $spec;
- } else {
- if ( $style eq 'obs') {
- $path_to_spec = "$package_path/$spec/$spec.spec";
- } else {
- $path_to_spec = "$package_path/$spec/$spec.spec";
- }
- }
- my $pack = Build::Rpm::parse($config, $path_to_spec);
+ my $pack = Build::Rpm::parse($config, $spec);
if ( ( $pack->{'exclarch'} ) && ( ! grep $_ eq $arch, $pack->{'exclarch'} ) ) {
next;
}
- debug("path to spec: $path_to_spec");
my $name = $pack->{name};
my $version = $pack->{version};
my $release = $pack->{release};
release => $release,
deps => @buildrequires,
subpacks => @subpacks,
- filename => $path_to_spec
+ filename => $spec
}
}
return %packs;
$workers{$worker} = { 'state' => 'idle' , 'tid' => undef};
}
+sub source_of {
+ my ($sub, %packs) = @_;
+ foreach my $x (keys %packs) {
+ my @sp = @{$packs{$x}->{subpacks}};
+ if (grep $_ eq $sub, @sp ) {
+ return $x;
+ }
+ }
+ return undef;
+}
+# MAIN
+print "Start building packages from: " . $package_path . " ($style)\n";
+
+if ($buildall || @packs == 0 ) {
+ if ($style eq "git") {
+ File::Find::find({wanted => \&git_wanted}, $package_path );
+ } elsif ($style eq "obs") {
+ File::Find::find({wanted => \&obs_wanted}, $package_path );
+ }
+} else {
+ if (@packs == 0 && $path eq "") {
+ print "Please provide a list of packages to build.";
+ exit 1;
+ }
+}
+
+print "Prepare sources...\n";
+foreach my $sp (@original_specs) {
+ prepare_git($config, $sp);
+}
+
print "Parsing package data...\n";
-my %packs = parse_packs(@packs);
+my %packs = parse_packs($config, @packs);
if ($binarylist ne "" && -e $binarylist ) {
- my %repo_assist = expand_deps();
open FILE, "<", $binarylist or die $!;
my @bins = <FILE>;
chomp(@bins);
print "Initial set:\n";
foreach my $p (@tobuild) {
- print "$p, ";
+ print " $p, ";
}
print "\n";
foreach my $m (@tofind_2) {
debug($m);
}
+ %to_build = parse_packs($config, @final);
} elsif ( $binarylist ne "") {
print STDERR "Cant find binary list for image\n";
exit 1;
-}
-
-sub source_of {
- my ($sub, %packs) = @_;
- foreach my $x (keys %packs) {
- my @sp = @{$packs{$x}->{subpacks}};
- if (grep $_ eq $sub, @sp ) {
- return $x;
- }
- }
- return undef;
-}
-
-if ($binarylist ne "") {
- %to_build = parse_packs(@final);
} else {
- %to_build = parse_packs(@packs);
+ %to_build = %packs
}
+
+# Prepare Workers
for(my $w = 0; $w < $MAX_THREADS; $w++) {
$workers{$w} = { 'state' => 'idle' , 'tid' => undef };
}