Skip to content

Commit

Permalink
Create packaged emulator compatible with mach.
Browse files Browse the repository at this point in the history
Creates/copies all the necessary files and folders need for a packaged
emulator to work with mach's un-packaging script and emulator starting
script.
  • Loading branch information
Brendan Dahl committed May 21, 2020
1 parent d9b8369 commit 84e6be5
Showing 1 changed file with 36 additions and 24 deletions.
60 changes: 36 additions & 24 deletions scripts/package-emulator.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
#!/bin/bash
set -
cd ..
. setup.sh
source build/envsetup.sh
HOST_ARCH=$(get_build_var HOST_ARCH)
lunch "aosp_${HOST_ARCH}-userdebug"
PRODUCT_OUT=$(get_build_var PRODUCT_OUT)
HOST_OUT=$(get_build_var HOST_OUT)
OUT_DIR=$(get_abs_build_var OUT_DIR)
OUT_TEMP_DIR=$(get_build_var OUT_DIR)/avd_package
# Default name compatible with mach's emulator extractor.
AVD_NAME="test-1"
AVD_DIR_NAME="${AVD_NAME}.avd"

mkdir -p $OUT_TEMP_DIR/$AVD_DIR_NAME

echo "avd.ini.encoding=UTF-8
path=/home/cltbld/.android/avd/${AVD_DIR_NAME}
path.rel=avd/${AVD_DIR_NAME}
target=android-29" > $OUT_TEMP_DIR/$AVD_NAME.ini

CONFIG_FILE=$OUT_TEMP_DIR/$AVD_DIR_NAME/config.ini
cp $PRODUCT_OUT/config.ini $CONFIG_FILE
sed -i 's/image\.sysdir\.1=x86\//image\.sysdir\.1=/g' $CONFIG_FILE
echo -e "abi.type=$HOST_ARCH\nhw.cpu.arch=$HOST_ARCH" >> $CONFIG_FILE

EMULATOR_FILES=(\
.config \
load-config.sh \
run-emulator.sh \
${HOST_OUT}/bin/adb \
${HOST_OUT}/bin/emulator \
${HOST_OUT}/bin/emulator-arm \
${HOST_OUT}/bin/mksdcard \
${HOST_OUT}/bin/qemu-android-x86 \
${HOST_OUT}/lib \
${HOST_OUT}/usr \
development/tools/emulator/skins \
prebuilts/qemu-kernel/arm/kernel-qemu-armv7 \
${PRODUCT_OUT}/system/build.prop \
${PRODUCT_OUT}/system.img \
${PRODUCT_OUT}/userdata.img \
${PRODUCT_OUT}/ramdisk.img)
${PRODUCT_OUT}/cache.img \
${OUT_TEMP_DIR}/${AVD_NAME}.ini \
${OUT_TEMP_DIR}/${AVD_DIR_NAME}/config.ini \
${PRODUCT_OUT}/encryptionkey.img \
${PRODUCT_OUT}/kernel-ranchu \
${PRODUCT_OUT}/ramdisk.img \
${PRODUCT_OUT}/VerifiedBootParams.textproto \
${PRODUCT_OUT}/system/build.prop \
${PRODUCT_OUT}/system-qemu.img \
${PRODUCT_OUT}/userdata.img)

EMULATOR_ARCHIVE="${OUT_DIR}/emulator.tar.gz"

echo "Creating emulator archive at $EMULATOR_ARCHIVE"

rm -rf $EMULATOR_ARCHIVE
tar -cvzf $EMULATOR_ARCHIVE --transform 's,^,b2g-distro/,S' --show-transformed-names ${EMULATOR_FILES[@]}
echo "Creating emulator archive at ${EMULATOR_ARCHIVE}"

# Create a file structure needed by mach.
rm -f $EMULATOR_ARCHIVE
tar -cvzf $EMULATOR_ARCHIVE --transform "\
s,^${PRODUCT_OUT}/system/,avd/${AVD_DIR_NAME}/,S;\
s,^${PRODUCT_OUT}/,avd/${AVD_DIR_NAME}/,S;\
s,^${OUT_TEMP_DIR}/,avd/,S" --show-transformed-names ${EMULATOR_FILES[@]}

0 comments on commit 84e6be5

Please sign in to comment.