From e47df6fdfe1cee5eaa3583b6959161b24c4b6bcc Mon Sep 17 00:00:00 2001 From: Vincent Petithory Date: Sun, 20 Jan 2013 23:22:56 +0100 Subject: Add Client updates tools to generate zip updates. --- tools/client-updates/src/client-updates-gen | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 tools/client-updates/src/client-updates-gen (limited to 'tools/client-updates/src/client-updates-gen') diff --git a/tools/client-updates/src/client-updates-gen b/tools/client-updates/src/client-updates-gen new file mode 100755 index 00000000..76c0ed34 --- /dev/null +++ b/tools/client-updates/src/client-updates-gen @@ -0,0 +1,68 @@ +#!/bin/sh + +# config +SRC=$(dirname $(readlink -f "$0")) + +. ${SRC}/client-updates.conf + +# Check we are on the $CLIENT_DATA_BRANCH branch +git --git-dir "${CLIENT_DATA_DIR}/.git" branch | grep -q "^* $CLIENT_DATA_BRANCH" || { echo "The client-data repository is not on $CLIENT_DATA_BRANCH branch. Exiting"; exit 2; } + +# Unless specified on 1st argument, we'll use the latest revision that was +# included in updates, as starting revision. +# If this is the initial generation, this argument is mandatory. +if [ $# -gt 0 ]; then + OLD_CLIENT_DATA_HEAD="$1" +else + # Get the last commit sha where we generated an update + # This assumes the generated zip names follow the pattern: update-SHA1..SHA2.zip + OLD_CLIENT_DATA_HEAD=$(tail -n 1 ${UPDATES_DIR}/release/resources2.txt | cut -d . -f 3) +fi + +# Unless specified on 2nd argument, we'll use the HEAD as final revision. +if [ $# -gt 1 ]; then + NEW_CLIENT_DATA_HEAD="$2" +else + # get the commit SHA from the client data repo + NEW_CLIENT_DATA_HEAD=$(git --git-dir "${CLIENT_DATA_DIR}/.git" rev-parse HEAD | cut -c 1-7) +fi + +if [ "$OLD_CLIENT_DATA_HEAD" = "$NEW_CLIENT_DATA_HEAD" ]; then + echo "Everything is up-to-date." + exit 0 +fi + +update_basename="update-${OLD_CLIENT_DATA_HEAD}..${NEW_CLIENT_DATA_HEAD}" + +# generate a diff of files to package +cd ${CLIENT_DATA_DIR} +git --git-dir "${CLIENT_DATA_DIR}/.git" log --name-status ${OLD_CLIENT_DATA_HEAD}..${NEW_CLIENT_DATA_HEAD} | awk '/^(A|M)\t/ {print $2}' | sort | uniq | xargs zip -9 -r "${UPDATES_DIR}/${update_basename}.zip" > /dev/null +cd - > /dev/null + +if [ ! -f "${UPDATES_DIR}/${update_basename}.zip" ];then + echo "Error while generating ${update_basename}.zip. Exiting." > /dev/stderr + exit 1 +fi + +# package update +cd "${UPDATES_DIR}" +mkdir -p "release" +${SRC}/adler32 "${update_basename}.zip" >> "release/resources2.txt" +hash=$(tail -n 1 "release/resources2.txt" | awk '{ print $2; }') +# populate resources.xml as well +xmlentry="" + +sed -i '$d' 'release/resources.xml' +echo " $xmlentry" >> 'release/resources.xml' +echo '' >> 'release/resources.xml' + +echo "Adding ${update_basename}.zip:" +# Display the contents of the update +unzip -l ${update_basename}.zip +mv "${update_basename}.zip" "release/" +# Copy resources +git add 'release' +git commit -m "Updating resources to ${NEW_CLIENT_DATA_HEAD}" > /dev/null +cd - > /dev/null + +exit 0 -- cgit v1.2.3-60-g2f50