mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 14:07:49 +01:00
Two levels of pure taxonomy carrying no information, and a 2-directory
cap leaves no room for them. Categories now sit directly under
linux_configuration/: features, fixes, utils, misc, fresh-install,
installers, diagnostics, gaming, boot_recovery, periodic_background, lib,
meta, tests. A script's own lib/ and tests/ are exempt from the cap, so
those stay put.
Depth violations 248 -> 139; roughly 40 of the remainder are inside
digital_wellbeing and hosts, deferred until the guard-lib repoint.
The moves are the easy half. What breaks is every path that counted
levels, and three classes of it had to be found by resolving paths rather
than reading diffs:
- 52 relative `source` lines for lib/common.sh and lib/android.sh. The
correct prefix differs per file: 40 were ../../ and 12 were ../../../,
so a blanket replace would have fixed one set and broken the other.
- REPO_ROOT in 7 fixes/lib/tests harnesses and setup_syncyomi_guard.sh,
each walking up four levels from a directory now two levels shallower.
This caused a real regression -- the fixes suite went red with
"log_warn: command not found" -- caught by running it and comparing
against the pre-move baseline worktree.
- conftest.py's sys.path entries, which took the pytest gate down with
14 collection errors, and the `# shellcheck source=` directives, which
took shellcheck down with SC1091.
16 symlinks in $HOME broke, including the entire i3blocks bar. All
repointed, and cpu_monitor/memory/disk/time/volume were run to confirm
they emit real output rather than merely resolving.
Verified: 1798 tests pass at 100% coverage, 8 of 9 lib/tests suites pass
(the ninth needs the coverage jail, identically at baseline), pre-commit
is clean, and the two untracked secret configs are still ignored after
their gitignore paths changed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
145 lines
4.8 KiB
Bash
Executable File
145 lines
4.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Boot image patching with Magisk.
|
|
#
|
|
# Sourced by root_bl9000.sh; split out to keep it under the 250-line
|
|
# cap. Sourced rather than run, so it inherits the caller's strict mode
|
|
# and the variables defined above the source line.
|
|
|
|
patch_boot_with_magisk() {
|
|
print_header "Patching Boot Image with Magisk"
|
|
|
|
if [[ ! -f ${BOOT_IMG:-} ]]; then
|
|
die "Boot image not found: ${BOOT_IMG:-none}"
|
|
fi
|
|
|
|
local magisk_apk="$WORK_DIR/magisk.apk"
|
|
if [[ ! -f $magisk_apk ]]; then
|
|
die "Magisk APK not found. Run download step first."
|
|
fi
|
|
|
|
log "Checking if device is connected..."
|
|
if ! adb devices | grep -q "device$"; then
|
|
die "No device detected. Make sure USB debugging is enabled and device is connected."
|
|
fi
|
|
|
|
log "Installing Magisk APK on device..."
|
|
if ! adb install -r "$magisk_apk" 2> /dev/null; then
|
|
warn "Magisk APK installation failed (may already be installed)"
|
|
fi
|
|
|
|
log "Pushing boot image to device..."
|
|
adb push "$BOOT_IMG" /sdcard/Download/boot.img || die "Failed to push boot image"
|
|
|
|
echo
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo " MANUAL STEP REQUIRED"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo
|
|
echo "On your phone:"
|
|
echo "1. Open the Magisk app"
|
|
echo "2. Tap 'Install' next to Magisk"
|
|
echo "3. Select 'Select and Patch a File'"
|
|
echo "4. Navigate to Downloads and select boot.img"
|
|
echo "5. Tap 'Let's Go' and wait for patching to complete"
|
|
echo "6. The patched file will be saved as magisk_patched_*.img"
|
|
echo
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo
|
|
|
|
if ! confirm "Have you completed patching the boot image in Magisk app?"; then
|
|
error "Patching cancelled by user"
|
|
return 1
|
|
fi
|
|
|
|
log "Pulling patched boot image from device..."
|
|
|
|
local patched_img
|
|
patched_img=$(adb shell "ls /sdcard/Download/magisk_patched_*.img 2>/dev/null" | tr -d '\r\n' | head -n1 || echo "")
|
|
|
|
if [[ -z $patched_img ]]; then
|
|
error "Could not find patched boot image on device."
|
|
echo "Please ensure the patching completed successfully in Magisk app."
|
|
return 1
|
|
fi
|
|
|
|
PATCHED_BOOT_IMG="$WORK_DIR/magisk_patched.img"
|
|
if ! adb pull "$patched_img" "$PATCHED_BOOT_IMG"; then
|
|
error "Failed to pull patched boot image"
|
|
return 1
|
|
fi
|
|
|
|
log "Patched boot image saved to: $PATCHED_BOOT_IMG"
|
|
return 0
|
|
}
|
|
|
|
flash_patched_boot() {
|
|
print_header "Flashing Patched Boot Image"
|
|
|
|
if [[ ! -f ${PATCHED_BOOT_IMG:-} ]]; then
|
|
die "Patched boot image not found: ${PATCHED_BOOT_IMG:-none}"
|
|
fi
|
|
|
|
echo
|
|
echo -e "${YELLOW}This will flash the patched boot image to your device.${NC}"
|
|
echo "Device uses A/B partitions - will flash to boot_a"
|
|
echo
|
|
|
|
if ! confirm "Proceed with flashing?"; then
|
|
log "Flashing cancelled by user"
|
|
return 1
|
|
fi
|
|
|
|
log "Rebooting to bootloader..."
|
|
adb reboot bootloader || die "Failed to reboot to bootloader"
|
|
|
|
log "Waiting for fastboot mode..."
|
|
sleep 5
|
|
|
|
if ! sudo fastboot devices | grep -q .; then
|
|
die "Device not detected in fastboot mode"
|
|
fi
|
|
|
|
log "Flashing patched boot image to boot_a..."
|
|
if ! sudo fastboot flash boot_a "$PATCHED_BOOT_IMG"; then
|
|
error "Failed to flash boot image"
|
|
return 1
|
|
fi
|
|
|
|
log "Flashed successfully!"
|
|
log "Rebooting device..."
|
|
sudo fastboot reboot
|
|
|
|
log "Waiting for device to boot..."
|
|
sleep 10
|
|
adb wait-for-device || true
|
|
|
|
echo
|
|
echo -e "${GREEN}╔═══════════════════════════════════════════════════════╗${NC}"
|
|
echo -e "${GREEN}║ Root Process Complete! ║${NC}"
|
|
echo -e "${GREEN}╚═══════════════════════════════════════════════════════╝${NC}"
|
|
echo
|
|
echo "Your BL9000 phone should now be rooted with Magisk!"
|
|
echo
|
|
echo "Next steps:"
|
|
echo "1. Open the Magisk app on your phone"
|
|
echo "2. Verify that it shows 'Installed' for both Magisk and App"
|
|
echo "3. Grant root access to apps as needed"
|
|
echo "4. Install Magisk modules if desired"
|
|
echo
|
|
echo "Note: Some banking and secure apps may not work with root."
|
|
echo " Use Magisk's DenyList feature to hide root from specific apps."
|
|
echo
|
|
|
|
return 0
|
|
}
|
|
|
|
clean_work_dir() {
|
|
if [[ -d $WORK_DIR ]]; then
|
|
log "Removing working directory: $WORK_DIR"
|
|
rm -rf "$WORK_DIR"
|
|
log "Cleaned successfully"
|
|
else
|
|
log "Work directory doesn't exist: $WORK_DIR"
|
|
fi
|
|
}
|