From 5746ffc359d425b3b6cc8016283b1f19559f3355 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Tue, 24 Jul 2012 03:31:24 +0100 Subject: [PATCH] move dep code into sub Change-Id: Ib9c812adb02bc0c0f09294391285931283b3593e --- depanneur | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/depanneur b/depanneur index fcad63b..dc855cf 100755 --- a/depanneur +++ b/depanneur @@ -164,6 +164,8 @@ if ( $exclude_from_file ne "" && -e $exclude_from_file ) { mkdir_p($order_dir); +mkdir_p "$localrepo/$dist/$arch/logs/success"; +mkdir_p "$localrepo/$dist/$arch/logs/fail"; my @packs = @ARGV; my $package_path = ""; @@ -740,8 +742,28 @@ if ( ! -e "$localrepo/$dist/$arch/RPMS" ) { print "Creating repo..."; createrepo ($arch, $dist); } -mkdir_p "$localrepo/$dist/$arch/logs/success"; -mkdir_p "$localrepo/$dist/$arch/logs/fail"; + +sub get_deps { + my ($name, %_to_build) = @_; + my $stop = 0; + my @deps = @{$_to_build{$name}->{deps}}; + debug("now looking into $name"); + foreach my $dep (@deps) { + open(EXPAND,"$virtualenv/usr/bin/do_expanddeps --dist $dist --depfile $order_dir/.repo.cache --archpath $archpath --configdir $dist_configs \"$dep\" |") || die "Failed: $!\n"; + while ( ) { + chomp; + my $ddep = $_; + my $so = source_of($ddep, %_to_build); + if ( defined($so) && ($so ne $name) && (! grep($_ eq $so, @skipped)) && (! grep($_ eq $so, @done)) ) { + debug("Not adding $name for now, it needs $dep -> $ddep ($so)..."); + $stop = 1; + last; + } + } + close(EXPAND); + } + return $stop; +} while (! $TERM) { my @order = (); @@ -793,25 +815,8 @@ while (! $TERM) { $dd = "--debug"; } if ( system("$virtualenv/usr/bin/check_unresolved $dd --depfile $order_dir/.repo.cache --configdir $dist_configs --dist $dist --archpath $archpath $fn") == 0 ) { - my $stop = 0; - my @deps = @{$to_build{$name}->{deps}}; - debug("now looking into $name"); - foreach my $dep (@deps) { - open(EXPAND,"$virtualenv/usr/bin/do_expanddeps --dist $dist --depfile $order_dir/.repo.cache --archpath $archpath --configdir $dist_configs \"$dep\" |") || die "Failed: $!\n"; - while ( ) { - chomp; - my $ddep = $_; - my $so = source_of($ddep, %to_build); - if ( defined($so) && ($so ne $name) && (! grep($_ eq $so, @skipped)) && (! grep($_ eq $so, @done)) ) { - debug("Not adding $name for now, it needs $dep -> $ddep ($so)..."); - $stop = 1; - last; - } - } - close(EXPAND); - } - if ($stop == 0 ) { + if (get_deps($name, %to_build) == 0 ) { push(@order, $name); } } -- 2.7.4