]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Allow git-version.h to be provided for the build
authorWayne Davison <wayne@opencoder.net>
Mon, 7 Sep 2020 05:49:27 +0000 (22:49 -0700)
committerWayne Davison <wayne@opencoder.net>
Mon, 7 Sep 2020 06:09:11 +0000 (23:09 -0700)
For a non-git build or for a git build w/o adequate git history, we now
allow the git-version.h file to be provided before the build.  If the
file does not exist, we either create an empty file or put a define of
RSYNC_GITVER in it based on the output of git describe.  The github
builds now snag the git-version.h file that was generated for the last
commit so that they all get the same version string, even with a shallow
checkout.

.cirrus.yml
.github/workflows/build.yml
Makefile.in
mkgitver
usage.c

index 4150bf3cac670920f087094be21898f91a12925b..ba78af7d651bdb3d9b1ddca07c0d62692ad91718 100644 (file)
@@ -7,7 +7,8 @@ freebsd_task:
   prep_script:
     - dd if=/dev/zero of=/tmp/zpool bs=1M count=1024
     - zpool create -m `pwd`/testtmp zpool /tmp/zpool
-    - pkg install -y autotools xxhash zstd liblz4
+    - pkg install -y autotools xxhash zstd liblz4 wget
+    - wget https://download.samba.org/pub/rsync/generated-files/git-version.h
   configure_script:
     - CPPFLAGS=-I/usr/local/include/ LDFLAGS=-L/usr/local/lib/ ./configure --disable-md2man
   make_script:
index ce5eedf03050533c805fd2629c9cb865979eed85..f15f737b7ff58a406b165783d3cd458ff3dc58a3 100644 (file)
@@ -16,11 +16,10 @@ jobs:
     runs-on: ubuntu-20.04
     steps:
     - uses: actions/checkout@v2
-      with:
-        fetch-depth: 0
     - name: prep
       run: |
-        sudo apt-get install acl libacl1-dev attr libattr1-dev liblz4-dev libzstd-dev libxxhash-dev python3-cmarkgfm openssl
+        sudo apt-get install acl libacl1-dev attr libattr1-dev liblz4-dev libzstd-dev libxxhash-dev python3-cmarkgfm openssl wget
+        wget https://download.samba.org/pub/rsync/generated-files/git-version.h
         echo "::add-path::/usr/local/bin"
     - name: configure
       run: ./configure
@@ -55,8 +54,9 @@ jobs:
     - uses: actions/checkout@v2
     - name: prep
       run: |
-        brew install automake openssl xxhash zstd lz4
+        brew install automake openssl xxhash zstd lz4 wget
         sudo pip3 install commonmark
+        wget https://download.samba.org/pub/rsync/generated-files/git-version.h
         echo "::add-path::/usr/local/bin"
     - name: configure
       run: CPPFLAGS=-I/usr/local/opt/openssl/include/ LDFLAGS=-L/usr/local/opt/openssl/lib/ ./configure
@@ -91,7 +91,8 @@ jobs:
         args: install -y --no-progress cygwin cyg-get
     - name: prep
       run: |
-        cyg-get make autoconf automake gcc-core attr libattr-devel python3 python36-commonmark libzstd-devel liblz4-devel libssl-devel
+        cyg-get make autoconf automake gcc-core attr libattr-devel python3 python36-commonmark libzstd-devel liblz4-devel libssl-devel wget
+        wget https://download.samba.org/pub/rsync/generated-files/git-version.h
         echo "::add-path::C:/tools/cygwin/bin"
     - name: configure
       run: bash -c './configure --disable-xxhash'
index 2b55d9f7504ec350e68a579febf51786584e8090..a5514888f55b2636f4f4bdc1ceeee11a29dcf70a 100644 (file)
@@ -32,7 +32,7 @@ SHELL=/bin/sh
 SIMD_x86_64=simd-checksum-x86_64.o
 ASM_x86_64=lib/md5-asm-x86_64.o
 
-GENFILES=configure.sh aclocal.m4 config.h.in rsync.1 rsync.1.html \
+GENFILES=configure.sh aclocal.m4 config.h.in git-version.h rsync.1 rsync.1.html \
         rsync-ssl.1 rsync-ssl.1.html rsyncd.conf.5 rsyncd.conf.5.html
 HEADERS=byteorder.h config.h errcode.h proto.h rsync.h ifuncs.h itypes.h inums.h \
        lib/pool_alloc.h lib/mdigest.h lib/md-defines.h
@@ -254,7 +254,7 @@ rsyncd.conf.5: rsyncd.conf.5.md md2man version.h Makefile
 .PHONY: clean
 clean: cleantests
        rm -f *~ $(OBJS) $(CHECK_PROGS) $(CHECK_OBJS) $(CHECK_SYMLINKS) \
-               rounding rounding.h *.old rsync*.1 rsync*.5 rsync*.html \
+               git-version.h rounding rounding.h *.old rsync*.1 rsync*.5 rsync*.html \
                daemon-parm.h help-*.h default-*.h proto.h proto.h-tstamp
 
 .PHONY: cleantests
index c0dd1b5f86b62df9c6b6d9eb56e41e5cf21fd303..8e76774cce065fc116d5c3327a9543e47f726c4e 100755 (executable)
--- a/mkgitver
+++ b/mkgitver
@@ -3,9 +3,12 @@
 srcdir=`dirname $0`
 gitver=`git describe --abbrev=8 2>/dev/null`
 
-if test x"$gitver" != x; then
-    gitver=\""$gitver"\"
-else
-    gitver=RSYNC_VERSION
-fi
-echo "#define RSYNC_GITVER $gitver" >git-version.h
+case "$gitver" in
+    *.*)
+       echo "#define RSYNC_GITVER \"$gitver\"" >git-version.h
+       ;;
+    *)
+       # We either create an empty file or update the time on what the user gave us.
+       touch git-version.h
+       ;;
+esac
diff --git a/usage.c b/usage.c
index 2b5f3761d1b5c0c9a320f8e8c1d37efe2fc28150..f427263ecae095a15308a8dbccdafc82ed95b544 100644 (file)
--- a/usage.c
+++ b/usage.c
@@ -253,7 +253,11 @@ void daemon_usage(enum logcode F)
 
 const char *rsync_version(void)
 {
+#ifdef RSYNC_GITVER
        return RSYNC_GITVER;
+#else
+       return RSYNC_VERSION;
+#endif
 }
 
 const char *default_cvsignore(void)