[OS-BUILD PATCHv6 4/8] [redhat] Makefile.common, self-test/egit.sh, 1005-dist-dump-variables.bats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ben Crocker <bcrocker@xxxxxxxxxx>

• Makefile.common: make HEAD an overridable variable.
  Change
  GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H)
  to
  GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))

  making the argument to 'git log' explicit and allowing it to be
  overridden by, e.g., self-tests.
• 1005-dist-dump-variables.bats: override HEAD with the tag under test;
  simplifies (and speeds up) prologue, obviates epilogue, makes the
  whole process more robust by eliminating even temporary changes to
  the git repo;
• egit.sh: eliminate as-yet-unused merge-base case.

Signed-off-by: Ben Crocker <bcrocker@xxxxxxxxxx>

[redhat] Makefile.common: fix GITID for overridable HEAD

Signed-off-by: Ben Crocker <bcrocker@xxxxxxxxxx>
---
 redhat/Makefile.common                        | 13 ++++++-----
 .../self-test/1005-dist-dump-variables.bats   | 23 +------------------
 redhat/self-test/egit.sh                      |  9 --------
 3 files changed, 8 insertions(+), 37 deletions(-)

diff --git a/redhat/Makefile.common b/redhat/Makefile.common
index 80c3b8dfccd4..cdffa9fb3d3d 100644
--- a/redhat/Makefile.common
+++ b/redhat/Makefile.common
@@ -6,11 +6,12 @@ RPMBUILD := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
                    else echo rpm; fi)
 
 MACH :=  $(shell uname -m)
-RPMKVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}')
-RPMKPATCHLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}')
-RPMKSUBLEVEL:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}')
-RPMKEXTRAVERSION:=$(shell $(GIT) show HEAD:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}')
-GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H)
+HEAD ?= HEAD
+RPMKVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}')
+RPMKPATCHLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}')
+RPMKSUBLEVEL:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}')
+RPMKEXTRAVERSION:=$(shell $(GIT) show $(HEAD):Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}')
+GITID:= $(shell $(GIT) log --max-count=1 --pretty=format:%H $(HEAD))
 # marker is git tag which we base off of for exporting patches
 # Make sure marker uses RPMKPATCHLEVEL and RPMKEXTRAVERSION from the kernel
 # makefile as opposed to any adjusted version for snapshotting.
@@ -42,7 +43,7 @@ else
 endif
 ifeq ($(VERSION_ON_UPSTREAM),1)
   # master is expected to track mainline.
-  MERGE_BASE:=$(shell $(GIT) merge-base HEAD master)
+  MERGE_BASE:=$(shell $(GIT) merge-base $(HEAD) master)
   _TAG:=$(shell $(GIT) describe $(MERGE_BASE))
   # a snapshot off of a tagged git is of the form [tag]-[cnt]-g[hash]
   SNAPSHOT:=$(shell echo $(_TAG) | grep -c '\-g')
diff --git a/redhat/self-test/1005-dist-dump-variables.bats b/redhat/self-test/1005-dist-dump-variables.bats
index 2ebea70baf59..bff950e6643a 100644
--- a/redhat/self-test/1005-dist-dump-variables.bats
+++ b/redhat/self-test/1005-dist-dump-variables.bats
@@ -1,27 +1,10 @@
 #!/usr/bin/env bats
-function get_rpmversion
-{
-        # ts = tag or sha1
-        ts=$1
-        RPMKVERSION=$(git show $ts:Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}')
-        RPMKPATCHLEVEL=$(git show $ts:Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}')
-        RPMKSUBLEVEL=$(git show $ts:Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}')
-        RPMKEXTRAVERSION=$(git show $ts:Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}')
-}
 
 function prologue()
 {
     tag=$1
-    git show $tag:Makefile > Makefile
-    git add Makefile
-    git commit -m "Temporarily replace with $tag Makefile"
     ofile=$BATS_TMPDIR/$tag.out
-    GIT=$BATS_TEST_DIRNAME/egit.sh EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile
-}
-
-function epilogue()
-{
-    git reset --hard HEAD^
+    GIT=$BATS_TEST_DIRNAME/egit.sh HEAD=$tag EGIT_OVERRIDE_DESCRIBE=$tag DIST=.fc33 make dist-dump-variables > $ofile
 }
 
 @test "dist-dump-variables v5.8" {
@@ -32,7 +15,6 @@ function epilogue()
     then
         status=$?
     fi
-    epilogue
     [ "$status" = 0 ]
 }
 
@@ -44,7 +26,6 @@ function epilogue()
     then
         status=$?
     fi
-    epilogue
     [ "$status" = 0 ]
 }
 
@@ -56,7 +37,6 @@ function epilogue()
     then
         status=$?
     fi
-    epilogue
     [ "$status" = 0 ]
 }
 
@@ -68,6 +48,5 @@ function epilogue()
     then
         status=$?
     fi
-    epilogue
     [ "$status" = 0 ]
 }
diff --git a/redhat/self-test/egit.sh b/redhat/self-test/egit.sh
index b998f868a314..f26921cc2aca 100755
--- a/redhat/self-test/egit.sh
+++ b/redhat/self-test/egit.sh
@@ -12,15 +12,6 @@ case $arg in
             git describe "$@"
         fi
         ;;
-    merge-base )
-        if [ -n "$EGIT_OVERRIDE_MERGE_BASE" ]
-        then
-            # This should be an SHA1:
-            echo "$EGIT_OVERRIDE_MERGE_BASE"
-        else
-            git merge-base "$@"
-        fi
-        ;;
     * )
         git "$arg" "$@"
         ;;
-- 
GitLab
_______________________________________________
kernel mailing list -- kernel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to kernel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/kernel@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Tux]     [Yosemite News]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [USB]     [Asterisk PBX]

  Powered by Linux