1
0
Fork 0

Reformat mkimg.sh and wireless_reprobe.sh with tab indentation

This commit is contained in:
Brendan Szymanski 2026-07-14 20:30:36 -04:00
parent cef9a10c1f
commit 6c2ea1b408
2 changed files with 45 additions and 47 deletions

View file

@ -19,48 +19,46 @@ KERNEL_BUILD_OUT=${ANDROID_PRODUCT_OUT}/obj/KERNEL_OBJ
# Helper: print error and cleanup
exit_with_error() {
echo "ERROR: $*" >&2
cleanup || true
exit 1
echo "ERROR: $*" >&2
cleanup || true
exit 1
}
cleanup() {
if [ -n "${LOOPDEV:-}" ]; then
if sudo kpartx -l "${IMAGE_PATH}" >/dev/null 2>&1; then
sudo kpartx -d "${IMAGE_PATH}" || true
fi
fi
if [ -n "${LOOPDEV:-}" ]; then
if sudo kpartx -l "${IMAGE_PATH}" >/dev/null 2>&1; then
sudo kpartx -d "${IMAGE_PATH}" || true
fi
fi
}
trap cleanup EXIT
: "${TARGET_PRODUCT:?TARGET_PRODUCT environment variable is not set. Run lunch first.}"
: "${ANDROID_PRODUCT_OUT:?ANDROID_PRODUCT_OUT environment variable is not set. Run lunch first.}"
for PART in boot system vendor; do
if [ ! -f "${ANDROID_PRODUCT_OUT}/${PART}.img" ]; then
exit_with_error "Missing partition image: ${ANDROID_PRODUCT_OUT}/${PART}.img — run 'make ${PART}image' first."
fi
if [ ! -f "${ANDROID_PRODUCT_OUT}/${PART}.img" ]; then
exit_with_error "Missing partition image: ${ANDROID_PRODUCT_OUT}/${PART}.img — run 'make ${PART}image' first."
fi
done
UBOOT_BIN=${KERNEL_PATH}/u-boot-rockchip.bin
if [ ! -f "${UBOOT_BIN}" ]; then
exit_with_error "Missing U-Boot: ${UBOOT_BIN}"
exit_with_error "Missing U-Boot: ${UBOOT_BIN}"
fi
LINEAGE_VERSION=$(build/soong/bin/get_build_var LINEAGE_VERSION)
if [ -z "${LINEAGE_VERSION}" ]; then
exit_with_error "LINEAGE_VERSION is empty. Run 'lunch' first and ensure the build environment is configured."
exit_with_error "LINEAGE_VERSION is empty. Run 'lunch' first and ensure the build environment is configured."
fi
IMGSIZE=19456MiB
IMAGE_PATH="${ANDROID_PRODUCT_OUT}/lineage-${LINEAGE_VERSION}.img"
if [ -f "${IMAGE_PATH}" ]; then
echo "Overwriting existing image: ${IMAGE_PATH}"
sudo rm -f "${IMAGE_PATH}"
echo "Overwriting existing image: ${IMAGE_PATH}"
sudo rm -f "${IMAGE_PATH}"
fi
echo "Creating image file ${IMAGE_PATH} (${IMGSIZE})..."
@ -74,8 +72,8 @@ sync
echo "Partitioning image using sfdisk (GPT) with explicit partition NAMES..."
PART_TABLE=$(cat <<EOF
PART_TABLE=$(
cat <<EOF
label: gpt
unit: sectors
@ -108,18 +106,18 @@ echo "${KPARTX_OUT}"
LOOPDEV=$(echo "${KPARTX_OUT}" | awk '/add map/ {dev=$3} END { sub(/p[0-9]+$/, "", dev); print dev }')
if [ -z "${LOOPDEV}" ]; then
exit_with_error "kpartx failed to map partitions or to return a loop device name."
exit_with_error "kpartx failed to map partitions or to return a loop device name."
fi
echo "Mapped image as /dev/mapper/${LOOPDEV}p* (base loop: ${LOOPDEV})"
# Wait for device nodes to appear
sleep 1
if [ ! -b "/dev/mapper/${LOOPDEV}p1" ]; then
echo "Waiting a bit longer for /dev/mapper/${LOOPDEV}p1 to appear..."
sleep 1
echo "Waiting a bit longer for /dev/mapper/${LOOPDEV}p1 to appear..."
sleep 1
fi
if [ ! -b "/dev/mapper/${LOOPDEV}p1" ]; then
exit_with_error "Device mapper nodes not found (e.g. /dev/mapper/${LOOPDEV}p1). Check kpartx output."
exit_with_error "Device mapper nodes not found (e.g. /dev/mapper/${LOOPDEV}p1). Check kpartx output."
fi
# --- Copy images into partitions ---
@ -130,14 +128,14 @@ sudo mkfs.vfat -F 32 -n "boot" "/dev/mapper/${LOOPDEV}p1"
BOOT_MOUNT=$(mktemp -d)
sudo mount "/dev/mapper/${LOOPDEV}p1" "${BOOT_MOUNT}"
if [ -f "${KERNEL_BUILD_OUT}/arch/arm64/boot/Image" ]; then
sudo cp ${KERNEL_BUILD_OUT}/arch/arm64/boot/Image "${BOOT_MOUNT}/"
sudo cp ${KERNEL_BUILD_OUT}/arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-ultra.dtb "${BOOT_MOUNT}/"
sudo cp ${KERNEL_BUILD_OUT}/arch/arm64/boot/Image "${BOOT_MOUNT}/"
sudo cp ${KERNEL_BUILD_OUT}/arch/arm64/boot/dts/rockchip/rk3588-orangepi-5-ultra.dtb "${BOOT_MOUNT}/"
else
sudo cp ${KERNEL_PATH}/Image "${BOOT_MOUNT}/"
sudo cp ${KERNEL_PATH}/rk3588-orangepi-5-ultra.dtb "${BOOT_MOUNT}/"
sudo cp ${KERNEL_PATH}/Image "${BOOT_MOUNT}/"
sudo cp ${KERNEL_PATH}/rk3588-orangepi-5-ultra.dtb "${BOOT_MOUNT}/"
fi
sudo mkdir -p "${BOOT_MOUNT}/extlinux"
sudo tee "${BOOT_MOUNT}/extlinux/extlinux.conf" > /dev/null << 'EXTLINUX_EOF'
sudo tee "${BOOT_MOUNT}/extlinux/extlinux.conf" >/dev/null <<'EXTLINUX_EOF'
label LineageOS Android TV
kernel /Image
fdt /rk3588-orangepi-5-ultra.dtb
@ -170,7 +168,7 @@ set +e
sudo e2label "/dev/mapper/${LOOPDEV}p2" system 2>/dev/null
E2_RC=$?
if [ "${E2_RC}" -ne 0 ]; then
echo "Warning: /dev/mapper/${LOOPDEV}p2 does not appear to be ext4 or e2label failed. Continuing."
echo "Warning: /dev/mapper/${LOOPDEV}p2 does not appear to be ext4 or e2label failed. Continuing."
fi
sudo e2label "/dev/mapper/${LOOPDEV}p3" vendor 2>/dev/null || echo "Warning: e2label on vendor failed (maybe not ext4)."

View file

@ -33,10 +33,10 @@ WIFI_USB_DRIVERS="mt7921u mt76x0u mt76x2u mt7601u rtw88_8822bu rtw88_8822cu \
# may still fail on the first pass, so the second catches its residue.
#---------------------------------------------------------------------
reprobe_usb() {
for intf in /sys/bus/usb/devices/*:*; do
[ -e "$intf/driver" ] && continue
echo "${intf##*/}" > /sys/bus/usb/drivers_probe 2>/dev/null
done
for intf in /sys/bus/usb/devices/*:*; do
[ -e "$intf/driver" ] && continue
echo "${intf##*/}" >/sys/bus/usb/drivers_probe 2>/dev/null
done
}
reprobe_usb
sleep 3
@ -51,16 +51,16 @@ reprobe_usb
# the full init sequence succeed.
#---------------------------------------------------------------------
for drv in $WIFI_USB_DRIVERS; do
drvdir="/sys/bus/usb/drivers/$drv"
[ -d "$drvdir" ] || continue
for dev_path in "$drvdir"/*; do
[ -L "$dev_path" ] || continue
name="${dev_path##*/}"
# Skip the driver's own 'module' symlink and similar metadata
[ "$name" = "module" ] || [ "$name" = "uevent" ] || [ "$name" = "new_id" ] && continue
echo "$name" > "$drvdir/unbind" 2>/dev/null
echo "$name" > /sys/bus/usb/drivers_probe 2>/dev/null
done
drvdir="/sys/bus/usb/drivers/$drv"
[ -d "$drvdir" ] || continue
for dev_path in "$drvdir"/*; do
[ -L "$dev_path" ] || continue
name="${dev_path##*/}"
# Skip the driver's own 'module' symlink and similar metadata
[ "$name" = "module" ] || [ "$name" = "uevent" ] || [ "$name" = "new_id" ] && continue
echo "$name" >"$drvdir/unbind" 2>/dev/null
echo "$name" >/sys/bus/usb/drivers_probe 2>/dev/null
done
done
#---------------------------------------------------------------------
@ -68,10 +68,10 @@ done
# request fires pre-/vendor the first time and fails).
#---------------------------------------------------------------------
for dev in /sys/bus/serial/devices/*; do
[ -e "$dev/driver" ] || continue
name="${dev##*/}"
echo "$name" > "$dev/driver/unbind" 2>/dev/null
echo "$name" > /sys/bus/serial/drivers_probe 2>/dev/null
[ -e "$dev/driver" ] || continue
name="${dev##*/}"
echo "$name" >"$dev/driver/unbind" 2>/dev/null
echo "$name" >/sys/bus/serial/drivers_probe 2>/dev/null
done
exit 0