Skip to content

Instantly share code, notes, and snippets.

@ndastur
Created January 18, 2013 21:33
Show Gist options
  • Save ndastur/4568789 to your computer and use it in GitHub Desktop.
Save ndastur/4568789 to your computer and use it in GitHub Desktop.
I got fed up of the fact that once I released a module into the Appcelerator marketplace I could not use it myself without getting Un-licensed module errors. So this script, modified the GUID and re-builds the module, then installs to the SDK location. Note that in more recent installs the SDK is located in home. Just change the line at 37,38 an…
#!/bin/bash
# make a backup file with the module GUID
# just in case there is some funny script error
# it will be available here
if [ ! -e "./moduleGUID_Backup.txt" ]
then
grep -i guid manifest > ./moduleGUID_Backup.txt
fi
OLD_UUID=`grep -i guid manifest | cut -d ' ' -f 2`
NEW_UUID=`uuidgen | tr [:upper:] [:lower:]`
MOD_ID=`grep -i moduleid manifest | cut -d ' ' -f 2`
MOD_PLATFORM=`grep -i platform manifest | cut -d ' ' -f 2`
MOD_VER=`grep -i ^version manifest | cut -d ' ' -f 2`
echo "Replace the GUID in the manifest ..."
sed -i .bak -e "s/$OLD_UUID/$NEW_UUID/" ./manifest
# Replace in the module class file
MOD_CLS_FILE_PREFIX=`echo ".$MOD_ID" | awk 'BEGIN { FS="." } ; { for ( i=1;i<=NF;i++) { sub(".", substr(toupper($i),1,1), $i) } print }' | tr -d " "`
MOD_CLS_FILE="./Classes/${MOD_CLS_FILE_PREFIX}Module.m"
echo "Replace the GUID in $MOD_CLS_FILE ..."
sed -i .bak -e "s/$OLD_UUID/$NEW_UUID/" $MOD_CLS_FILE
./build.py
# Restore
echo "Restore the old files back the originals"
mv ./manifest.bak ./manifest
mv ./${MOD_CLS_FILE}.bak ./$MOD_CLS_FILE
ZIP_FILE="${MOD_ID}-${MOD_PLATFORM}-${MOD_VER}.zip"
echo "Installing module $ZIP_FILE ..."
mv ${ZIP_FILE} "/Library/Application Support/Titanium"
(cd "/Library/Application Support/Titanium" && unzip -o ${ZIP_FILE})
echo "Remove the module zip file"
rm "/Library/Application Support/Titanium/${ZIP_FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment