contrib/jenkins.sh: skip upload if nothing new

The contrib/jenkins.sh script gets triggered daily. Do not upload new
files unless a new commit was added (then the filename changes).
Otherwise the binary and timestamp change on the server each day, which
is confusing and potentially makes catching regressions harder.

I've also considered disabling the daily trigger for this repository,
but I think it's better to keep it so we notice without much delay if
changes in libosmocore or the toolchain cause a build failure.

Change-Id: I3f70d6149b29ec2ff7f185dfae8bc8d4a1953dc2
diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh
index 7877dcf..961acf1 100755
--- a/contrib/jenkins.sh
+++ b/contrib/jenkins.sh
@@ -71,14 +71,22 @@
 [ftp.osmocom.org]:48 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8iivY70EiR5NiGChV39gRLjNpC8lvu1ZdHtdMw2zuX
 EOF
 	SSH_COMMAND="ssh -o 'UserKnownHostsFile=/build/known_hosts' -p 48"
-	rsync --archive --copy-links --verbose --compress --delete --rsh "$SSH_COMMAND" \
-		$TOPDIR/sysmoOCTSIM/gcc/sysmoOCTSIM.{bin,elf} \
-			binaries@ftp.osmocom.org:web-files/osmo-ccid-firmware/latest/
-	rsync --archive --verbose --compress --rsh "$SSH_COMMAND" \
-		--exclude $TOPDIR/sysmoOCTSIM/gcc/sysmoOCTSIM.bin \
-		--exclude $TOPDIR/sysmoOCTSIM/gcc/sysmoOCTSIM.elf \
-		$TOPDIR/sysmoOCTSIM/gcc/*-*.{bin,elf} \
-			binaries@ftp.osmocom.org:web-files/osmo-ccid-firmware/all/
+	LATEST_BIN="$(cd "$TOPDIR"/sysmoOCTSIM/gcc/; ls -1 sysmoOCTSIM-*-*.bin)"
+
+	echo "LATEST_BIN: $LATEST_BIN"
+
+	if rsync --rsh "$SSH_COMMAND" binaries@ftp.osmocom.org:web-files/osmo-ccid-firmware/all/ | grep -q "$LATEST_BIN"; then
+		echo "Skipping upload, $LATEST_BIN has already been uploaded."
+	else
+		rsync --archive --copy-links --verbose --compress --delete --rsh "$SSH_COMMAND" \
+			$TOPDIR/sysmoOCTSIM/gcc/sysmoOCTSIM.{bin,elf} \
+				binaries@ftp.osmocom.org:web-files/osmo-ccid-firmware/latest/
+		rsync --archive --verbose --compress --rsh "$SSH_COMMAND" \
+			--exclude $TOPDIR/sysmoOCTSIM/gcc/sysmoOCTSIM.bin \
+			--exclude $TOPDIR/sysmoOCTSIM/gcc/sysmoOCTSIM.elf \
+			$TOPDIR/sysmoOCTSIM/gcc/*-*.{bin,elf} \
+				binaries@ftp.osmocom.org:web-files/osmo-ccid-firmware/all/
+	fi
 fi
 
 echo