mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-12 15:36:58 +02:00
The problem here is that most were doing their exiting w/in a subshell; exit within a subshell kills the subshell, not the parent. Not all scripts were using set -e (which would pick up the failing subshell); as such just rewriting them to remove the potential via eliminateing the subshelling. Beyond that, removed a couple of custom (working, although non-standard) approaches, and removed a duplicate common.sh sourc'ing w/in mk_memento_images.sh TEST=force 'find_common_sh' to fail, note the scripts fails to exit BUG=none Change-Id: Ia1108a091a6399ad6aedd3cade4a107f4411686c Reviewed-on: http://gerrit.chromium.org/gerrit/3905 Reviewed-by: Brian Harring <ferringb@chromium.org> Tested-by: Brian Harring <ferringb@chromium.org>
117 lines
3.1 KiB
Bash
Executable File
117 lines
3.1 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.
|
|
|
|
# --- BEGIN COMMON.SH BOILERPLATE ---
|
|
# Load common CrOS utilities. Inside the chroot this file is installed in
|
|
# /usr/lib/crosutils. Outside the chroot we find it relative to the script's
|
|
# location.
|
|
find_common_sh() {
|
|
local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")"))
|
|
local path
|
|
|
|
SCRIPT_ROOT=
|
|
for path in "${common_paths[@]}"; do
|
|
if [ -r "${path}/common.sh" ]; then
|
|
SCRIPT_ROOT=${path}
|
|
break
|
|
fi
|
|
done
|
|
}
|
|
|
|
find_common_sh
|
|
. "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; }
|
|
# --- END COMMON.SH BOILERPLATE ---
|
|
|
|
# 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")
|
|
|
|
function cleanup() {
|
|
rm -rf "${TMP}"
|
|
}
|
|
|
|
function main() {
|
|
assert_outside_chroot
|
|
assert_not_root_user
|
|
|
|
# Parse command line
|
|
FLAGS "$@" || exit 1
|
|
eval set -- "${FLAGS_ARGV}"
|
|
set -e
|
|
|
|
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}"
|
|
|
|
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 "$@"
|