mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 22:46:58 +02:00
This change adds support for building the disk layout from a configuration file. It also cleans up much of the image creation code. install_gpt no longer exists, and has been replaced by cgpt.py's write action. This spits out a file that has two functions that can be called to write a partition layout to a disk/file. This gets rid of the gigantic nest of calculations that built the layout previously. All instances of partition/filesystem sizes in build scripts should now be gone in favour of calls to the cgpt.py tool. create_boot_desc has moved inside the base image creation, in an effort to simplify build_image. load_kernel_test is gone since it's apparently not supposed to be called here anyway (asked wfrichar/rspangler about this one). Base image creation now uses files rather than loop devices when building an image. This means we can simply umount them once we're done and not worry about cleaning up the loop device, since it's been done for us. Hash pad calculation has been removed. This is now set manually inside the partition config file. Hybrid MBR creation is gone, since it's now possible to do that in a board specific hook (see overlay-beaglebone/scripts/board_specific_setup.sh). OEM partition now has a filesystem, which is mounted at /usr/share/oem during emerge so that packages can stash files here. root_fs_dir and friends are still globals, but the long-term idea is to make this not the case. BUG=chromium-os:33817 TEST=All types of images and their respective flows (VM, recovery, test, factory etc) Change-Id: I8a596728a4d1845c930e837bea627f5b6a11c098 Reviewed-on: https://gerrit.chromium.org/gerrit/29931 Commit-Ready: Liam McLoughlin <lmcloughlin@chromium.org> Reviewed-by: Liam McLoughlin <lmcloughlin@chromium.org> Tested-by: Liam McLoughlin <lmcloughlin@chromium.org>
38 lines
1.1 KiB
Bash
38 lines
1.1 KiB
Bash
#!/bin/bash
|
|
# 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.
|
|
|
|
# This script is automatically generated by @SCRIPT_GENERATOR@
|
|
# Do not edit!
|
|
|
|
if ! type numsectors &>/dev/null; then
|
|
if [[ -f "/usr/sbin/chromeos-common.sh" ]]; then
|
|
. "/usr/sbin/chromeos-common.sh"
|
|
else
|
|
die "Can't load chromeos-common.sh, dying!"
|
|
fi
|
|
fi
|
|
locate_gpt
|
|
|
|
# Usage: create_image <device> <min_disk_size> <block_size>
|
|
# If <device> is a block device, wipes out the GPT
|
|
# If it's not, it creates a new file of the requested size
|
|
create_image() {
|
|
local dev=$1
|
|
local min_disk_size=$2
|
|
local block_size=$3
|
|
if [[ -b "${dev}" ]]; then
|
|
# Zap any old partitions (otherwise gpt complains).
|
|
dd if=/dev/zero of="${dev}" conv=notrunc bs=512 count=32
|
|
dd if=/dev/zero of="${dev}" conv=notrunc bs=512 \
|
|
seek=$((${min_disk_size} - 1 - 33)) count=33
|
|
else
|
|
if [[ ! -e "${dev}" ]]; then
|
|
dd if=/dev/zero of="${dev}" bs=${block_size} count=1 \
|
|
seek=$((${min_disk_size} - 1))
|
|
fi
|
|
fi
|
|
}
|
|
|