Change mod_for_test_script to make it work with arm os image.

Get rid of chroot inside this script, and not mounting mod_for_test_scripts into rootfs any more.

The reason caused the failure here is once you chroot into the mounted rootfs directory, all binaries were searched inside the rootfs. But all binaries inside the arm rootfs was for arm hardware, so not executable on the host linux machine(intel).

Review URL: http://codereview.chromium.org/845007
This commit is contained in:
Eric Li 2010-03-15 20:35:59 -07:00
parent cbac648820
commit df5bf95764
7 changed files with 19 additions and 31 deletions

View File

@ -10,7 +10,7 @@
# Record the size, but don't overwrite the file as its existence indicates
# that this image is not a production image.
echo "Recording production image size."
FILE="/root/bytes-rootfs-prod"
FILE="${ROOT_FS_DIR}/root/bytes-rootfs-prod"
if [[ ! -f "${FILE}" ]]; then
# This will complain it cannot find a valid mtab so keep it quiet.
df -B1 / 2>/dev/null | tail -1 | awk '{ print $3 }' > "${FILE}"

View File

@ -4,11 +4,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# reset password for root and shared user account.
LOCAL_ACCOUNT="chronos"
echo "Reset password for root."
passwd root < test_account.passwd 2> /dev/null
echo "Reset password for ${LOCAL_ACCOUNT}."
passwd ${LOCAL_ACCOUNT} < test_account.passwd 2> /dev/null
# reset root password to test0000 (4 zeroes).
TEMP_SHADOWFILE=${ROOT_FS_DIR}/etc/newshadow
CRYPTED_PASSWD="$(echo "test0000" | openssl passwd -1 -stdin)"
echo "root:${CRYPTED_PASSWD}:14500:0:::::" > ${TEMP_SHADOWFILE}
echo "chronos:${CRYPTED_PASSWD}:14500:0:99999::::" > ${TEMP_SHADOWFILE}
sed '/^root/ d;/^chronos/ d' ${ROOT_FS_DIR}/etc/shadow >> ${TEMP_SHADOWFILE}
mv -f ${TEMP_SHADOWFILE} ${ROOT_FS_DIR}/etc/shadow

View File

@ -9,8 +9,8 @@
echo "Copying public keys"
KEYS_DIR=ssh_keys
ROOT_AUTHKEYS=/root/.ssh/authorized_keys
mkdir -p /root/.ssh
KEYS_DIR=${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/ssh_keys
mkdir -p ${ROOT_FS_DIR}/root/.ssh
ROOT_AUTHKEYS=${ROOT_FS_DIR}/root/.ssh/authorized_keys
cat ${KEYS_DIR}/*.pub >> ${ROOT_AUTHKEYS}

View File

@ -6,4 +6,5 @@
# enable autox login by disabling remembering of last username
echo "Enabling autologin using autox."
touch "/root/.forget_usernames"
touch "${ROOT_FS_DIR}/root/.forget_usernames"

View File

@ -1,3 +0,0 @@
test0000
test0000

View File

@ -4,9 +4,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
cd `dirname $0`
for SCRIPT in [0-9][0-9][0-9]*[!$~]
for SCRIPT in \
${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/[0-9][0-9][0-9]*[!$~]
do
./${SCRIPT}
${SCRIPT}
done

View File

@ -50,10 +50,6 @@ cleanup_rootfs_mounts() {
echo "Killing process that has open file on our rootfs: $cmdline"
! sudo kill $pid # Preceded by ! to disable ERR trap.
done
if [[ -d "${ROOT_FS_DIR}/modify_scripts" ]]; then
echo "Cleaned up modify_scripts mount"
! sudo umount "${ROOT_FS_DIR}/modify_scripts"
fi
}
cleanup_rootfs_loop() {
@ -100,15 +96,9 @@ else
fi
MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts"
sudo mkdir -p "${ROOT_FS_DIR}/modify_scripts"
sudo mount --bind "${MOD_SCRIPTS_ROOT}" "${ROOT_FS_DIR}/modify_scripts"
# Run test setup script inside chroot jail to modify the image
sudo chroot "${ROOT_FS_DIR}" "/modify_scripts/test_setup.sh"
sudo umount "${ROOT_FS_DIR}/modify_scripts"
sudo rmdir "${ROOT_FS_DIR}/modify_scripts"
sudo GCLIENT_ROOT=${GCLIENT_ROOT} ROOT_FS_DIR=${ROOT_FS_DIR} \
"${MOD_SCRIPTS_ROOT}/test_setup.sh"
cleanup
trap - EXIT