Add in acloud pre-setup routine.
Also update the default config path to ~/.config/acloud/acloud.config
Bug: 112615679
Test: acloud setup with test.sh
atest acloud_test
Change-Id: I2992c88ebddb3cfd8082a45035e2bd4d64119b32
diff --git a/setup/pre_setup_sh/acloud_pre_setup.sh b/setup/pre_setup_sh/acloud_pre_setup.sh
new file mode 100755
index 0000000..d6ad80e
--- /dev/null
+++ b/setup/pre_setup_sh/acloud_pre_setup.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Run any scripts in this dir and in any extra specified locations.
+SCRIPT_LOCATIONS=(
+ $(dirname $(realpath $0))
+ "$ANDROID_BUILD_TOP/vendor/google/tools/acloud"
+)
+
+for script_dir in ${SCRIPT_LOCATIONS[*]};
+do
+ if [[ ! -d $script_dir ]]; then
+ continue
+ fi
+ for script in $(ls ${script_dir}/*.sh);
+ do
+ if [[ $(basename $script) != $(basename $0) ]]; then
+ $script
+ fi
+ done
+done
diff --git a/setup/setup.py b/setup/setup.py
index f7cf18e..1660af0 100644
--- a/setup/setup.py
+++ b/setup/setup.py
@@ -20,6 +20,8 @@
"""
from __future__ import print_function
+import os
+import subprocess
from acloud.internal.lib import utils
from acloud.setup import host_setup_runner
@@ -37,6 +39,8 @@
Args:
args: Namespace object from argparse.parse_args.
"""
+ _RunPreSetup()
+
# Setup process will be in the following manner:
# 1.Print welcome message.
_PrintWelcomeMessage()
@@ -79,3 +83,19 @@
utils.PrintColorString("")
utils.PrintColorString("Setup process finished")
utils.PrintColorString("To get started creating AVDs, run '#acloud create'")
+
+
+def _RunPreSetup():
+ """This will run any pre-setup scripts.
+
+ If we can find any pre-setup scripts, run it and don't care about the
+ results. Pre-setup scripts will do any special setup before actual
+ setup occurs (e.g. copying configs).
+ """
+ build_top = os.environ.get("ANDROID_BUILD_TOP")
+ if build_top is None:
+ return
+ pre_setup_sh = os.path.join(build_top, "tools", "acloud", "setup",
+ "pre_setup_sh", "acloud_pre_setup.sh")
+ if os.path.exists(pre_setup_sh):
+ subprocess.call([pre_setup_sh])