Use extracted partitions for x86_64
extract bios, root, and efi partitions from x86_64 image, and include those in tarball instead of whole disk image. also change the corresponding vm_config.json for the new partition layout.
Bug: 358426674
Change-Id: Ide24b52a23350330f61776642f99c3d3c2c60dd9
Flag: EXEMPT desktop only
Test: sudo ./build.sh -a x86_64
Test: deploy images.tar.gz to brya DUT
Test: Launch terminal app
diff --git a/build/debian/build.sh b/build/debian/build.sh
index 59a98b6..8f232aa 100755
--- a/build/debian/build.sh
+++ b/build/debian/build.sh
@@ -144,7 +144,7 @@
build_ttyd() {
local ttyd_version=1.7.7
local url="https://github.com/tsl0922/ttyd/archive/refs/tags/${ttyd_version}.tar.gz"
- cp -r $(dirname $0)/ttyd ${workdir}/ttyd
+ cp -r "$(dirname "$0")/ttyd" "${workdir}/ttyd"
pushd "${workdir}" > /dev/null
wget "${url}" -O - | tar xz
@@ -152,7 +152,7 @@
pushd "$workdir/ttyd-${ttyd_version}" > /dev/null
bash -c "env BUILD_TARGET=${arch} ./scripts/cross-build.sh"
mkdir -p "${dst}/files/usr/local/bin/ttyd"
- cp /tmp/stage/${arch}-linux-musl/bin/ttyd "${dst}/files/usr/local/bin/ttyd/AVF"
+ cp "/tmp/stage/${arch}-linux-musl/bin/ttyd" "${dst}/files/usr/local/bin/ttyd/AVF"
chmod 777 "${dst}/files/usr/local/bin/ttyd/AVF"
mkdir -p "${dst}/files/usr/share/doc/ttyd"
cp LICENSE "${dst}/files/usr/share/doc/ttyd/copyright"
@@ -161,8 +161,10 @@
}
copy_android_config() {
- local src="$(dirname "$0")/fai_config"
- local dst="${config_space}"
+ local src
+ local dst
+ src="$(dirname "$0")/fai_config"
+ dst="${config_space}"
cp -R "${src}"/* "${dst}"
cp "$(dirname "$0")/image.yaml" "${resources_dir}"
@@ -181,14 +183,21 @@
extract_partitions() {
root_partition_num=1
+ bios_partition_num=14
efi_partition_num=15
loop=$(losetup -f --show --partscan $built_image)
- dd if=${loop}p$root_partition_num of=root_part
- dd if=${loop}p$efi_partition_num of=efi_part
- losetup -d ${loop}
+ dd if="${loop}p$root_partition_num" of=root_part
+ if [[ "$arch" == "x86_64" ]]; then
+ dd if="${loop}p$bios_partition_num" of=bios_part
+ fi
+ dd if="${loop}p$efi_partition_num" of=efi_part
+ losetup -d "${loop}"
sed -i "s/{root_part_guid}/$(sfdisk --part-uuid $built_image $root_partition_num)/g" vm_config.json
+ if [[ "$arch" == "x86_64" ]]; then
+ sed -i "s/{bios_part_guid}/$(sfdisk --part-uuid $built_image $bios_partition_num)/g" vm_config.json
+ fi
sed -i "s/{efi_part_guid}/$(sfdisk --part-uuid $built_image $efi_partition_num)/g" vm_config.json
}
@@ -217,27 +226,28 @@
fdisk -l "${built_image}"
images=()
-cp $(dirname $0)/vm_config.json.${arch} vm_config.json
+cp "$(dirname "$0")/vm_config.json.${arch}" vm_config.json
+
+extract_partitions
if [[ "$arch" == "aarch64" ]]; then
- extract_partitions
images+=(
root_part
efi_part
)
-fi
-
# TODO(b/365955006): remove these lines when uboot supports x86_64 EFI application
-if [[ "$arch" == "x86_64" ]]; then
+elif [[ "$arch" == "x86_64" ]]; then
virt-get-kernel -a "${built_image}"
mv vmlinuz* vmlinuz
mv initrd.img* initrd.img
images+=(
- "${built_image}"
+ boot_part
+ root_part
+ efi_part
vmlinuz
initrd.img
)
fi
# --sparse option isn't supported in apache-commons-compress
-tar czv -f images.tar.gz ${images[@]} vm_config.json
+tar czv -f images.tar.gz "${images[@]}" vm_config.json