guix: make git tag and commit known prior to building #22680

pull achow101 wants to merge 2 commits into bitcoin:master from achow101:guix-use-tag changing 2 files +13 −6
  1. achow101 commented at 1:54 am on August 11, 2021: member

    Guix currently builds from the source archive produced by git archive in a location outside of the git tree. This means that share/genbuild.sh will be unable to determine the version number from git because there is no git information available to it during the build. In order for the correct version to be set, share/genbuild.sh will now fallback to GIT_TAG and GIT_COMMIT environment variables if they are set. Guix makes use of this by setting GIT_TAG and GIT_COMMIT before leaving the git tree so that during the build, share/genbuild.sh will create a build.h file containing the correct values for the version string.

    Fixes #22623

  2. build: Allow GIT_TAG and GIT_COMMIT to be specified to genbuild.sh
    genbuild.sh figures out GIT_TAG and GIT_COMMIT by checking with git, but
    if git is not available, it generates a blank build.h file. However
    sometimes we will know the tag or commit and want to provide it to
    genbuild.sh even when git is not available. Now GIT_TAG and GIT_COMMIT
    can be set as environment variables, and if genbuild.sh cannot ask git
    for this information, it will fallback to what was provided.
    6b6b8e7ede
  3. achow101 commented at 1:54 am on August 11, 2021: member
    Needs 22.0 backport
  4. fanquake added the label DrahtBot Guix build requested on Aug 11, 2021
  5. fanquake added the label Scripts and tools on Aug 11, 2021
  6. fanquake commented at 1:58 am on August 11, 2021: member
     0In contrib/guix/libexec/build.sh line 243:
     1export GIT_TAG=$(git describe --exact-match 2> /dev/null)
     2       ^-----^ SC2155: Declare and assign separately to avoid masking return values.
     3
     4
     5In contrib/guix/libexec/build.sh line 244:
     6export GIT_COMMIT=$(git rev-parse --short=12 HEAD)
     7       ^--------^ SC2155: Declare and assign separately to avoid masking return values.
     8
     9For more information:
    10  https://www.shellcheck.net/wiki/SC2155 -- Declare and assign separately to ...
    11^---- failure generated from test/lint/lint-shell.sh
    
  7. guix: set GIT_TAG and GIT_COMMIT before building
    The environemnet variables GIT_TAG and GIT_COMMIT allow
    share/genbuild.sh know what the git tag and commit are so the version
    string can be correctly set. This is needed because the build will occur
    outside of the git tree, so genbuild.sh will be unable to determine this
    information itself.
    cb4b1906bf
  8. achow101 force-pushed on Aug 11, 2021
  9. in share/genbuild.sh:22 in 6b6b8e7ede outdated
    17@@ -18,17 +18,14 @@ else
    18     exit 1
    19 fi
    20 
    21-GIT_TAG=""
    22-GIT_COMMIT=""
    23+GIT_TAG="${GIT_TAG:-}"
    24+GIT_COMMIT="${GIT_COMMIT:-}"
    


    hebasto commented at 8:25 am on August 11, 2021:

    6b6b8e7edeba3360738fb40ebc12872a81089967

    Should we check GIT_TAG and GIT_COMMIT for emptiness, and run the following if block only when they are empty?


    achow101 commented at 7:30 pm on August 11, 2021:
    No, I did it this way specifically to allow for GIT_TAG and GIT_COMMIT to be fallbacks. So if we are in the git work tree, then it won’t be possible to accidentally override them with the incorrect values.
  10. in share/genbuild.sh:28 in 6b6b8e7ede outdated
    29     # if latest commit is tagged and not dirty, then override using the tag name
    30-    RAWDESC=$(git describe --abbrev=0 2>/dev/null)
    31-    if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
    32-        git diff-index --quiet HEAD -- && GIT_TAG=$RAWDESC
    33-    fi
    34+    git diff-index --quiet HEAD -- && GIT_TAG=$(git describe --exact-match 2>/dev/null)
    


    hebasto commented at 8:25 am on August 11, 2021:

    6b6b8e7edeba3360738fb40ebc12872a81089967

    Why this change is required?


    achow101 commented at 7:31 pm on August 11, 2021:
    It isn’t, but it’s simpler.
  11. in contrib/guix/libexec/build.sh:247 in cb4b1906bf
    242+# what tag and commit to use.
    243+# We want "git describe" to not cause an exit on failure and just be set to ""
    244+# shellcheck disable=SC2155
    245+export GIT_TAG=$(git describe --exact-match 2> /dev/null)
    246+git_commit=$(git rev-parse --short=12 HEAD)
    247+export GIT_COMMIT=${git_commit}
    


    hebasto commented at 8:27 am on August 11, 2021:

    cb4b1906bfbd636df8e7dd7fedee5d0951d2e3b1

    Why not just

    0export GIT_COMMIT=$(git rev-parse --short=12 HEAD)
    

    ?


    achow101 commented at 7:31 pm on August 11, 2021:

    hebasto commented at 7:36 pm on August 11, 2021:
    0GIT_COMMIT=$(git rev-parse --short=12 HEAD)
    1export GIT_COMMIT
    

    to do not introduce a new variable git_commit?

  12. hebasto commented at 8:30 am on August 11, 2021: member

    Concept ACK.

    Btw, a top commit hash is available in git archive:

    Additionally the commit ID is stored in a global extended pax header if the tar format is used; it can be extracted using git get-tar-commit-id.

  13. achow101 commented at 9:00 pm on August 11, 2021: member
    Closing in favor of #22685. I think using the version already being set in source is better than trying to extract it from git tags.
  14. achow101 closed this on Aug 11, 2021

  15. fanquake removed the label DrahtBot Guix build requested on Aug 12, 2021
  16. DrahtBot commented at 6:59 pm on August 12, 2021: member

    Guix builds

    File commit c3545a7396787c1d649f2d12fcb380b714cab6b2(master) commit e451db2c246b03f858f7af9882e8c20bed3b8b65(master and this pull)
    SHA256SUMS.part 204b7435d5668c46... c9ba49283c4c798c...
    *-aarch64-linux-gnu-debug.tar.gz f2f60a08f86d1e3d... 6bc522cda9a52ed9...
    *-aarch64-linux-gnu.tar.gz d1dff7253f312faa... 2b4ac46fb9b5e306...
    *-arm-linux-gnueabihf-debug.tar.gz 08a0e7286cc0323b... 0b8b0ba4157d62f2...
    *-arm-linux-gnueabihf.tar.gz bc42ea614f6ee4e1... ccc96b6955b82ad9...
    *-osx-unsigned.dmg 8efddd2a903d8270... 045213cb14232686...
    *-osx-unsigned.tar.gz 02c61265581c8320... 64c2eaf81bdc7176...
    *-osx64.tar.gz c62a3ef993e9edb2... fa2e0cd75c35a697...
    *-powerpc64-linux-gnu-debug.tar.gz bd09186d433213fa... 662bec65ee399ff8...
    *-powerpc64-linux-gnu.tar.gz d5c0bb487cf1aeec... 2e5886436d047abd...
    *-powerpc64le-linux-gnu-debug.tar.gz 7576ce96ed1d4750... c213038f1e9d9255...
    *-powerpc64le-linux-gnu.tar.gz d6dba31fd3d6f899... 7995c5845c9462a3...
    *-riscv64-linux-gnu-debug.tar.gz f8a9b54e5357f5ee... 73bc3227b80d4abd...
    *-riscv64-linux-gnu.tar.gz c3f721496efd3236... d29c5ca1df355cd4...
    *-win-unsigned.tar.gz 12f6a985fd0aaaff... 6968af6ab95373cd...
    *-win64-debug.zip d545291682591d2e... 267205c6cf2dc442...
    *-win64-setup-unsigned.exe e38f766e78bc8139... 1a0671a33563a645...
    *-win64.zip 5533af634afe65c1... 995079abb2d9d4fa...
    *-x86_64-linux-gnu-debug.tar.gz fe932ffc39d88398... c343e050e4b9507a...
    *-x86_64-linux-gnu.tar.gz 06b6c7d43ee31981... 1d39abc1f20eeb3f...
    *.tar.gz b8c2072ee95dcef5... e27f950b512aa444...
    guix_build.log 8acbda7979e2c7b6... 5a8da82906da27d5...
    guix_build.log.diff c30cd0f230b6ab60...
  17. DrahtBot locked this on Aug 18, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me