Skip to content

Instantly share code, notes, and snippets.

@shroukkhan
Last active April 13, 2016 06:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shroukkhan/bf3ebed5b1e2b28979bf to your computer and use it in GitHub Desktop.
Save shroukkhan/bf3ebed5b1e2b28979bf to your computer and use it in GitHub Desktop.
this script will rename csipsimple and build fingi usage is simple, call it the same way you call build.sh no change is needed to your existing code. the script will automatically download csipsimple and actionbarsherlock if not found. put this scripp in your app (android_app ) folder ( same directory as build.sh) and call it like this: ./rename…
#!/bin/bash
############ check arguments #################
if [ -z "$1" ]
then
echo "No argument supplied, please provide product name and build type. such as: ./renameAndBuild.sh aloft debug "
exit
fi
############ setting paths #################
CURRENT_PATH=$PWD
OUTPUT_PATH=$CURRENT_PATH/build/$1
TMP_PATH=/tmp/$1
PARENT_DIRECTORY="$(dirname "$CURRENT_PATH")"
############ checkout from github #################
echo checking \if csipsimplelib is there...
if [ ! -d "$PARENT_DIRECTORY/csipsimplelib" ]; then
echo not found ... downloading from github
git clone https://github.com/fingi/csipsimple.git $PARENT_DIRECTORY/csipsimplelib
cp local.properties $PARENT_DIRECTORY/csipsimplelib/local.properties
fi
echo checking \if csipsimplelib is there...
if [ ! -d "$PARENT_DIRECTORY/actionbarsherlocklib" ]; then
git clone https://github.com/fingi/actionbarsherlock.git $PARENT_DIRECTORY/actionbarsherlocklib
cp local.properties $PARENT_DIRECTORY/csipsimplelib/local.properties
fi
############ update from github #################
echo updating from github....
cd $PARENT_DIRECTORY/csipsimplelib
git remote update
cd $PARENT_DIRECTORY/actionbarsherlocklib
git remote update
############ cp local.properties #################
cd $CURRENT_PATH
cp local.properties $PARENT_DIRECTORY/csipsimplelib/local.properties
cp local.properties $PARENT_DIRECTORY/csipsimplelib/local.properties
echo your files will be located at $OUTPUT_PATH
echo removing older files from $OUTPUT_PATH
rm -rf $OUTPUT_PATH
mkdir $OUTPUT_PATH
echo removing older files from temp directory at $TMP_PATH
rm -rf $TMP_PATH
mkdir $TMP_PATH
#copy back and forth...
cp -r ../* $TMP_PATH/
echo copying to $OUTPUT_PATH/ from $TMP_PATH/
cp -r $TMP_PATH/* $OUTPUT_PATH/
#now change the package name completely...
echo starting renaming...
echo creating \( $OUTPUT_PATH/csipsimplelib/src/com/fingi \) \in csipsimple \source folder..
mkdir $OUTPUT_PATH/csipsimplelib/src/com/fingi
echo creating \( $OUTPUT_PATH/csipsimplelib/src/com/fingi/$1 \) \in csipsimple \source folder..
mkdir $OUTPUT_PATH/csipsimplelib/src/com/fingi/$1
echo moving \source files...
mv $OUTPUT_PATH/csipsimplelib/src/com/csipsimple $OUTPUT_PATH/csipsimplelib/src/com/fingi/$1/csipsimple
echo renaming java files..
find $OUTPUT_PATH/ -name '*.java' -type f -print0 | xargs -0 sed -i "s/com.csipsimple/com.fingi.$1.csipsimple/g"
echo renaming aidl files..
find $OUTPUT_PATH/ -name '*.aidl' -type f -print0 | xargs -0 sed -i "s/com.csipsimple/com.fingi.$1.csipsimple/g"
echo renaming xml files..
find $OUTPUT_PATH/ -name '*.xml' -type f -print0 | xargs -0 sed -i "s/com.csipsimple/com.fingi.$1.csipsimple/g"
echo renaming txt files..
find $OUTPUT_PATH/ -name '*.txt' -type f -print0 | xargs -0 sed -i "s/com.csipsimple/com.fingi.$1.csipsimple/g"
echo renaming xsl files
find $OUTPUT_PATH/ -name '*.xsl' -type f -print0 | xargs -0 sed -i "s/com.csipsimple/com.fingi.$1.csipsimple/g"
echo removing build stage files and class files...
rm -rf $OUTPUT_PATH/app/build_stage/*
rm -rf $OUTPUT_PATH/app/build/*
find $OUTPUT_PATH/ -name "gen" | xargs rm -Rf
find $OUTPUT_PATH/ -name "bin" | xargs rm -Rf
find $OUTPUT_PATH/ -name ".git" | xargs rm -Rf
find $OUTPUT_PATH/ -name ".svn" | xargs rm -Rf
echo ----- \complete ------
echo changing directory to $OUTPUT_PATH/app/
cd $OUTPUT_PATH/app/
echo
echo starting build... [ $1 $2 $3 $4 $5 $6 $7]
echo
echo
./build.sh $1 $2 $3 $4 $5 $6 $7
cp -rf $OUTPUT_PATH/app/build/*.apk $CURRENT_PATH/build/
rm -rf $OUTPUT_PATH
echo you shall \find your apk \in $CURRENT_PATH/build/ directory...
@shroukkhan
Copy link
Author

this is working on bom's old build.sh script that marco had prepared for him while we were still in suk 33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment