OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 # Script to take an archived build result and prepare a hwqual release. |
| 8 |
| 9 # Load common constants. This should be the first executable line. |
| 10 # The path to common.sh should be relative to your script's location. |
| 11 . "$(dirname "$0")/common.sh" |
| 12 |
| 13 # Flags |
| 14 DEFINE_string from "" "Directory with build archive (zipname)" |
| 15 DEFINE_string to "" "Directory to receive packaged hwqual" |
| 16 DEFINE_string zipname "image.zip" "Name of zip file to create." |
| 17 DEFINE_string output_tag "chromeos-hwqual" "Name used in tar" |
| 18 |
| 19 TMP=$(mktemp -d "/tmp/image.XXXX") |
| 20 |
| 21 function cleanup() { |
| 22 rm -rf "${TMP}" |
| 23 } |
| 24 |
| 25 function main() { |
| 26 assert_outside_chroot |
| 27 assert_not_root_user |
| 28 |
| 29 # Parse command line |
| 30 FLAGS "$@" || exit 1 |
| 31 eval set -- "${FLAGS_ARGV}" |
| 32 set -e |
| 33 |
| 34 if [[ -z "${FLAGS_from}" ]]; then |
| 35 echo "Please specify --from directory" |
| 36 exit 1 |
| 37 fi |
| 38 |
| 39 FLAGS_from=$(readlink -f "${FLAGS_from}") |
| 40 |
| 41 if [[ -z "${FLAGS_to}" ]]; then |
| 42 FLAGS_to="${FLAGS_from}" |
| 43 fi |
| 44 |
| 45 local script_dir=$(dirname "$0") |
| 46 |
| 47 script_dir=$(readlink -f "${script_dir}") |
| 48 |
| 49 trap cleanup EXIT |
| 50 |
| 51 cd "${TMP}" |
| 52 |
| 53 echo "Extracting build artifacts..." |
| 54 unzip "${FLAGS_from}/${FLAGS_zipname}" |
| 55 mkdir -p image |
| 56 mkdir -p "tarball/${FLAGS_output_tag}" |
| 57 |
| 58 echo "Extracting autotest from build artifacts..." |
| 59 tar --bzip2 -xf autotest.tar.bz2 |
| 60 mv rootfs_test.image image/rootfs.image |
| 61 mv mbr.image image |
| 62 |
| 63 echo "Formatting rootfs as a USB image..." |
| 64 "${script_dir}/image_to_usb.sh" --from=image \ |
| 65 --to="tarball/${FLAGS_output_tag}/chromeos-hwqual-usb.img" |
| 66 |
| 67 echo "Inserting documentation and autotest to tarball..." |
| 68 ln -s \ |
| 69 "${FLAGS_output_tag}/autotest/client/site_tests/suite_HWQual/README.txt" \ |
| 70 tarball |
| 71 ln -s autotest/client/site_tests/suite_HWQual/manual \ |
| 72 "tarball/${FLAGS_output_tag}" |
| 73 cp "${script_dir}/mod_for_test_scripts/ssh_keys/testing_rsa" \ |
| 74 "tarball/${FLAGS_output_tag}" |
| 75 chmod 0400 "tarball/${FLAGS_output_tag}/testing_rsa" |
| 76 mv autotest "tarball/${FLAGS_output_tag}" |
| 77 |
| 78 echo "Creating ${FLAGS_to}/${FLAGS_output_tag}.tar.bz2..." |
| 79 mkdir -p "${FLAGS_to}" |
| 80 cd tarball |
| 81 tar --bzip2 -cf "${FLAGS_to}/${FLAGS_output_tag}.tar.bz2" . |
| 82 |
| 83 trap - EXIT |
| 84 cleanup |
| 85 |
| 86 echo "Done." |
| 87 cd "${script_dir}" |
| 88 } |
| 89 |
| 90 main "$@" |
OLD | NEW |