mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-10 06:26:57 +02:00
from within the chroot. It also fixes a number of style issues. It changes the meaning of cros_workon "list-all" to list all available packages, and adds "list-live" to list all live packages. It changes things that load chromeos-common.sh from the installer to load it from /usr/lib/installer. BUG=chromium-os:4230 TEST=synced, rebuilt chroot, made packages, made images, built chrome from source, and wrote an image to a USB stick. Review URL: http://codereview.chromium.org/6240018 Change-Id: I90c34420af1a64020402bafef8e9e77f56837c02
76 lines
1.7 KiB
Bash
Executable File
76 lines
1.7 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.
|
|
|
|
# Usage:
|
|
# update_image.sh [image_to_update] [packages...]
|
|
usage()
|
|
{
|
|
cat <<EOF
|
|
|
|
usage:
|
|
update_image.sh [image_to_update] [packages...]
|
|
EOF
|
|
}
|
|
|
|
if [[ $# < 2 ]]; then
|
|
echo "Not enough arguments supplied."
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -f /home/${USER}/trunk/src/scripts/.default_board ]]; then
|
|
BOARD=$( cat /home/${USER}/trunk/src/scripts/.default_board )
|
|
else
|
|
BOARD=st1q
|
|
fi
|
|
|
|
IMAGE=$( readlink -f ${1} )
|
|
IMAGE_DIR=$( dirname "${IMAGE}" )
|
|
shift
|
|
PKGS=$@
|
|
|
|
if [[ -z "${IMAGE}" || ! -f ${IMAGE} ]]; then
|
|
echo "Missing required argument 'image_to_update'"
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
cd ${IMAGE_DIR}
|
|
if ! [[ -x ./unpack_partitions.sh && -x ./pack_partitions.sh ]]; then
|
|
echo "Could not find image manipulation scripts."
|
|
exit 1
|
|
fi
|
|
|
|
./unpack_partitions.sh ${IMAGE}
|
|
mkdir -p ./rootfs
|
|
mkdir -p ./stateful_part
|
|
mkdir -p ./orig_partitions
|
|
|
|
rm -rf ./orig_partitions/*
|
|
cp ./part_* ./orig_partitions
|
|
sudo mount -o loop part_3 rootfs
|
|
sudo mount -o loop part_1 stateful_part
|
|
sudo mount --bind stateful_part/dev_image rootfs/usr/local
|
|
sudo mount --bind stateful_part/var rootfs/var
|
|
|
|
emerge-${BOARD} --root="./rootfs" \
|
|
--root-deps=rdeps --nodeps --usepkgonly ${PKGS}
|
|
|
|
#if the kernel is one of the packages that got updated
|
|
#we need to update the kernel partition as well.
|
|
if [[ ${PKGS/kernel/} != ${PKGS} ]]; then
|
|
rm -rf part_2
|
|
sudo dd if="/dev/zero" of=part_2 bs=512 count=8192
|
|
sudo dd if="./rootfs/boot/vmlinuz" of=part_2 bs=512 count=8192 conv=notrunc
|
|
fi
|
|
|
|
sudo umount rootfs/usr/local
|
|
sudo umount rootfs/var
|
|
sudo umount rootfs
|
|
sudo umount stateful_part
|
|
./pack_partitions.sh ${IMAGE}
|
|
|
|
cd -
|