mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-08 05:26:58 +02:00
As outlined here we need a new partition layout, this patch makes the necessary changes: https://groups.google.com/forum/#!topic/coreos-dev/bA7gwGGoTng The first big change is making all of the scripts obey partition numbers based on labels in the disk_layout.json. This makes it much easier to change later on. The second big change is in the layout itself. The json file was updated to reflect the document above. And finally the grub boot configuration needed for pv-grub and pygrub were added to the create_legacy_bootloader_templates.sh library utlity. Everything seems to work and boot now.
103 lines
3.7 KiB
Bash
Executable File
103 lines
3.7 KiB
Bash
Executable File
# Copyright (c) 2012 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.
|
|
|
|
# Shell function library for functions specific to creating dev
|
|
# images from base images. The main function for export in this
|
|
# library is 'install_dev_packages'.
|
|
|
|
|
|
# Modifies an existing image to add development packages.
|
|
# Takes as an arg the name of the image to be created.
|
|
install_dev_packages() {
|
|
local image_name=$1
|
|
|
|
info "Adding developer packages to ${image_name}"
|
|
|
|
trap "unmount_image ; delete_prompt" EXIT
|
|
|
|
mount_image "${BUILD_DIR}/${image_name}" "${root_fs_dir}" \
|
|
"${stateful_fs_dir}" "${esp_fs_dir}"
|
|
|
|
# Determine the root dir for developer packages.
|
|
local root_dev_dir="${root_fs_dir}/usr/local"
|
|
|
|
# Install developer packages described in chromeos-dev.
|
|
emerge_to_image --root="${root_dev_dir}" coreos-base/coreos-dev
|
|
|
|
# Copy over the libc debug info so that gdb
|
|
# works with threads and also for a better debugging experience.
|
|
sudo mkdir -p "${root_fs_dir}/usr/local/usr/lib/debug"
|
|
pbzip2 -dc --ignore-trailing-garbage=1 "${LIBC_PATH}" | \
|
|
sudo tar xpf - -C "${root_fs_dir}/usr/local/usr/lib/debug" \
|
|
./usr/lib/debug/usr/${CHOST} --strip-components=6
|
|
# Since gdb only looks in /usr/lib/debug, symlink the /usr/local
|
|
# path so that it is found automatically.
|
|
sudo ln -s /usr/local/usr/lib/debug "${root_fs_dir}/usr/lib/debug"
|
|
|
|
# Install the bare necessary files so that the "emerge" command works
|
|
sudo sed -i s,/usr/bin/wget,wget, \
|
|
${root_fs_dir}/usr/share/portage/config/make.globals
|
|
|
|
sudo mkdir -p ${root_fs_dir}/etc/make.profile
|
|
|
|
# Re-run ldconfig to fix /etc/ldconfig.so.cache.
|
|
sudo /sbin/ldconfig -r "${root_fs_dir}"
|
|
|
|
# Mark the image as a developer image (input to chromeos_startup).
|
|
# TODO(arkaitzr): Remove this file when applications no longer rely on it
|
|
# (crosbug.com/16648). The preferred way of determining developer mode status
|
|
# is via crossystem cros_debug?1 (checks boot args for "cros_debug").
|
|
sudo mkdir -p "${root_fs_dir}/root"
|
|
sudo touch "${root_fs_dir}/root/.dev_mode"
|
|
|
|
# Additional changes to developer image.
|
|
|
|
# Leave core files for developers to inspect.
|
|
sudo touch "${root_fs_dir}/root/.leave_core"
|
|
|
|
# This hack is only needed for devs who have old versions of glibc, which
|
|
# filtered out ldd when cross-compiling. TODO(davidjames): Remove this hack
|
|
# once everybody has upgraded to a new version of glibc.
|
|
if [[ ! -x "${root_fs_dir}/usr/bin/ldd" ]]; then
|
|
sudo cp -a "$(which ldd)" "${root_fs_dir}/usr/bin"
|
|
fi
|
|
|
|
# If vim is installed, then a vi symlink would probably help.
|
|
if [[ -x "${root_fs_dir}/usr/local/bin/vim" ]]; then
|
|
sudo ln -sf vim "${root_fs_dir}/usr/local/bin/vi"
|
|
fi
|
|
|
|
# If pygtk is installed in stateful-dev, then install a path.
|
|
if [[ -d \
|
|
"${root_fs_dir}/usr/local/lib/python2.6/site-packages/gtk-2.0" ]]; then
|
|
sudo bash -c "\
|
|
echo gtk-2.0 > \
|
|
${root_fs_dir}/usr/local/lib/python2.6/site-packages/pygtk.pth"
|
|
fi
|
|
|
|
# File searches /usr/share by default, so add a wrapper script so it
|
|
# can find the right path in /usr/local.
|
|
local path="${root_fs_dir}/usr/local/bin/file"
|
|
if [[ -x ${path} ]]; then
|
|
sudo mv "${path}" "${path}.bin"
|
|
sudo_clobber "${path}" <<EOF
|
|
#!/bin/sh
|
|
exec file.bin -m /usr/local/share/misc/magic.mgc "\$@"
|
|
EOF
|
|
sudo chmod a+rx "${path}"
|
|
fi
|
|
|
|
info "Developer image built and stored at ${image_name}"
|
|
|
|
cleanup_mounts
|
|
trap - EXIT
|
|
|
|
if [[ ${skip_kernelblock_install} -ne 1 ]]; then
|
|
if should_build_image ${image_name}; then
|
|
${SCRIPTS_DIR}/bin/cros_make_image_bootable "${BUILD_DIR}" \
|
|
${image_name} --force_developer_mode
|
|
fi
|
|
fi
|
|
}
|