if [ -d "$TMPDIR" ]; then
rm -rf "$TMPDIR" || error "Failed to remove $TMPDIR"
fi
- [ -f "$TMP_DIR/TMP-AGL-wic-image.wic" ] || rm -f $TMP_DIR/TMP-AGL-wic-image.wic
+ [ -f "$TMP_DIR/TMP-AGL-wic-image.wic" ] && rm -f $TMP_DIR/TMP-AGL-wic-image.wic
}
trap 'die "Signal Received, Aborting..."' HUP INT TERM
# MMC devices use a partition prefix character 'p'
PART_PREFIX=""
-if [ ! "${DEVICE#/dev/mmcblk}" = "${DEVICE}" ] || [ ! "${DEVICE#/dev/loop}" = "${DEVICE}" ]; then
+if [ ! "${DEVICE#/dev/mmcblk}" = "${DEVICE}" ] || [ ! "${DEVICE#/dev/nvme0n}" = "${DEVICE}" ] || [ ! "${DEVICE#/dev/loop}" = "${DEVICE}" ]; then
PART_PREFIX="p"
fi
BOOTFS=$DEVICE${PART_PREFIX}1
ROOTFS=$DEVICE${PART_PREFIX}2
TARGET_PART_PREFIX=""
-if [ ! "${TARGET_DEVICE#/dev/mmcblk}" = "${TARGET_DEVICE}" ]; then
+if [ ! "${TARGET_DEVICE#/dev/mmcblk}" = "${TARGET_DEVICE}" ] || [ ! "${TARGET_DEVICE#/dev/nvme0n}" = "${TARGET_DEVICE}" ]; then
TARGET_PART_PREFIX="p"
fi
TARGET_ROOTFS=$TARGET_DEVICE${TARGET_PART_PREFIX}2
if [ $ROOTFS_DISKID = "" ]; then
die "Failed to read DISKID"
fi
+BOOTFS_PARTUUID="$ROOTFS_DISKID-01"
ROOTFS_PARTUUID="$ROOTFS_DISKID-02"
debug "PARTUUID for ROOTFS is $ROOTFS_PARTUUID"
debug "kernel is vmlinuz"
fi
if [ -f $HDDIMG_MNT/bzimage ]; then
- cp $HDDIMG_MNT/bzimage $BOOTFS_MNT 1>&3 2>&1 || die "Failed to copy vmlinuz"
+ cp $HDDIMG_MNT/bzimage $BOOTFS_MNT 1>&3 2>&1 || die "Failed to copy bzimage"
KERNEL_TYPE="BZIMAGE"
debug "kernel is bzimage"
fi
+if [ -f $HDDIMG_MNT/microcode.cpio ]; then
+ cp $HDDIMG_MNT/microcode.cpio $BOOTFS_MNT 1>&3 2>&1 || die "Failed to copy microcode.cpio"
+ debug "microcode.cpio copied"
+fi
[ -z $KERNEL_TYPE ] && die "Linux kernel type in $HDDIMG is unsupported"
if [ -f $HDDIMG_MNT/initrd ]
fi
debug "removing any swap entry in /etc/fstab"
sed --in-place '/swap/d' $ROOTFS_MNT/etc/fstab
+debug "fixing PARTUUID for /boot"
+sed --in-place -e "s#PARTUUID=[0-9a-z-]\+\t/boot#${BOOTFS_PARTUUID}\t/boot#" $ROOTFS_MNT/etc/fstab
printf "flushing data on removable device. May take a while ... "
sync --file-system $ROOTFS_MNT