mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 13:36:58 +02:00
A modest number of different scripts and files have a usage restricted to build_image. Move those files to build_library, to prevent them accumulating unwanted clients. BUG=chromium-os:17390 TEST=build_image TEST=grep relevant sources for references to all the files Change-Id: I3e9f6447ec34c09ea2d61f29ac343386a1e122b9 Reviewed-on: http://gerrit.chromium.org/gerrit/4762 Reviewed-by: Richard Barnette <jrbarnette@chromium.org> Tested-by: Richard Barnette <jrbarnette@chromium.org>
104 lines
2.8 KiB
Bash
Executable File
104 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright (c) 2011 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_ROOT=$(readlink -f $(dirname "$0")/..)
|
|
. "${SCRIPT_ROOT}/common.sh" || exit 1
|
|
|
|
# We're invoked only by build_image, which runs in the chroot
|
|
assert_inside_chroot
|
|
|
|
# Flags
|
|
DEFINE_string root "" \
|
|
"The root file system to check."
|
|
|
|
# Parse command line
|
|
FLAGS "$@" || exit 1
|
|
eval set -- "${FLAGS_ARGV}"
|
|
|
|
# Die on any errors
|
|
set -e
|
|
|
|
# Check all parts of a pipe
|
|
set -o pipefail
|
|
|
|
ROOT="$FLAGS_root"
|
|
if [[ ! -d "$ROOT" ]]; then
|
|
echo "Error: Root FS does not exist ($ROOT)"
|
|
exit 1
|
|
fi
|
|
|
|
BINARIES="$ROOT/usr/bin/Xorg
|
|
$ROOT/usr/bin/chromeos-wm
|
|
$ROOT/boot/vmlinuz
|
|
$ROOT/sbin/session_manager
|
|
$ROOT/bin/sed
|
|
$ROOT/opt/google/chrome/chrome"
|
|
|
|
EXITCODE=0
|
|
for i in $BINARIES; do
|
|
if ! [[ -f $i ]]; then
|
|
echo test_build_root: Cannot find $i
|
|
EXITCODE=1
|
|
fi
|
|
done
|
|
|
|
# Extract the version number from lines like:
|
|
# kCrosAPIMinVersion = 29,
|
|
# kCrosAPIVersion = 30
|
|
extract_cros_version() {
|
|
NAME="$1"
|
|
FILE="$2"
|
|
VERSION=$(perl -ne "print \$1 if /^\\s*${NAME}\\s*=\\s*(\\d+)/" "$FILE")
|
|
test -z "$VERSION" && die "Failed to get $NAME from $FILE"
|
|
echo $VERSION
|
|
}
|
|
|
|
# Check the libcros version compatibility, like we do in libcros at run time.
|
|
# See also platform/cros/version_check.cc and load.cc.
|
|
check_cros_version() {
|
|
CHROME_CROS="${ROOT}/opt/google/chrome/include/chromeos_cros_api.h"
|
|
SYSTEM_CROS="${ROOT}/usr/include/cros/chromeos_cros_api.h"
|
|
|
|
if [ ! -f "$SYSTEM_CROS" ]; then
|
|
echo "test_build_root: Missing libcros headers."
|
|
return 1
|
|
fi
|
|
|
|
|
|
if [ ! -f "$CHROME_CROS" ]; then
|
|
# For compatiblity with old versions of Chrome which don't install headers
|
|
# and already check the libcros version, skip the check here.
|
|
return 0
|
|
fi
|
|
|
|
# Get the version of libcros in the chromium tree.
|
|
VERSION=$(extract_cros_version kCrosAPIVersion "${CHROME_CROS}")
|
|
|
|
# Get the min version of libcros in the chromium os tree.
|
|
MIN_VERSION=$(extract_cros_version kCrosAPIMinVersion "${SYSTEM_CROS}")
|
|
|
|
# Get the max version of libcros in the chromium os tree.
|
|
MAX_VERSION=$(extract_cros_version kCrosAPIVersion "${SYSTEM_CROS}")
|
|
|
|
if [ "$MIN_VERSION" -gt "$VERSION" ]; then
|
|
echo "test_build_root: System libcros not compatible with Chromium."
|
|
echo "Chromium requires version $VERSION, but system provides $MIN_VERSION"
|
|
echo "or later."
|
|
return 1
|
|
fi
|
|
if [ "$VERSION" -gt "$MAX_VERSION" ]; then
|
|
echo "test_build_root: System libcros not compatible with Chromium headers."
|
|
echo "Chromium requires version $VERSION, but system provides $MAX_VERSION"
|
|
echo "or earlier."
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
check_cros_version || EXITCODE=1
|
|
|
|
exit $EXITCODE
|