add --style=tar feature, which can build with gbs export source 94/187994/3
authorjingui.ren <jingui.ren@samsung.com>
Thu, 9 Aug 2018 12:16:48 +0000 (20:16 +0800)
committerjingui.ren <jingui.ren@samsung.com>
Thu, 30 Aug 2018 07:42:07 +0000 (15:42 +0800)
Change-Id: Ib7a0764b29af886e9f611b8cbee77a1c9b7af397
Signed-off-by: jingui.ren <jingui.ren@samsung.com>
depanneur

index ae047bf..d413ebc 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -454,7 +454,7 @@ sub read_not_export {
 if ($incremental == 1 && $style ne 'git') {
     error("incremental build only support git style packages");
 }
-if ($style ne 'git' && $style ne 'obs') {
+if ($style ne 'git' && $style ne 'obs' && $style ne 'tar') {
     error("style should be 'git' or 'obs'");
 }
 
@@ -1860,7 +1860,7 @@ sub build_package {
     my $pkg_path = "$build_root/local/sources/$dist/$name-$version-$release";
     my $srpm_filename = "";
     my $not_ex = 0;
-    if ( $style eq "git" && $incremental == 0 ) {
+    if ( ( $style eq "git" || $style eq "tar" ) && $incremental == 0 ) {
         if ($not_export_source == 1) {
             $not_ex = grep /^$name$/, @not_export;
             if ($vmtype eq "kvm") {
@@ -2498,6 +2498,46 @@ sub generate_depends() {
         $index++;
     }
 }
+#use pre-export source to analyse
+sub fill_packs_from_dir {
+       my $name = shift;
+       my $base = dirname($name);
+       my $prj = basename($base);
+
+    if ( (grep $_ eq $prj, @exclude) ) {
+        return;
+    }
+    debug("working on $base");
+    my $l_packaging_dir = $packaging_dir;
+
+    if (-e "$base/.gbs.conf") {
+        debug("use $base own gbs.conf");
+        my $cfg_tiny = Config::Tiny->new;
+        $cfg_tiny = Config::Tiny->read("$base/.gbs.conf");
+        my $v = $cfg_tiny->{general}->{packaging_dir};
+        $l_packaging_dir = $v if (defined($v));
+    }
+    # use pre-export source to find spec
+    my $pattern = "$base/$l_packaging_dir/*.spec";
+    $pattern = "$base/$l_packaging_dir/$arg_spec" if $arg_spec ne "";
+    my @spec_list = glob($pattern);
+    my $specs = "";
+    foreach my $spec (@spec_list) {
+        push(@packs, {filename => "$spec",
+                      project_base_path => $base,
+                      packaging_dir => $l_packaging_dir
+                     });
+    }
+
+}
+
+sub dir_wanted {
+       if( -d "$name/packaging" )
+       {
+               fill_packs_from_dir("$name/packaging");
+               $prune = 1;
+       }
+}
 
 # MAIN
 if ($depends) {
@@ -2602,6 +2642,11 @@ if ($style eq 'git') {
             }
         }
     }
+} elsif($style eq 'tar') {
+    File::Find::find({wanted => \&dir_wanted}, $package_path );
+    if (@packs == 0) {
+        error("No source package found at $package_path");
+    }
 } else {
     @packs = @ARGV;
     if (@packs == 0) {