Skip to content

Instantly share code, notes, and snippets.

@jaroel
Last active December 8, 2015 17:16
Show Gist options
  • Save jaroel/1a10a69731a20c746c63 to your computer and use it in GitHub Desktop.
Save jaroel/1a10a69731a20c746c63 to your computer and use it in GitHub Desktop.
Unpack Plone hotfixes into parts/products
#!/bin/bash
# ./add_hotfix.sh url md5hash [target basedir]
# i.e. ./add_hotfix.sh http://plone.org/products/plone-hotfix/releases/20110928/PloneHotfix20110928-1.0.zip aab87c2904754a2f6374f52c441fb97f /zeoclients/
PATCHFILE="/tmp/$(basename $0).$$"
rm -rf "$PATCHFILE"
curl "$1" > "$PATCHFILE"
MD5=`openssl md5 "$PATCHFILE"|cut -d " " -f 2`
[[ $MD5 != $2 ]] && echo "Hashes do not match." && exit 1
IS_ZIP=`file "$PATCHFILE"|grep "Zip archive data"`
IS_GZIP=`file "$PATCHFILE"|grep "gzip compressed data"`
BASEDIR=`cd ${3-.} && pwd`
echo "Appying patch to zeoclients in $BASEDIR"
for i in `find $BASEDIR -maxdepth 1 -mindepth 1 -type d|grep -v ".git"`
do
PRODUCTS="$i/parts/products/"
echo "Adding hotfix to folder $PRODUCTS"
mkdir -p $PRODUCTS
PRODUCTS=`cd "$PRODUCTS" && pwd`
cd $PRODUCTS
#tar zvxf "$PATCHFILE"
[[ -n "$IS_ZIP" ]] && unzip "$PATCHFILE"
[[ -n "$IS_GZIP" ]] && tar zvxf "$PATCHFILE"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment