ROM签名脚本[原创]

时间:2022-12-01 21:48:17

下面的代码是bash脚本来的。需要保存为*.sh后序。

# !/bin/bash
#usage: signapk.sh [-hs] [zipfile-unsigned | update.zip]
#Author: Gaojiquan LaoYang
#Date: -- : if [ "$1" = "-h" ];
then
# print the help info
echo "usages: signed the apk | zip file "
echo "signapk.sh [-hs] [zipfile-[unsigned.zip] | update.zip]"
echo "signapk.sh -h -> show help info "
echo "signapk.sh -s update -> update is the prefix of zipfile "
echo "signapk.sh -s update-unsigned.zip"
echo "signapk.sh [ -t key ] -s zifile[-unsigned.zip]" elif [ "$1" = "-s" ];
then
FILE_NAME=$(basename "$2")
echo " Signed Zip..."
#echo "FILE_NAME = $FILE_NAME"
#SIGN_FINE = if [ -f $FILE_NAME ];
then
SIGN_FILE="update-signed.zip"
TMP=$FILE_NAME
java -jar signapk.jar testkey.x509.pem testkey.pk8 $FILE_NAME update-signed.zip
elif [ -f $FILE_NAME.zip ];
then
SIGN_FILE=$FILE_NAME-signed.zip
TMP=$FILE_NAME.zip
java -jar signapk.jar testkey.x509.pem testkey.pk8 $FILE_NAME.zip $FILE_NAME-signed.zip
elif [ -f $FILE_NAME-unsigned.zip ];
then
SIGN_FILE=$FILE_NAME-signed.zip
TMP=$FILE_NAME-unsigned.zip
java -jar signapk.jar testkey.x509.pem testkey.pk8 $FILE_NAME-unsigned.zip $FILE_NAME-signed.zip
fi if [ $? = ];
then
echo "input file: $TMP"
echo "Output file: $SIGN_FILE"
echo "Signapk Success !"
exit ;
else
echo "Signapk Error! with $TMP"
exit ;
fi
#end signed zip #choose the signed key
#testkey
#releases
#you-keys
elif [ "$1" = "-t" ] && [ "$3" = "-s" ]; #check the args[] && args[]
then
if [ -f $.x509.pem ] && [ -f $.pk8 ]; #check the signed key exists;
then
FILE_NAME=$(basename "$4")
echo " Signed Zip..." if [ -f $FILE_NAME ];
then
SIGN_FILE="update-signed.zip"
TMP=$FILE_NAME
java -jar signapk.jar $.x509.pem $.pk8 $FILE_NAME update-signed.zip
elif [ -f $FILE_NAME.zip ];
then
SIGN_FILE=$FILE_NAME-signed.zip
TMP=$FILE_NAME.zip
java -jar signapk.jar $.x509.pem $.pk8 $FILE_NAME.zip $FILE_NAME-signed.zip
elif [ -f $FILE_NAME-unsigned.zip ];
then
SIGN_FILE=$FILE_NAME-signed.zip
TMP=$FILE_NAME-unsigned.zip
java -jar signapk.jar $.x509.pem $.pk8 $FILE_NAME-unsigned.zip $FILE_NAME-signed.zip
fi fi if [ $? = ];
then
echo "input file: $TMP"
echo "Output file: $SIGN_FILE"
echo "Signapk Success !"
exit ;
else
echo "Signapk Error! with $TMP"
exit ;
fi
#end the Advance signed #bad call option
else exit ;
fi #if [ -f $1 ] # check file exists
#then
# rm $
#fi #if [ -f $1-unsigned.zip ]
#then
# rm $-unsigned.zip
#lif [ -f $.zip ]
#then
# rm $.zip
#elif [ -f $1 ]
#then
# rm $
#fi