Support use some configuration in package own gbs.conf 58/127158/2
authorJun Wang <junbill.wang@samsung.com>
Wed, 26 Apr 2017 09:01:49 +0000 (17:01 +0800)
committerJun Wang <junbill.wang@samsung.com>
Wed, 26 Apr 2017 12:00:33 +0000 (20:00 +0800)
Change-Id: Ib3b581fbd8b8c2161af3ef9b69fa76fb4c9f6166
Signed-off-by: Wang Jun <junbill.wang@samsung.com>
debian/control
depanneur
packaging/depanneur.spec

index 626bd5b06046e9a09deb34777067f3e4b068b2da..07a0ac3554522a04e5b711b1ffe86f3b34104d3f 100644 (file)
@@ -13,7 +13,8 @@ Depends: ${perl:Depends},
  libyaml-perl,
  createrepo (>= 0.9.8),
  libjson-perl,
- libhtml-template-perl
+ libhtml-template-perl,
+ libconfig-tiny-perl
 Description: Manages and executes the builds using the obs-build script.
   The depanneur tool goes through local Git trees and evaluates packaging
   meta-data to determine packages needed and the build order; it then starts
index f708b48cefdb171ea1ffad1e592d84cb0b41f96c..dfed4b70123b33c963d1b911c94c8335ad50e2d0 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -30,7 +30,7 @@ use POSIX ":sys_wait_h";
 use File::Glob ':glob';
 use User::pwent qw(getpw);
 use POSIX qw(sysconf);
-
+use Config::Tiny;
 
 # Global vars
 
@@ -603,10 +603,25 @@ sub fill_packs_from_git {
     }
 
     debug("working on $base");
+    my $l_packaging_dir = $packaging_dir;
+    my $l_upstream_branch = $upstream_branch;
+    my $l_upstream_tag = $upstream_tag;
+    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));
+        $v  = $cfg_tiny->{general}->{upstream_branch};
+        $l_upstream_branch = $v if (defined($v));
+        $v = $cfg_tiny->{general}->{upstream_tag};
+        $l_upstream_tag = $v if (defined($v));
+    }
+
     if ($includeall == 0 || $spec_commit ne "") {
         my (undef, $tmp_file) = tempfile(OPEN => 0);
         my $__commit = $spec_commit eq "" ? $commit : $spec_commit;
-        if (my_system("cd $base; git show $__commit:$packaging_dir >$tmp_file 2>/dev/null") == 0) {
+        if (my_system("cd $base; git show $__commit:$l_packaging_dir >$tmp_file 2>/dev/null") == 0) {
             open my $file, '<', $tmp_file or die $!;
             # the content like:
             # tree $__commit:$packaging_dir
@@ -622,8 +637,11 @@ sub fill_packs_from_git {
                     next if $_ !~ /\.spec$/;
                     # if build specify --spec
                     next if $arg_spec ne "" && $_ ne $arg_spec;
-                    push(@pre_packs, {filename => "$base/$packaging_dir/$_",
-                                      project_base_path => $base});
+                                       push(@pre_packs, {filename => "$base/$l_packaging_dir/$_",
+                                      project_base_path => $base,
+                                      packaging_dir => $l_packaging_dir,
+                                      upstream_branch => $l_upstream_branch,
+                                      upstream_tag => $l_upstream_tag});
                 }
             } else {        #packaging_dir is a symbol link
                 my (undef, $tmp_symlink_file) = tempfile(OPEN => 0);
@@ -635,7 +653,10 @@ sub fill_packs_from_git {
                         next if $_ !~ /\.spec$/;
                         next if $arg_spec ne "" && $_ ne $arg_spec;
                         push(@pre_packs, {filename => "$base/$first_line/$_",
-                                          project_base_path => $base});
+                                          project_base_path => $base,
+                                          packaging_dir => $l_packaging_dir,
+                                          upstream_branch => $l_upstream_branch,
+                                          upstream_tag => $l_upstream_tag});
                     }
                     close($symlink_file);
                     unlink $tmp_symlink_file;
@@ -646,12 +667,15 @@ sub fill_packs_from_git {
         }
     } else {
         # specify --include-all use current packaging dir not from git
-        my $pattern = "$base/$packaging_dir/*.spec";
-        $pattern = "$base/$packaging_dir/$arg_spec" if $arg_spec ne "";
+        my $pattern = "$base/$l_packaging_dir/*.spec";
+        $pattern = "$base/$l_packaging_dir/$arg_spec" if $arg_spec ne "";
         my @spec_list = glob($pattern);
         foreach my $spec (@spec_list) {
                 push(@pre_packs, {filename => "$spec",
-                                  project_base_path => $base});
+                                  project_base_path => $base,
+                                  packaging_dir => $l_packaging_dir,
+                                  upstream_branch => $l_upstream_branch,
+                                  upstream_tag => $l_upstream_tag});
         }
     }
 }
@@ -660,7 +684,7 @@ sub fill_packs_from_git {
 # Call gbs export
 #---------------------------------------------------------------------
 sub gbs_export {
-    my ($base, $spec) = @_;
+    my ($base, $spec, $packaging_dir, $upstream_branch, $upstream_tag) = @_;
     my @args = ();
     my $cmd;
     push @args, "gbs";
@@ -725,9 +749,9 @@ sub read_cache {
 # No return value
 #---------------------------------------------------------------------
 sub write_cache {
-    my ($cache_key, $cache_val, $base, $spec) = @_;
+    my ($cache_key, $cache_val, $base, $spec, $packaging_dir, $upstream_branch, $upstream_tag) = @_;
     my $cache_fname = "$cache_path/$cache_key";
-    my @export_out = gbs_export($base, $spec);
+    my @export_out = gbs_export($base, $spec, $packaging_dir, $upstream_branch, $upstream_tag);
 
     if (shift @export_out) {
         # if export failed, collect export error to report
@@ -786,6 +810,9 @@ sub prepare_git {
     my $config = shift;
     my $base = shift;
     my $spec = shift;
+       my $packaging_dir = shift;
+    my $upstream_branch = shift;
+    my $upstream_tag = shift;
     my $packs_queue = shift;
     my $spec_file = basename($spec);
 
@@ -843,7 +870,7 @@ sub prepare_git {
 
         } else {
             # if it's failed to write cache
-            unless (write_cache($cache_key, $val, $base, $spec_file)) {
+            unless (write_cache($cache_key, $val, $base, $spec_file, $packaging_dir, $upstream_branch, $upstream_tag)) {
                 clean_cache($cache_key);
                 debug("$pkg_name was not exported correctly");
                 return;
@@ -2306,7 +2333,8 @@ if ($style eq 'git') {
                $data_queue->enqueue(undef);
                threads->create(sub {
                        while (my $pack = $data_queue->dequeue()) {
-                               prepare_git($config, $pack->{"project_base_path"}, $pack->{"filename"}, $packs_queue);
+                               prepare_git($config, $pack->{"project_base_path"}, $pack->{"filename"},
+                    $pack->{"packaging_dir"}, $pack->{"upstream_branch"}, $pack->{"upstream_tag"}, $packs_queue);
                        }
                });
        }
index 5df88081758621b837d9a6be994d3a1791b8e29d..86b625b0bb14d8dbc36caa4ec36d2720d5661742 100644 (file)
@@ -11,6 +11,7 @@ Requires:       perl(YAML)
 Requires:       perl(JSON)
 Requires:       perl(HTML::Template)
 Requires:       tizen-build >= 20161231
+Requires:       perl(Config::Tiny)
 %if 0%{?centos_ver} == 7 || 0%{?suse_version} == 1315
 
 %else