Commits

Carlos Sola-Llonch  committed c051ef9

initial check-in

  • Participants

Comments (0)

Files changed (2)

File bar_maker.sh

+#!/usr/bin/env bash
+
+# simple script to create a bar file from an apk based on keystore
+# syntax bar_maker <keystore> <keypass> <Z10 ip address> <device pass> <apk input file> <output directory>
+
+if [ $(which apk2bar | wc -c) -eq 0 ]; then
+	echo BlackBerry Android commandline tools not found. Download from:
+	echo
+	echo http://developer.blackberry.com/android/tools 
+	echo
+	echo and add the blackberry.tools.SDK/bin directory to your PATH.
+	echo 
+	exit -1
+fi
+
+if [ $# -ne 6 ]; then
+	echo 'syntax: apk2bar <keystore> <keypass> <Z10 ip address> <device pass> <apk input file> <output directory>.' 1>&2
+	echo
+	exit -1
+fi
+
+if [ ! -f $1 ]; then
+	echo 'keystore not found.' 1>&2
+	echo
+	exit -1
+fi
+
+if [ $(openssl pkcs12 -in $1 -passin pass:$2 -info -noout 2>&1 | grep -c "MAC verified OK") -ne 1 ]; then
+	echo 'keystore password is invalid. just helping you out, man.' 1>&2
+	echo
+	exit -1
+fi
+
+if [ $(ping -c 1 -n $3 | grep -c '1 packets received') -ne 1 ]; then
+	echo 'Z10 device not reachable.' 1>&2
+	echo
+	exit -1
+fi
+
+# set some variables
+loc=$(which apk2bar)
+bin_loc=${loc%/apk2bar}
+sdk_root=${loc%/bin/apk2bar}
+
+#echo $bin_loc
+#echo $sdk_root
+
+output_dir=$(echo $6 | sed 's/\/$//')
+
+#echo $output_dir
+
+apk_file=${5%.apk}
+wrn_file=${apk_file##*/}.wrn
+bar_file=${apk_file##*/}.bar
+
+#echo $apk_file
+#echo $wrn_file
+#echo $bar_file
+
+#exit 0
+
+echo checking apk for compatibility...
+apk2barVerifier $5 -os 10 -t /var/tmp > /dev/null
+# awk program to make above output pretty
+awk -f parse_verify_results.awk /var/tmp/$wrn_file
+
+read -p "Do you wish to continue? " yn
+
+#echo "blackberry-signer -storepass $2 -keystore $1 -signedbar $output_dir/$bar_file /var/tmp/$bar_file"
+#exit 0
+
+if [ "$yn" == "yes" ]; then
+	echo yes
+	
+	# turn it into a bar
+	echo creating bar from apk file...
+	apk2bar $5 -t /var/tmp 1>/dev/null
+	
+	#sign the bar
+	pushd $sdk_root/bin > /dev/null
+	echo signing newly created bar file...
+	blackberry-signer -storepass $2 -keystore $1 -signedbar $output_dir/$bar_file /var/tmp/$bar_file
+	popd > /dev/null
+fi
+
+echo cleaning up...
+if [ -f  /var/tmp/$wrn_file ]; then
+	rm /var/tmp/$wrn_file > /dev/null
+fi
+if [ -f /var/tmp/$bar_file ]; then
+	rm /var/tmp/$bar_file > /dev/null
+fi
+
+# todo check for error before trying this
+read -p "Install signed bar file? " yn
+if [ "$yn" == "yes" ]; then
+	echo installing signed bar file...
+	blackberry-deploy -installApp -device $3 -password $4 $output_dir/$bar_file
+fi

File parse_verify_results.awk

+BEGIN {
+	FS = ":";
+};
+
+$0 ~ /impact=/ {
+	last_error = length(error_counts[$NF]) != 0 ? error_counts[$NF] : 0;
+	errors[$NF, last_error] = $0;
+	error_counts[$NF] = last_error + 1;
+};
+
+END {
+	for (i in error_counts) {
+		system("echo \"`tput bold`" i " (total " error_counts[i] ")`tput sgr0`\"");
+		max_val = error_counts[i];
+		cur_error = 0;
+		while (cur_error < max_val) {
+			split(errors[i,cur_error], flds, ":");
+			cmd = "echo '" errors[i,cur_error] "' | cut -d ':' -f 1-" length(flds)-1;
+			system(cmd);
+			++cur_error;
+		}
+		print ""
+	}
+}