diff --git a/mkimg.sh b/mkimg.sh index 6bdb7a1..197619a 100755 --- a/mkimg.sh +++ b/mkimg.sh @@ -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 < /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)." diff --git a/wifi/wireless_reprobe.sh b/wifi/wireless_reprobe.sh index 21ea445..9ae4b3d 100644 --- a/wifi/wireless_reprobe.sh +++ b/wifi/wireless_reprobe.sh @@ -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