From c9f8c35cfab7ee168bf074bbf456374bd6f9d4ec Mon Sep 17 00:00:00 2001 From: "jingui.ren" Date: Thu, 9 Aug 2018 20:16:48 +0800 Subject: [PATCH] add --style=tar feature, which can build with gbs export source Change-Id: Ib7a0764b29af886e9f611b8cbee77a1c9b7af397 Signed-off-by: jingui.ren --- depanneur | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/depanneur b/depanneur index ae047bf..d413ebc 100755 --- 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) { -- 2.34.1