factory: remove factory_common.py
With py/cli/factory_env.py, we can run scripts under bin/ correctly.
This CL removes factory_common.py and fix some scripts that are calling
python scripts directly (not via factory_env under bin/).
BUG=b:112251287
TEST=make test ==> image_tool_unittest is failing
TEST=make toolkit
TEST=install toolkit on DUT, goofy starts successfully
Change-Id: Iebe881bce2109c4cb8986e29499d49a2d1fde18c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/1837164
Reviewed-by: Yong Hong <yhong@chromium.org>
Commit-Queue: Yilin Yang (kerker) <kerker@chromium.org>
Tested-by: Yilin Yang (kerker) <kerker@chromium.org>
Auto-Submit: Wei-Han Chen <stimim@chromium.org>
diff --git a/py/toolkit/installer.py b/py/toolkit/installer.py
index f39a0c3..02769cd 100755
--- a/py/toolkit/installer.py
+++ b/py/toolkit/installer.py
@@ -26,7 +26,6 @@
from six.moves import input
from six.moves import xrange
-import factory_common # pylint: disable=unused-import
from cros.factory.test.env import paths
from cros.factory.test.test_lists import test_list_common
from cros.factory.tools import install_symlinks
@@ -36,7 +35,8 @@
from cros.factory.utils import sys_utils
-INSTALLER_PATH = 'usr/local/factory/py/toolkit/installer.py'
+PYTHONPATH = 'usr/local/factory/py_pkg'
+INSTALLER_MODULE = 'cros.factory.toolkit.installer'
VERSION_PATH = 'usr/local/factory/TOOLKIT_VERSION'
# Short and sweet help header for the executable generated by makeself.
@@ -361,7 +361,8 @@
# We have to explicitly execute python instead of directly execute
# INSTALLER_PATH because files under INSTALLER_PATH may not be
# executable.
- 'env', 'python2', INSTALLER_PATH, '--in-exe']
+ 'env', 'PYTHONPATH=' + PYTHONPATH,
+ 'python2', '-m', INSTALLER_MODULE, '--in-exe']
Spawn(cmd, check_call=True, log=True)
with file_utils.TempDirectory() as tmp_dir:
version_path = os.path.join(tmp_dir, VERSION_PATH)
@@ -490,8 +491,10 @@
if args.repack:
if args.pack_into is None:
parser.error('Must specify --pack-into when using --repack.')
- Spawn([os.path.join(args.repack, INSTALLER_PATH),
- '--pack-into', args.pack_into], check_call=True, log=True)
+ env = dict(os.environ,
+ PYTHONPATH=os.path.join(args.repack, PYTHONPATH))
+ Spawn(['python2', '-m', INSTALLER_MODULE, '--pack-into', args.pack_into],
+ check_call=True, log=True, env=env)
return
if args.build_info: