Merge patch (Support ExportFilter)
authorjiankang.fan <jiankang.fan@samsung.com>
Thu, 10 Mar 2016 07:52:57 +0000 (15:52 +0800)
committerjiankang.fan <jiankang.fan@samsung.com>
Thu, 10 Mar 2016 07:52:57 +0000 (15:52 +0800)
Change-Id: I6680768122187c2245bb8f0212730b1e975ee763
Signed-off-by: jiankang.fan <jiankang.fan@samsung.com>
expanddeps

index 48272b72f1bcc3728d41f3e1c0247cd36e9ac2a0..05de077d2146a36df4214bed0ae3a5717fd46614 100755 (executable)
@@ -27,6 +27,7 @@ BEGIN {
 use strict;
 
 use Build;
+use File::Basename;
 
 my ($dist, $rpmdeps, $archs, $configdir, $useusedforbuild, $installonly, $noinstall);
 
@@ -123,6 +124,40 @@ my %ids;
 
 my %packs_arch;
 my %packs_done;
+# XXX: move to separate tool
+if (!defined($dist) || $dist eq '') {
+  my $rpmarch = (grep {$fn{"rpm.$_"}} @archs)[0];
+  if (!$rpmarch) {
+    $dist = 'default';
+  } else {
+    my $rpmfn = $fn{"rpm.$rpmarch"};
+    if ($rpmfn =~ /^[a-z]+:\/\//) {
+      require File::Temp;
+      my $tmpdir = File::Temp::tempdir('CLEANUP' => 1);
+      $rpmfn =~ s/.*\//$tmpdir\// unless system("$INC[0]/download", $tmpdir, $rpmfn);
+    }
+    my $rpmdist = '';
+    if ($rpmfn =~ /^\// && -e $rpmfn) {
+      my %res = Build::Rpm::rpmq($rpmfn, 1010);
+      $rpmdist = $res{1010}->[0] || '';
+    }
+    $dist = Build::dist_canon($rpmdist, $archs[0]);
+    # need some extra work for sles11 :(
+    if ($dist =~ /^sles11-/) {
+      my %res = Build::Rpm::rpmq($rpmfn, 1049);
+      $dist =~ s/^sles11-/sles11sp2-/ if grep {/^liblzma/} @{$res{1049} || []};
+    }
+  }
+  print STDERR "Warning: distribution not specified, assuming '$dist' (see $configdir).\n";
+}
+
+$cf ||= Build::read_config_dist($dist, $archs[0], $configdir);
+$cf->{'warnings'} = 1;
+
+my $dofileprovides = %{$cf->{'fileprovides'}};
+$dofileprovides = 1 if ($binarytype || 'rpm') ne 'rpm';
+my %exportfilters = %{$cf->{'exportfilter'}};
+
 open(F, '<', $rpmdeps) || die("$rpmdeps: $!\n");
 # WARNING: the following code assumes that the 'I' tag comes last
 my ($pkgF, $pkgP, $pkgR, $pkgC, $pkgO);
@@ -139,7 +174,19 @@ if ($binarytype && $binarytype eq 'deb') {
 while(<F>) {
   chomp;
   if (/^F:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
+    my $pkgname = basename($2);
     $pkgF = $2;
+    my $basename = $1;
+    my $arch = $2;
+    for(keys %exportfilters) {
+      next if ($pkgname !~ /$_/);
+      for (@{$exportfilters{$_}}) {
+        my $a = $_;
+        next if ($a eq ".");
+        next if (! grep ($_ eq $a, @archs));
+        $packs{$basename} = "$basename.$arch"
+      }
+    }
   } elsif (/^P:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
     $pkgP = $2;
   } elsif (/^R:(.*?)-\d+\/\d+\/\d+: (.*)$/) {
@@ -181,39 +228,6 @@ for my $arch (@archs) {
   $packs{$_} ||= "$_.$arch" for @{$packs_arch{$arch} || []};
 }
 
-# XXX: move to separate tool
-if (!defined($dist) || $dist eq '') {
-  my $rpmarch = (grep {$fn{"rpm.$_"}} @archs)[0];
-  if (!$rpmarch) {
-    $dist = 'default';
-  } else {
-    my $rpmfn = $fn{"rpm.$rpmarch"};
-    if ($rpmfn =~ /^[a-z]+:\/\//) {
-      require File::Temp;
-      my $tmpdir = File::Temp::tempdir('CLEANUP' => 1);
-      $rpmfn =~ s/.*\//$tmpdir\// unless system("$INC[0]/download", $tmpdir, $rpmfn);
-    }
-    my $rpmdist = '';
-    if ($rpmfn =~ /^\// && -e $rpmfn) {
-      my %res = Build::Rpm::rpmq($rpmfn, 1010);
-      $rpmdist = $res{1010}->[0] || '';
-    }
-    $dist = Build::dist_canon($rpmdist, $archs[0]);
-    # need some extra work for sles11 :(
-    if ($dist =~ /^sles11-/) {
-      my %res = Build::Rpm::rpmq($rpmfn, 1049);
-      $dist =~ s/^sles11-/sles11sp2-/ if grep {/^liblzma/} @{$res{1049} || []};
-    }
-  }
-  print STDERR "Warning: distribution not specified, assuming '$dist' (see $configdir).\n";
-}
-
-$cf ||= Build::read_config_dist($dist, $archs[0], $configdir);
-$cf->{'warnings'} = 1;
-
-my $dofileprovides = %{$cf->{'fileprovides'}};
-$dofileprovides = 1 if ($binarytype || 'rpm') ne 'rpm';
-
 for my $pack (keys %packs) {
   my $r = {};
   my (@s, $s, @pr, @re, @co, @ob);