1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00

a much more robust tools/build-beta

This commit is contained in:
Ashley Willis 2013-06-30 15:49:38 -04:00
parent 85e7d4fa12
commit 92faef62f1

121
tools/build-beta Normal file → Executable file
View File

@ -1,16 +1,107 @@
BETA_PACKAGE=com.fsck.k9beta #!/bin/bash
BETA_PATH=com/fsck/k9beta
BETA_PROJ_NAME="K9 Beta" # The MIT License
perl -pi -e"s|\@string/app_name|\@string/beta_app_name|g" AndroidManifest.xml #
perl -pi -e"s|com/fsck/k9/R.java|$BETA_PATH/R.java|g" build.xml # Copyright 2012 Ashley Willis <ashley.github@gmail.com>
find src/com/fsck res -type f |xargs -n 1 perl -pi -e"s/com.fsck.k9(?=\W)/$BETA_PACKAGE/g" #
perl -pi -e"s|com.fsck.k9|$BETA_PACKAGE|g" AndroidManifest.xml # Permission is hereby granted, free of charge, to any person obtaining a copy
mv src/com/fsck/k9 src/$BETA_PATH # of this software and associated documentation files (the "Software"), to deal
perl -pi -e"s|K9|$BETA_PROJ_NAME|g" build.xml # in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Based off original tools/build-beta by Jesse Vincent.
# Works on OS X and Linux.
# Temporarily rename an Android project for building.
# Set the first 5 or 6 DIST_* and BETA_* to whatever you are going from and to.
# Set PROJECT_DIR to the absolute path pf the main project.
# Set TEST_DIR to the absolute path of the test project.
# Then run this script with the same arguments you'd pass to ant. It can be
# run from either $PROJECT_DIR or $TEST_DIR. It might require tweaks
# depending on how your project is laid out.
PROJECT_DIR=.
TEST_DIR=${PROJECT_DIR}/tests
DIST_TLD=com
DIST_DOMAIN=fsck
DIST_PROJECT=k9
DIST_LOGTAG=k9
DIST_PROJ_NAME=K9
DIST_APP_NAME='\@string/app_name'
BETA_TLD=com
BETA_DOMAIN=fsck
BETA_PROJECT=k9beta
BETA_LOGTAG=k9beta
BETA_PROJ_NAME='K9 Beta'
BETA_APP_NAME='K-9 Beta'
# Nothing below here should need to be changed.
DIST_PACKAGE="${DIST_TLD}.${DIST_DOMAIN}.${DIST_PROJECT}"
DIST_PATH="${DIST_TLD}/${DIST_DOMAIN}/${DIST_PROJECT}"
BETA_PACKAGE="${BETA_TLD}.${BETA_DOMAIN}.${BETA_PROJECT}"
BETA_PATH="${BETA_TLD}/${BETA_DOMAIN}/${BETA_PROJECT}"
# convert to beta project:
perl -pi -e"s|${DIST_APP_NAME}|${BETA_APP_NAME}|g" ${PROJECT_DIR}/AndroidManifest.xml
perl -pi -e"s|${DIST_PACKAGE}|${BETA_PACKAGE}|g" ${PROJECT_DIR}/AndroidManifest.xml ${TEST_DIR}/AndroidManifest.xml
perl -pi -e"s|${DIST_PROJ_NAME}|${BETA_PROJ_NAME}|g" ${PROJECT_DIR}/build.xml ${TEST_DIR}/build.xml
perl -pi -e"s|LOG_TAG = \"${DIST_LOGTAG}\"|LOG_TAG = \"${BETA_LOGTAG}\"|" ${PROJECT_DIR}/src/${DIST_PATH}/${DIST_PROJ_NAME}.java
find ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN} ${PROJECT_DIR}/res ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN} ${TEST_DIR}/res \
-type f -print0 | xargs -0 perl -pi -e"s/${DIST_PACKAGE}(?=\W)/${BETA_PACKAGE}/g"
if [[ "${DIST_PROJECT}" != "${BETA_PROJECT}" ]]; then
mv ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${DIST_PROJECT} ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${BETA_PROJECT}
mv ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${DIST_PROJECT} ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${BETA_PROJECT}
fi
if [[ "${DIST_DOMAIN}" != "${BETA_DOMAIN}" ]]; then
mv ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN} ${PROJECT_DIR}/src/${DIST_TLD}/${BETA_DOMAIN}
mv ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN} ${TEST_DIR}/src/${DIST_TLD}/${BETA_DOMAIN}
fi
if [[ "${DIST_TLD}" != "${BETA_TLD}" ]]; then
mv ${PROJECT_DIR}/src/${DIST_TLD} ${PROJECT_DIR}/src/${BETA_TLD}
mv ${TEST_DIR}/src/${DIST_TLD} ${TEST_DIR}/src/${BETA_TLD}
fi
# do ant and save exit status:
ant $@ ant $@
mv src/$BETA_PATH src/com/fsck/k9 MYEXIT=$?
perl -pi -e"s|$BETA_PACKAGE|com.fsck.k9|g" AndroidManifest.xml
perl -pi -e"s|$BETA_PATH/R.java|com/fsck.k9/R.java|g" build.xml # convert back to normal project:
find src/com/fsck res -type f |xargs -n 1 perl -pi -e"s/$BETA_PACKAGE(?=\W)/com.fsck.k9/g" if [[ "${DIST_TLD}" != "${BETA_TLD}" ]]; then
perl -pi -e"s|$BETA_PROJ_NAME|K9|g" build.xml mv ${PROJECT_DIR}/src/${BETA_TLD} ${PROJECT_DIR}/src/${DIST_TLD}
perl -pi -e"s|\@string/beta_app_name|\@string/app_name|g" AndroidManifest.xml mv ${TEST_DIR}/src/${BETA_TLD} ${TEST_DIR}/src/${DIST_TLD}
fi
if [[ "${DIST_DOMAIN}" != "${BETA_DOMAIN}" ]]; then
mv ${PROJECT_DIR}/src//${DIST_TLD}/${BETA_DOMAIN} ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}
mv ${TEST_DIR}/src//${DIST_TLD}/${BETA_DOMAIN} ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}
fi
if [[ "${DIST_PROJECT}" != "${BETA_PROJECT}" ]]; then
mv ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${BETA_PROJECT} ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${DIST_PROJECT}
mv ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${BETA_PROJECT} ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN}/${DIST_PROJECT}
fi
find ${PROJECT_DIR}/src/${DIST_TLD}/${DIST_DOMAIN} ${PROJECT_DIR}/res ${TEST_DIR}/src/${DIST_TLD}/${DIST_DOMAIN} ${TEST_DIR}/res \
-type f -print0 | xargs -0 perl -pi -e"s/${BETA_PACKAGE}(?=\W)/${DIST_PACKAGE}/g"
perl -pi -e"s|LOG_TAG = \"${BETA_LOGTAG}\"|LOG_TAG = \"${DIST_LOGTAG}\"|" ${PROJECT_DIR}/src/${DIST_PATH}/${DIST_PROJ_NAME}.java
perl -pi -e"s|${BETA_PROJ_NAME}|${DIST_PROJ_NAME}|g" ${PROJECT_DIR}/build.xml ${TEST_DIR}/build.xml
perl -pi -e"s|${BETA_PACKAGE}|${DIST_PACKAGE}|g" ${PROJECT_DIR}/AndroidManifest.xml ${TEST_DIR}/AndroidManifest.xml
perl -pi -e"s|${BETA_APP_NAME}|${DIST_APP_NAME}|g" ${PROJECT_DIR}/AndroidManifest.xml
# exit with value from ant:
exit ${MYEXIT}