Add '--use-build-count' option.
authorwanchao-xu <wanchao.xu@samsung.com>
Tue, 11 Jun 2024 05:47:19 +0000 (13:47 +0800)
committerwanchao-xu <wanchao.xu@samsung.com>
Fri, 21 Jun 2024 02:19:39 +0000 (10:19 +0800)
* Gbs has a mistake while building multiple packages which have dependence.
* For example, to build package A and B by gbs, and package B depends on package A.
  - Build package A, and rpm of package A can be found in gbs build dir.
  - Build package B, the package A will be installed while building.
  - Modify package A and rebuild it.
  - Rebuild package B, package A is not re-installed because rpm name of package A is not changed.
* This option can add build count into package release while building package, so the rpm name of package will be different from previous build.

Change-Id: I5e7c785b9b72de5b39f848437979631200c5e922
Signed-off-by: wanchao-xu <wanchao.xu@samsung.com>
depanneur

index da1e78eaf7a5cffeae06ac5c31b6567f8ea79ca3..494afac1d04ff053d1869f456c9e64f7ae776fc5 100755 (executable)
--- a/depanneur
+++ b/depanneur
@@ -151,6 +151,7 @@ my @defines;            # define extra macros for 'rpmbuild'
 my $arg_spec = "";      # spec file to be built this time
 my $start_time = "";    # build start time
 my $gbs_version = "";   # show gbs version info in final report
+my $use_build_count = 0; # use build count to specify the release of package
 
 my @tofind = ();        # for resolve final build binary list
 my @pre_packs = ();       # temp packages data, item structure :
@@ -271,6 +272,7 @@ GetOptions (
     "with-submodules" => \$with_submodules,
     "release=s" => \$release_tag,
     "nocumulate" => \$nocumulate,
+    "use-build-count" => \$use_build_count,
     );
 
 if ( $help ) {
@@ -1965,6 +1967,29 @@ sub create_cache_local {
     my_system("cat '$order_dir'/.repo.cache.local '$order_dir'/.repo.cache.remote >'$order_dir'/.repo.cache");
 }
 
+#---------------------------------------------------------------------
+# update build count of package
+#---------------------------------------------------------------------
+sub update_build_count {
+    my ($pkg_name) = @_;
+    my $build_count_file = "$cache_path/$pkg_name.bcnt";
+    my $build_count = 1;
+
+    if (-e "$build_count_file") {
+        open(my $fh_in, '<', "$build_count_file")  or die "$build_count_file - $!";
+        my $line = readline($fh_in);
+        close($fh_in);
+        chomp $line;
+        $build_count = int($line) < 999 ? int($line) + 1 : 1;
+    }
+
+    open(my $fh, '>', "$build_count_file")  or die "$build_count_file - $!";
+    print $fh $build_count . "\n";
+    close($fh);
+
+    return $build_count;
+}
+
 #---------------------------------------------------------------------
 # Generate buid command and run it
 #---------------------------------------------------------------------
@@ -2090,7 +2115,12 @@ sub build_package {
     }
 
     if ($release_tag ne "") {
-       push @args, "--release=$release_tag";
+        push @args, "--release=$release_tag";
+    } else {
+        if ($use_build_count == 1) {
+            my $build_count = update_build_count("$name-$version-$release");
+            push @args, "--release=$release.$build_count";
+        }
     }
     if ($nocumulate) {
         push @args, "--nocumulate";