cloud goes social

Icon

computer, travel, movies, music, cuisine and more

Sparkle script in XCode

So,
for a project that I’m working on (Reader Notifier Reloaded, more about it in a following post), I’ve been using Sparkle. It is a great tool for providing updates to the users.

Since Sparkle is using public/private key cryptography in order to sign the updates and guarantee their authenticity there is some “fiddling” one has to do in order to push out an update. Marc Liyanage provides us with a great way to do all the signing, packaging and xml generation for updates.

I’ve been using his technique and just adapted the shell script to make it work on my Snow Leopard 10.6.3 without the need of the libxml perl library.

In particular I’ve changed the SIGNATURE part to:

SIGNATURE=$(
	myvar=$(security find-generic-password -g -s "Sparkle Private Key" 2>&1 1>/dev/null | sed 's/.*-----BEGIN DSA PRIVATE KEY-----\\012\(.*\)\\012-----END DSA PRIVATE KEY-----.*/-----BEGIN DSA PRIVATE KEY-----\
\1\
-----END DSA PRIVATE KEY-----/g' | sed 's/\\012/\
/g')

echo "$myvar" > tmp.tmp

openssl dgst -sha1 -binary < "$ARCHIVE_FILENAME" \
| openssl dgst -dss1 -sign tmp.tmp \
| openssl enc -base64

rm tmp.tmp
)

So, here’s the script I’m using, if anyone wants it!

set -o errexit

if [[ $BUILD_STYLE != "Deploy" ]]; then
	echo Distribution target requires "'Deploy'" build style
	exit
fi

VERSION=$(defaults read "$BUILT_PRODUCTS_DIR/$PRODUCT_NAME.app/Contents/Info" CFBundleVersion)
DOWNLOAD_BASE_URL="http://www.example.com/some_product"
RELEASENOTES_URL="http://www.example.com/some_product/$VERSION.html"

ARCHIVE_FILENAME="${PRODUCT_NAME}_$VERSION.zip"
DOWNLOAD_URL="$DOWNLOAD_BASE_URL/$ARCHIVE_FILENAME"
KEYCHAIN_PRIVKEY_NAME="Sparkle Private Key"

WD=$PWD
cd "$BUILT_PRODUCTS_DIR"
rm -f "$PRODUCT_NAME"*.zip
ditto -ck --keepParent "$PRODUCT_NAME.app" "$ARCHIVE_FILENAME"

SIZE=$(stat -f %z "$ARCHIVE_FILENAME")
PUBDATE=$(LC_TIME=en_US date +"%a, %d %b %G %T %z")
SIGNATURE=$(
	myvar=$(security find-generic-password -g -s "Sparkle Private Key" 2>&1 1>/dev/null | sed 's/.*-----BEGIN DSA PRIVATE KEY-----\\012\(.*\)\\012-----END DSA PRIVATE KEY-----.*/-----BEGIN DSA PRIVATE KEY-----\
\1\
-----END DSA PRIVATE KEY-----/g' | sed 's/\\012/\
/g')

echo "$myvar" > tmp.tmp

openssl dgst -sha1 -binary < "$ARCHIVE_FILENAME" \
| openssl dgst -dss1 -sign tmp.tmp \
| openssl enc -base64

rm tmp.tmp
)

[ $SIGNATURE ] || { echo Unable to load signing private key with name "'$KEYCHAIN_PRIVKEY_NAME'" from keychain; false; }

cat > $VERSION.xml <<EOF
<item>
	<title>Version $VERSION</title>
	<sparkle:releaseNotesLink>$RELEASENOTES_URL</sparkle:releaseNotesLink>
	<pubDate>$PUBDATE</pubDate>
	<enclosure
		url="$DOWNLOAD_URL"
		sparkle:version="$VERSION"
		type="application/octet-stream"
		length="$SIZE"
		sparkle:dsaSignature="$SIGNATURE"
	/>
</item>
EOF

XCode custom templates

I’ve been developing some iPhone applications both for fun and profit. Always I haven’t liked the way XCode creates new files in a project. Not only I didn’t like the formatting of the top comment (where your name shows and so on) but also I most of the times found myself deleting all the pre-generated contents.

For this reason I’ve investigated a bit in how to create custom templates and, starting from Apple defaults and the work done by jad I put up a simple project that anyone can edit to change to their own preferences and a simple script that links the templates so that XCode can (and will!) show them when you create new files.

I hope someone will find it useful, if no-one does no big problems, I still use it for myself and my collaborators :)

You can find the project and installation instructions (just running the script) on github

~C

ImageMagick on iPhone – Xcode

UPDATE: iOS4.3 and Xcode4

PLEASE READ THE UPDATE

UPDATE! (30.08.09)
Thanks to Jon Kean (see comments) the downloadable project now shows how to use images with unusual number of bits per component. As usual look at the defines at the top to check the functionality you want.

UPDATE! (14.07.09)
Thanks to Karl (see comments) the downloadable project now shows different ways of integrating ImageMagick with Objective-C UIImages offering both compressed methods, using JPEG compression as an example, and raw-data methods. Look at the define at the top to change which method the program will be using.

Many of you have asked me if I could post an Xcode project example to use the libraries and ImageMagick, and so, here it is.

The code is self-describing so I didn’t comment it much, it’s just a few functions call. All it does in this case is loading an image from an UIImage (Objective-C) into a format that ImageMagick (C) understands and can manipulate. Then it applies an ImageMagick filter (OrderedPosterize), which uses a configuration file (thresholds.xml).

Everything is working fine, and you have the complete set of libraries, headers and configuration files, and a configured XCode project right at hand.

All downloadable from here

If you still have any problem, don’t hesitate to contact me!

ciop ciop

ABOUT

CLOUD GOES SOCIAL is the personal blog of Claudio Marforio.
He holds a MSc in Computer Science with focus on Information Security granted by ETH Zurich. He is currently a PhD Student in the System Security Group of ETH Zurich

Categories

Donate

If you appreciate my work, my applications, this blog in general or you simply feel like rewarding me for something please consider donate.
Any amount will motivate me in keeping up with the blog and the applications.


Thank you!

Donors

F. Olsen, W. Chang, W. Edmondson, C. Sharff, M. Brown, G. Helton, J. de Ruiter, K. Langner, K. Smith, T. OHalloran, B. Zabarauskas

Listening to ...