mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 21:46:58 +02:00
Currently, the scripts in src/scripts have multiple implementations for handling when common.sh fails to load, some of which are buggy. To simplify the boilerplate, these scripts now just exit if common.sh fails to load. The shell itself will print the following message if common.sh is not found: /usr/lib/crosutils/common.sh: No such file or directory BUG=chromium-os:32442 TEST=Run these scripts with and without common.sh installed. Change-Id: Ie54420b6c649774f9cb039c14c80f4cf6c6ebc07 Reviewed-on: https://gerrit.chromium.org/gerrit/27058 Reviewed-by: David James <davidjames@chromium.org> Tested-by: David James <davidjames@chromium.org> Commit-Ready: David James <davidjames@chromium.org>
105 lines
2.8 KiB
Bash
Executable File
105 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 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.
|
|
|
|
# Script to take an archived build result and prepare a hwqual release.
|
|
|
|
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
|
|
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
|
|
|
# Flags
|
|
DEFINE_string from "" "Directory with build archive (zipname)"
|
|
DEFINE_string to "" "Directory to receive packaged hwqual"
|
|
DEFINE_string zipname "image.zip" "Name of zip file to create."
|
|
DEFINE_string output_tag "chromeos-hwqual" "Name used in tar"
|
|
|
|
TMP=$(mktemp -d "/tmp/image.XXXX")
|
|
|
|
cleanup() {
|
|
rm -rf "${TMP}"
|
|
}
|
|
|
|
main() {
|
|
assert_outside_chroot
|
|
assert_not_root_user
|
|
|
|
# Parse command line
|
|
FLAGS "$@" || exit 1
|
|
eval set -- "${FLAGS_ARGV}"
|
|
switch_to_strict_mode
|
|
|
|
if [[ -z "${FLAGS_from}" ]]; then
|
|
echo "Please specify --from directory"
|
|
exit 1
|
|
fi
|
|
|
|
FLAGS_from=$(readlink -f "${FLAGS_from}")
|
|
|
|
if [[ -z "${FLAGS_to}" ]]; then
|
|
FLAGS_to="${FLAGS_from}"
|
|
fi
|
|
|
|
local script_dir=${SCRIPTS_DIR}
|
|
|
|
script_dir=$(readlink -f "${script_dir}")
|
|
|
|
trap cleanup EXIT
|
|
|
|
cd "${TMP}"
|
|
|
|
echo "Extracting build artifacts..."
|
|
unzip "${FLAGS_from}/${FLAGS_zipname}"
|
|
mkdir -p image
|
|
mkdir -p "tarball/${FLAGS_output_tag}"
|
|
|
|
if which pbzip2 >/dev/null 2>/dev/null; then
|
|
TAR_BZIP2="tar --use-compress-program=pbzip2"
|
|
else
|
|
TAR_BZIP2="tar --bzip2"
|
|
fi
|
|
|
|
echo "Extracting autotest from build artifacts..."
|
|
${TAR_BZIP2} -xf autotest.tar.bz2
|
|
|
|
cd "${TMP}"
|
|
|
|
mv chromiumos_test_image.bin image/chromiumos_image.bin
|
|
|
|
echo "Formatting rootfs as a USB image..."
|
|
"${script_dir}/image_to_usb.sh" --from=image \
|
|
--to="tarball/${FLAGS_output_tag}/chromeos-hwqual-usb.img"
|
|
|
|
echo "Inserting documentation and autotest to tarball..."
|
|
ln -s \
|
|
"${FLAGS_output_tag}/autotest/client/site_tests/suite_HWQual/README.txt" \
|
|
tarball
|
|
ln -s autotest/client/site_tests/suite_HWQual/manual \
|
|
"tarball/${FLAGS_output_tag}"
|
|
cp "${script_dir}/mod_for_test_scripts/ssh_keys/testing_rsa" \
|
|
"tarball/${FLAGS_output_tag}"
|
|
chmod 0400 "tarball/${FLAGS_output_tag}/testing_rsa"
|
|
mv autotest "tarball/${FLAGS_output_tag}"
|
|
# Copy call_autoserv.py to tarball.
|
|
cp "${script_dir}/call_autoserv.py" "tarball/${FLAGS_output_tag}/."
|
|
cp "${script_dir}/generate_test_report" \
|
|
"tarball/${FLAGS_output_tag}/generate_test_report"
|
|
# Copy python lib used in generate_test_report.
|
|
mkdir -p "tarball/${FLAGS_output_tag}/lib"
|
|
cp "${script_dir}/lib/cros_build_lib.py" \
|
|
"tarball/${FLAGS_output_tag}/lib"
|
|
echo "Creating ${FLAGS_to}/${FLAGS_output_tag}.tar.bz2..."
|
|
mkdir -p "${FLAGS_to}"
|
|
cd tarball
|
|
${TAR_BZIP2} -cf "${FLAGS_to}/${FLAGS_output_tag}.tar.bz2" .
|
|
|
|
trap - EXIT
|
|
cleanup
|
|
|
|
echo "Done."
|
|
cd "${script_dir}"
|
|
}
|
|
|
|
main "$@"
|