Code Review
/
AGL
/
meta-agl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Enable agl-sota for h3ulcb
[AGL/meta-agl.git]
/
scripts
/
mkefi-agl.sh
diff --git
a/scripts/mkefi-agl.sh
b/scripts/mkefi-agl.sh
index
e3240a6
..
c44eced
100755
(executable)
--- a/
scripts/mkefi-agl.sh
+++ b/
scripts/mkefi-agl.sh
@@
-25,7
+25,7
@@
# - keep initrd if present
# - create a grub config with PARTUID to ease boot from various devices automaticaly
# - add a UEFI startup.nsh script for autoboot
# - keep initrd if present
# - create a grub config with PARTUID to ease boot from various devices automaticaly
# - add a UEFI startup.nsh script for autoboot
-# -
does not allocate swap
+# -
remove any configured swap is fstab
# - accept .hddimg, wic and wic.xz as sources
LANG=C
# - accept .hddimg, wic and wic.xz as sources
LANG=C
@@
-64,7
+64,7
@@
cleanup() {
if [ -d "$TMPDIR" ]; then
rm -rf "$TMPDIR" || error "Failed to remove $TMPDIR"
fi
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
}
trap 'die "Signal Received, Aborting..."' HUP INT TERM
@@
-307,14
+307,14
@@
ROOTFS_END=$((ROOTFS_START+ROOTFS_SIZE))
# MMC devices use a partition prefix character 'p'
PART_PREFIX=""
# 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=""
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
TARGET_PART_PREFIX="p"
fi
TARGET_ROOTFS=$TARGET_DEVICE${TARGET_PART_PREFIX}2
@@
-352,6
+352,7
@@
ROOTFS_DISKID=$(fdisk -l "$DEVICE" | grep -e "Disk identifier" | sed -n 's/^.*Di
if [ $ROOTFS_DISKID = "" ]; then
die "Failed to read DISKID"
fi
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"
ROOTFS_PARTUUID="$ROOTFS_DISKID-02"
debug "PARTUUID for ROOTFS is $ROOTFS_PARTUUID"
@@
-415,10
+416,14
@@
if [ -f $HDDIMG_MNT/vmlinuz ]; then
debug "kernel is vmlinuz"
fi
if [ -f $HDDIMG_MNT/bzimage ]; then
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
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 ]
[ -z $KERNEL_TYPE ] && die "Linux kernel type in $HDDIMG is unsupported"
if [ -f $HDDIMG_MNT/initrd ]
@@
-450,7
+455,10
@@
if [ -e "$GRUB_CFG" ]; then
sed -i "/menuentry 'install'/,/^}/d" $GRUB_CFG
# Delete any LABEL= strings
sed -i "s/ LABEL=[^ ]*/ /" $GRUB_CFG
sed -i "/menuentry 'install'/,/^}/d" $GRUB_CFG
# Delete any LABEL= strings
sed -i "s/ LABEL=[^ ]*/ /" $GRUB_CFG
-
+ # detect config initrd=microcode.cpio
+ if grep -q microcode $GRUB_CFG; then
+ warn "initrd=microcode.cpio detected, might not work on all boot configurations"
+ fi
sed -i "s@ root=[^ ]*@ @" $GRUB_CFG
sed -i "s@vmlinuz @vmlinuz root=$ROOTFS_PARTUUID @" $GRUB_CFG
fi
sed -i "s@ root=[^ ]*@ @" $GRUB_CFG
sed -i "s@vmlinuz @vmlinuz root=$ROOTFS_PARTUUID @" $GRUB_CFG
fi
@@
-470,7
+478,10
@@
if [ -e "$SYSTEMDBOOT_CFG" ]; then
fi
# Delete any LABEL= strings
sed -i "s/ LABEL=[^ ]*/ /" $SYSTEMDBOOT_BOOT
fi
# Delete any LABEL= strings
sed -i "s/ LABEL=[^ ]*/ /" $SYSTEMDBOOT_BOOT
-
+ # detect config initrd=microcode.cpio
+ if grep -q microcode $SYSTEMDBOOT_BOOT; then
+ warn "initrd=microcode.cpio detected, might not work on all boot configurations"
+ fi
sed -i "s@ root=[^ ]*@ @" $SYSTEMDBOOT_BOOT
sed -i "s@options @options root=$ROOTFS_PARTUUID @" $SYSTEMDBOOT_BOOT
fi
sed -i "s@ root=[^ ]*@ @" $SYSTEMDBOOT_BOOT
sed -i "s@options @options root=$ROOTFS_PARTUUID @" $SYSTEMDBOOT_BOOT
fi
@@
-488,6
+499,10
@@
if [ $DEBUG -eq 1 ] && [ $? -eq 0 ]; then
else
cp -a $HDDIMG_ROOTFS_MNT/* $ROOTFS_MNT 1>&3 2>&1 || die "Root FS copy failed"
fi
else
cp -a $HDDIMG_ROOTFS_MNT/* $ROOTFS_MNT 1>&3 2>&1 || die "Root FS copy failed"
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
printf "flushing data on removable device. May take a while ... "
sync --file-system $ROOTFS_MNT