From 9fc34a6b6c4d3378277766cb6e5301b89422601f Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Tue, 8 Nov 2016 10:33:20 -0500 Subject: [PATCH] add winsparkle xml updated script This script is needed to update a Windows Sparkle XML file for Windows auto-update. The script has been modified to take account of the new repository dl.ring.cx. It also requires gawk for inplace modifications. Change-Id: I4ca9b3fcc126e22db3b5303fabda3c666ef2f7f1 --- scripts/winsparkle-xml-updater.sh | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 scripts/winsparkle-xml-updater.sh diff --git a/scripts/winsparkle-xml-updater.sh b/scripts/winsparkle-xml-updater.sh new file mode 100755 index 00000000..7c274054 --- /dev/null +++ b/scripts/winsparkle-xml-updater.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Update SPARKLE_FILE with given executable +# Usage ./winsparkle-xml-updater.sh ring.exe <URI of winsparkle-ring.xml> + +PACKAGE=$1 +SPARKLE_SOURCE=$2 +SPARKLE_FILE=winsparkle-ring.xml +TMP_FILE=winsparkle.tmp +REPO_URL=${2%/${SPARKLE_FILE}} + + +if [ ! -f ${PACKAGE} ]; then + echo "Can't find package aborting..." + exit 1 +fi + +if [ ! -s ${SPARKLE_FILE} ]; then + wget --no-check-certificate --retry-connrefused --tries=20 --wait=2 \ + --random-wait --waitretry=10 ${SPARKLE_SOURCE} -O ${SPARKLE_FILE} + if [ $? -ne 0 ]; then + echo 'the winsparkle file have been badly overwriten; deleting it.' + rm -f winsparkle.xml + exit 1 + fi +fi + +if [[ $(basename ${PACKAGE}) == *"x86_64"* ]] +then + OS="windows-x64"; +else + OS="windows-x86"; +fi + +#update URI in <link> field +gawk -i inplace -v source="${SPARKLE_SOURCE}" '/<link>/{printf " <link>"; + printf source; print "</link>"; next}1' ${SPARKLE_FILE} + + +#update list with new image item +cat << EOS > ${TMP_FILE} + <item> + <title>Ring nightly $(date "+%Y/%m/%d %H:%M")</title> + <pubDate>$(date -R)</pubDate> + <enclosure url="${REPO_URL}/$(basename ${PACKAGE})" sparkle:version="$(date +%Y%m%d)" sparkle:shortVersionString="nightly-$(date "+%Y%m%d")" sparkle:os="${OS}" length="$(stat -c %s ${PACKAGE})" type="application/octet-stream" /> + </item> +EOS + +if [ -s ${SPARKLE_FILE} ];then + gawk -i inplace -v tmp="${TMP_FILE}" '/language/{print; while(getline line < tmp){print line};close(tmp);next}1' ${SPARKLE_FILE} + rm -f ${TMP_FILE} +else + echo 'empty SPARKLE_FILE' + rm -f ${TMP_FILE} + exit 1 +fi -- GitLab