Deprecate factory related scripts.
With recent changes the factory build process is now all done in package
"emerge chromeos-factory". We don't need further post-processing by
calling make_factory_toolkit.
make_factory_package and serve_factory_package should always run from
factory/setup (or from the factory.zip), especially now we are migrating
to Umpire server. It should be safe to remove these symlink and
deprecated commands now.
BUG=chromium:577601
TEST=./make_factory_toolkit.sh
Change-Id: I872973f7bf9aa24eb5fb432148014d6b02f775a6
Reviewed-on: https://chromium-review.googlesource.com/397084
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
diff --git a/make_factory_package.sh b/make_factory_package.sh
deleted file mode 120000
index 6cdb3d5..0000000
--- a/make_factory_package.sh
+++ /dev/null
@@ -1 +0,0 @@
-../platform/factory/setup/make_factory_package.sh
\ No newline at end of file
diff --git a/make_factory_toolkit.sh b/make_factory_toolkit.sh
index 5fafd3b..df027c8 100755
--- a/make_factory_toolkit.sh
+++ b/make_factory_toolkit.sh
@@ -3,106 +3,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# make_factory_toolkit.sh --board=[board]
-#
-# This script builds a factory toolkit, which is a self-extracting shellball,
-# and can be installed onto a device running test image.
+echo 'This script is deprecated and will be removed soon.'
+echo 'To get toolkit, run "emerge-$BOARD chromeos-factory"'
+echo ' or "cd ../platform/factory; make toolkit BOARD=$BOARD".'
+echo 'Read go/cros-factory-make for more details.'
-SCRIPT_ROOT=$(dirname "$(readlink -f "$0")")
-. "${SCRIPT_ROOT}/common.sh" || exit 1
-
-# Script must be run inside the chroot.
-restart_in_chroot_if_needed "$@"
-
-DEFINE_string board "${DEFAULT_BOARD}" \
- "The board to build a factory toolkit for."
-DEFINE_string output_dir "" "Path to the folder to store the factory toolkit."
-DEFINE_string version "" \
- "The version tag to be included in the identification string."
-
-cleanup() {
- sudo rm -rf "${temp_pack_root}"
-}
-
-main() {
- # Parse command line.
- FLAGS "$@" || exit 1
- eval set -- "${FLAGS_ARGV}"
-
- switch_to_strict_mode
-
- trap cleanup EXIT
-
- # Must specify a board
- if [[ -z "${FLAGS_board}" ]]; then
- die "No board specified. Use the --board option."
- fi
-
- local default_dir="${CHROOT_TRUNK_DIR}/src/build/images/${FLAGS_board}/latest"
- if [[ -n "${FLAGS_output_dir}" ]]; then
- local output_dir="${FLAGS_output_dir}"
- else
- local output_dir="${default_dir}"
- fi
-
- echo "Building into directory ${output_dir}"
- if [[ ! -d "${output_dir}" ]]; then
- die \
- "Output directory '${output_dir}' does not exist." \
- "Check the --board or --output_dir options and that the image is built."
- fi
- cd "${output_dir}"
-
- temp_pack_root="$(mktemp -d toolkit_XXXXXX)"
- if [[ ! -d "${temp_pack_root}" ]]; then
- die "Failed to create temporary directory."
- fi
-
- export INSTALL_MASK="${FACTORY_TEST_INSTALL_MASK}"
- emerge-${FLAGS_board} --root="${temp_pack_root}" --nodeps --usepkgonly -v \
- chromeos-factory chromeos-factory-board autotest-factory-install \
- memento_softwareupdate
-
- sudo USE="static" INSTALL_MASK="/usr/bin/ghost" \
- emerge --root="${temp_pack_root}" --nodeps -v chromeos-factory-overlord
-
- # /var/cache is not part of installed files but generated by emerge itself.
- # Since chromeos-factory-overlord is emerge with root permission, we need
- # to remove this to avoid error.
- sudo rm -rf "${temp_pack_root}"/var/cache
-
- local factory_repo="${CHROOT_TRUNK_DIR}/src/platform/factory"
- local repo_status_script="${factory_repo}/py/toolkit/print_repo_status.py"
- if [[ -x "${repo_status_script}" ]]; then
- "${repo_status_script}" -b "${FLAGS_board}" >"${temp_pack_root}/REPO_STATUS"
- fi
-
- # Include 'makeself' in the toolkit
- local makeself_path="$(readlink -f $(which makeself))"
- local makeself_header_path="$(dirname "${makeself_path}")/makeself-header.sh"
- cp -L "${makeself_path}" "${makeself_header_path}" "${temp_pack_root}"
-
- # Include a VERSION tag in the toolkit
- if [[ -n "${FLAGS_version}" ]]; then
- local id_str="${FLAGS_board} Factory Toolkit ${FLAGS_version}"
- else
- local timestamp="$(date "+%Y-%m-%dT%H:%M:%S")"
- local builder="$(whoami)@$(hostname)"
- local id_str="${FLAGS_board} Factory Toolkit ${timestamp} ${builder}"
- fi
-
- # create factory-mini.par
- local temp_factory_root="$(readlink -f "${temp_pack_root}")/usr/local/factory"
- sudo "${temp_factory_root}/bin/make_par" --output \
- "${temp_factory_root}/factory.par"
-
- local version_tag="usr/local/factory/TOOLKIT_VERSION"
- echo "${id_str}" | sudo_clobber "${temp_pack_root}/${version_tag}"
- ln -s "${version_tag}" "${temp_pack_root}/VERSION"
-
- local output_toolkit="${output_dir}/install_factory_toolkit.run"
- "${temp_pack_root}/usr/local/factory/py/toolkit/installer.py" \
- --pack-into "${output_toolkit}"
-}
-
-main "$@"
diff --git a/serve_factory_packages.py b/serve_factory_packages.py
deleted file mode 100644
index 158ccec..0000000
--- a/serve_factory_packages.py
+++ /dev/null
@@ -1,182 +0,0 @@
-#!/usr/bin/python
-# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""
-This script runs inside chroot environment. It signs and build factory packages.
-Then serves them using devserver. All paths should be specified relative to the
-chroot environment.
-
-E.g.: cros_sdk -- serve_factory_packages.py --board <board>
-
-Always precede the call to the script with 'cros_sdk -- ".
-"""
-
-import gflags
-import os
-import shlex
-import signal
-import subprocess
-import sys
-
-
-CWD = os.getcwd()
-USER = os.environ['USER']
-HOME_DIR = '/home/%s/trunk/src' % USER
-SCRIPTS_DIR = HOME_DIR + '/scripts'
-DEVSERVER_DIR = HOME_DIR + '/platform/dev'
-
-# Paths to image signing directory and dev key.
-VBOOT_REF_DIR = HOME_DIR + '/platform/vboot_reference'
-IMG_SIGN_DIR = VBOOT_REF_DIR + '/scripts/image_signing'
-DEVKEYS = VBOOT_REF_DIR + '/tests/devkeys'
-
-FLAGS = gflags.FLAGS
-
-gflags.DEFINE_string('board', None, 'Platform to build.')
-gflags.DEFINE_string('base_image', None, 'Path to base image.')
-gflags.DEFINE_string('firmware_updater', None, 'Path to firmware updater.')
-gflags.DEFINE_boolean('start_devserver', False, 'Start devserver.')
-
-class KillableProcess():
- """A killable process.
- """
-
- running_process = None
-
- def __init__(self, cmd, timeout=60, cwd=CWD):
- """Initialize process
-
- Args:
- cmd: command to run.
- """
- self.cmd = shlex.split(cmd)
- self.cmd_timeout = timeout
- self.cmd_cwd = cwd
-
- def start(self, wait=True):
- """Start the process.
-
- Args:
- wait: wait for command to complete.
- """
- self.running_process = subprocess.Popen(self.cmd,
- cwd=self.cmd_cwd)
- if wait:
- self.running_process.wait()
-
- def stop(self):
- """Stop the process.
-
- This will only work for commands that do not exit.
- """
- self.running_process.send_signal(signal.SIGINT)
- self.running_process.wait()
-
-
-def start_devserver():
- """Starts devserver."""
- cmd = 'python devserver.py --factory_config miniomaha.conf'
- print 'Running command: %s' % cmd
- devserver_process = KillableProcess(cmd, cwd=DEVSERVER_DIR)
- devserver_process.start(wait=False)
-
-
-def assert_is_file(path, message):
- """Assert file exists.
-
- Args:
- path: path to file.
- message: message to print if file does not exist.
- """
- if not os.path.isfile(path):
- error_message = '%s: %s is not a file!' % (message, path)
- print error_message
- sys.exit(1)
-
-
-def setup_board(board):
- """Setup the board inside chroot.
- """
- cmd = './setup_board --board %s' % board
- print 'Setting up board: %s' % board
- setup_board_process = KillableProcess(cmd, cwd=SCRIPTS_DIR)
- setup_board_process.start()
-
-
-def sign_build(image, output):
- """Make an SSD signed build.
-
- Args:
- image: image to sign.
- output: destination path for signed image.
- """
- assert_is_file(image, 'Asserting base image exists')
- cmd = ('sudo ./sign_official_build.sh ssd %s %s %s'
- % (image, DEVKEYS, output))
- print 'IMG_SIGN_DIR: %s' % IMG_SIGN_DIR
- print 'Signing image: %s' % cmd
- sign_process = KillableProcess(cmd, cwd=IMG_SIGN_DIR)
- sign_process.start()
-
-
-def build_factory_packages(signed_image, base_image, fw_updater, folder, board):
- """Build factory packages and modify mini omaha config.
-
- Args:
- signed_image: signed image
- base_image: base image
- fw_updater: firmware updater
- folder: destination folder to write packages
- board: platform to build
- """
- cmd = ('./make_factory_package.sh --release %s --factory %s'
- ' --subfolder %s --board %s'
- % (signed_image, base_image, folder, board))
- if fw_updater:
- cmd = '%s --firmware_updater %s' % (cmd, fw_updater)
- else:
- print ('No --firmware_updater specified. Not including firmware shellball.')
-
- print 'Building factory packages: %s' % cmd
- build_packages_process = KillableProcess(cmd, cwd=SCRIPTS_DIR)
- build_packages_process.start()
-
-
-def exit(message):
- print message
- sys.exit(1)
-
-
-def main(argv):
- try:
- argv = FLAGS(argv)
- except gflags.FlagsError, e:
- print '%s\nUsage: %s ARGS\n%s' % (e, sys.argv[0], FLAGS)
- sys.exit(1)
-
- if not FLAGS.base_image:
- exit('No --base_image specified.')
-
- if FLAGS.firmware_updater:
- assert_is_file(FLAGS.firmware_updater,
- 'Invalid or missing firmware updater.')
-
- assert_is_file(FLAGS.base_image, 'Invalid or missing base image.')
-
- signed_image = os.path.join(os.path.dirname(FLAGS.base_image),
- '%s_ssd_signed.bin' % FLAGS.board)
-
- setup_board(FLAGS.board)
- sign_build(FLAGS.base_image, signed_image)
- build_factory_packages(signed_image, FLAGS.base_image,
- FLAGS.firmware_updater,
- folder=FLAGS.board, board=FLAGS.board)
-
- if FLAGS.start_devserver:
- start_devserver()
-
-
-if __name__ == '__main__':
- main(sys.argv)