crosutils/make_factory_package.sh: support full SSD image as target outside chroot

When running outside chroot, we should use locate_cgpt + "$GPT" to invoke cgpt;
otherwise it may be not in system PATH.

For dealing with a true SSD image (over USB, for example) this CL also improved
data writing speed from <2M/s to 8M/s+ (over USB).

BUG=chromium-os:10531
TEST=./make_factory_package.sh \
  --factory=../build/images/x86-mario/latest/chromiumos_factory_image.bin \
  --release=../build/images/x86-mario/latest//chromiumos_image.bin \
  --diskimg=/dev/sdb

Also tested:
  --diskimg=blah # local file
  (chroot) --diskimg=/dev/sdd
  (chroot) --diskimg=blah

Change-Id: I647d97fe388f5b6a6223fa8cacfecdf00265f60c

Review URL: http://codereview.chromium.org/6261003
This commit is contained in:
Hung-Te Lin 2011-01-13 16:59:42 +08:00
parent c584cf0e95
commit 4653cbd0e5
2 changed files with 13 additions and 2 deletions

View File

@ -185,6 +185,16 @@ image_partition_copy() {
exit 1
fi
# Try to use larger buffer if offset/size can be re-aligned.
# 2M / 512 = 4096
local buffer_ratio=4096
local bs=512
if [ $((dstoffset % buffer_ratio)) -eq 0 -a \
$((length % buffer_ratio)) -eq 0 ]; then
dstoffset=$((dstoffset / buffer_ratio))
bs=$((bs * buffer_ratio))
fi
image_dump_partition "${src}" "${srcpart}" |
dd of="${dst}" bs=512 seek="${dstoffset}" conv=notrunc
dd of="${dst}" bs="${bs}" seek="${dstoffset}" conv=notrunc oflag=dsync
}

View File

@ -110,9 +110,10 @@ prepare_img() {
fi
# Create GPT partition table.
locate_gpt
install_gpt "${outdev}" 0 0 "${pmbrcode}" 0 "${force_full}"
# Activate the correct partition.
cgpt add -i 2 -S 1 -P 1 "${outdev}"
sudo "${GPT}" add -i 2 -S 1 -P 1 "${outdev}"
}
prepare_omaha() {