1#!/bin/bash 2 3function replace() 4{ 5 echo replacing $1 6 rm $V -rf "$UNZIPPED_BASE_DIR"/$1 7 cp $V -rf "$UNZIPPED_IMAGE_DIR"/$1 "$UNZIPPED_BASE_DIR"/$1 8} 9 10V="" 11Q="-q" 12if [ "$1" == "-v" ]; then 13 V="-v" 14 Q="" 15 shift 16fi 17 18NOZIP="" 19if [ "$1" == "-nozip" ]; then 20 NOZIP="1" 21 shift 22fi 23 24BASE="$1" 25IMAGES="$2" 26OUTPUT="$3" 27 28if [[ -z "$BASE" || -z "$IMAGES" || -z "$OUTPUT" ]] ; then 29 echo "usage: combine_sdks.sh [-v] [-nozip] BASE IMAGES OUTPUT" 30 echo 31 echo " BASE and IMAGES should be sdk zip files. The system image files," 32 echo " emulator and other runtime files will be copied from IMAGES and" 33 echo " everything else will be copied from BASE. All of this will be" 34 echo " bundled into OUTPUT and zipped up again (unless -nozip is specified)." 35 echo 36 exit 1 37fi 38 39TMP=$(mktemp -d) 40 41TMP_ZIP=tmp.zip 42 43# determine executable extension 44case `uname -s` in 45 *_NT-*) # for Windows 46 EXE=.exe 47 ;; 48 *) 49 EXE= 50 ;; 51esac 52 53BASE_DIR="$TMP"/base 54IMAGES_DIR="$TMP"/images 55OUTPUT_TMP_ZIP="$BASE_DIR/$TMP_ZIP" 56 57unzip $Q "$BASE" -d "$BASE_DIR" 58unzip $Q "$IMAGES" -d "$IMAGES_DIR" 59 60UNZIPPED_BASE_DIR=$(echo "$BASE_DIR"/*) 61UNZIPPED_IMAGE_DIR=$(echo "$IMAGES_DIR"/*) 62 63# 64# The commands to copy over the files that we want 65# 66 67# replace tools/emulator # at this time we do not want the exe from SDK1.x 68replace tools/lib/images 69replace tools/lib/res 70replace tools/lib/fonts 71replace tools/lib/layoutlib.jar 72replace docs 73replace android.jar 74 75for i in widgets categories broadcast_actions service_actions; do 76 replace tools/lib/$i.txt 77done 78 79if [ -d "$UNZIPPED_BASE_DIR"/usb_driver ]; then 80 replace usb_driver 81fi 82 83# 84# end 85# 86 87if [ -z "$NOZIP" ]; then 88 pushd "$BASE_DIR" &> /dev/null 89 # rename the directory to the leaf minus the .zip of OUTPUT 90 LEAF=$(echo "$OUTPUT" | sed -e "s:.*\.zip/::" | sed -e "s:.zip$::") 91 mv * "$LEAF" 92 # zip it 93 zip $V -qr "$TMP_ZIP" "$LEAF" 94 popd &> /dev/null 95 96 cp $V "$OUTPUT_TMP_ZIP" "$OUTPUT" 97 echo "Combined SDK available at $OUTPUT" 98else 99 OUT_DIR="${OUTPUT//.zip/}" 100 mv $V "$BASE_DIR"/* "$OUT_DIR" 101 echo "Unzipped combined SDK available at $OUT_DIR" 102fi 103 104rm $V -rf "$TMP" 105 106