#!/bin/bash # Copyright (c) 2010 Mia-Software # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v1.0 # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html # # Contributors: # Nicolas Bros (Mia-Software) set -o errexit set -o nounset SCRIPTS_DIR=${SCRIPTS_DIR:-$(readlink --canonicalize $(dirname $0))} XSLT_FILE="$SCRIPTS_DIR/addDownloadStats.xsl" [ -f "$XSLT_FILE" ] || { echo "addDownloadStats.xsl not found"; exit 1; } if [ $# -ne 1 ]; then echo "usage: $0 " exit fi [ -d "$1" ] || { echo "not a directory"; exit 1; } [ -f "$1/artifacts.jar" ] || { echo "artifacts.jar not found"; exit 1; } echo "Adding download stats to repository" cd "$1" unzip -o artifacts.jar mv artifacts.xml artifacts.xml.original if grep p2.statsURI artifacts.xml.original ; then echo "p2.statsURI already defined: exiting"; exit 1; fi # remove path prefix repository_path=$(echo $1 | sed 's/.*\/modeling/\/modeling/') echo "enabling download stats in update site '$repository_path'" xsltproc --stringparam repository_path "$repository_path" -o artifacts.xml $XSLT_FILE artifacts.xml.original rm -f artifacts.jar zip -q artifacts.jar artifacts.xml rm artifacts.xml echo "done."