用Android workspace簽章system app
指定AOSP目錄與要簽章成system app的檔案進行簽章
#!/bin/bash
if [ $# -lt 2 ]; then
echo "usage: signapp "
exit -1
fi
WORKSPACE="$1"
APKFILE="$2"
if [ -z "${WORKSPACE}" -o ! -d "${WORKSPACE}" ] ; then
echo "ERROR! not found the workspace directory ${WORKSPACE}"
exit -2
fi
if [ -z "${APKFILE}" -o ! -f "${APKFILE}" ] ; then
echo "ERROR! not found APP file! ${APKFILE}"
exit -3
fi
OUTDIR=$(dirname "${APKFILE}")
APKFILENAME=$(basename "${APKFILE}")
APKNANE_WITHOUT_EXT="${APKFILENAME%.*}"
OUTFILENAME="${OUTDIR}/${APKNANE_WITHOUT_EXT}_signed.apk"
#echo ${OUTDIR}
#echo ${APKFILENAME}
#echo ${APKNANE_WITHOUT_EXT}
#echo ${OUTFILENAME}
if [ -z "${APKFILE}" -o ! -f "${APKFILE}" ] ; then
echo "ERROR! not found APP file! ${APKFILE}"
exit -4
fi
TOOLFILE="${WORKSPACE}/prebuilts/sdk/tools/lib/signapk.jar"
KEYFILE1="${WORKSPACE}/build/target/product/security/platform.x509.pem"
KEYFILE2="${WORKSPACE}/build/target/product/security/platform.pk8"
if [ -z "${TOOLFILE}" -o ! -f "${TOOLFILE}" ] ; then
echo "ERROR! not found sign key tool! ${TOOLFILE}"
exit -5
fi
if [ -z "${KEYFILE1}" -o ! -f "${KEYFILE1}" ] ; then
echo "ERROR! not found platform pem file! ${KEYFILE1}"
exit -6
fi
if [ -z "${KEYFILE2}" -o ! -f "${KEYFILE2}" ] ; then
echo "ERROR! not found platform pk8 file! ${KEYFILE2}"
exit -7
fi
UNSIGN_APP=${APKFILE}
SIGNED_APP=${OUTFILENAME}
if [[ ${UNSIGN_APP} == ${SIGNED_APP} ]] ; then
echo "ERROR! input and output apk file are the same!"
exit -10
fi
echo "sign platform key from ${UNSIGN_APP} to ${SIGNED_APP}"
java -jar ${TOOLFILE} ${KEYFILE1} ${KEYFILE2} ${UNSIGN_APP} ${SIGNED_APP}
#!/bin/bash
if [ $# -lt 2 ]; then
echo "usage: signapp
exit -1
fi
WORKSPACE="$1"
APKFILE="$2"
if [ -z "${WORKSPACE}" -o ! -d "${WORKSPACE}" ] ; then
echo "ERROR! not found the workspace directory ${WORKSPACE}"
exit -2
fi
if [ -z "${APKFILE}" -o ! -f "${APKFILE}" ] ; then
echo "ERROR! not found APP file! ${APKFILE}"
exit -3
fi
OUTDIR=$(dirname "${APKFILE}")
APKFILENAME=$(basename "${APKFILE}")
APKNANE_WITHOUT_EXT="${APKFILENAME%.*}"
OUTFILENAME="${OUTDIR}/${APKNANE_WITHOUT_EXT}_signed.apk"
#echo ${OUTDIR}
#echo ${APKFILENAME}
#echo ${APKNANE_WITHOUT_EXT}
#echo ${OUTFILENAME}
if [ -z "${APKFILE}" -o ! -f "${APKFILE}" ] ; then
echo "ERROR! not found APP file! ${APKFILE}"
exit -4
fi
TOOLFILE="${WORKSPACE}/prebuilts/sdk/tools/lib/signapk.jar"
KEYFILE1="${WORKSPACE}/build/target/product/security/platform.x509.pem"
KEYFILE2="${WORKSPACE}/build/target/product/security/platform.pk8"
if [ -z "${TOOLFILE}" -o ! -f "${TOOLFILE}" ] ; then
echo "ERROR! not found sign key tool! ${TOOLFILE}"
exit -5
fi
if [ -z "${KEYFILE1}" -o ! -f "${KEYFILE1}" ] ; then
echo "ERROR! not found platform pem file! ${KEYFILE1}"
exit -6
fi
if [ -z "${KEYFILE2}" -o ! -f "${KEYFILE2}" ] ; then
echo "ERROR! not found platform pk8 file! ${KEYFILE2}"
exit -7
fi
UNSIGN_APP=${APKFILE}
SIGNED_APP=${OUTFILENAME}
if [[ ${UNSIGN_APP} == ${SIGNED_APP} ]] ; then
echo "ERROR! input and output apk file are the same!"
exit -10
fi
echo "sign platform key from ${UNSIGN_APP} to ${SIGNED_APP}"
java -jar ${TOOLFILE} ${KEYFILE1} ${KEYFILE2} ${UNSIGN_APP} ${SIGNED_APP}
留言