diff --git a/fedac/native/scripts/media-layout.sh b/fedac/native/scripts/media-layout.sh index f9d0e9f6b0..6b3d429a65 100644 --- a/fedac/native/scripts/media-layout.sh +++ b/fedac/native/scripts/media-layout.sh @@ -273,8 +273,33 @@ ac_media_partition_start_sector() { ' } +ac_media_partition_number_for_type_guid() { + local image_path="$1" + local type_guid="$2" + + python3 - "$image_path" "$type_guid" <<'PYEOF' +import re +import subprocess +import sys + +image_path, type_guid = sys.argv[1:] +dump = subprocess.check_output(["sfdisk", "-d", image_path], text=True, stderr=subprocess.DEVNULL) +pattern = re.compile(rf"{re.escape(image_path)}(\d+)\s*:.*type=([0-9A-Fa-f\-]+)") +for line in dump.splitlines(): + match = pattern.match(line.strip()) + if match and match.group(2).lower() == type_guid.lower(): + print(match.group(1)) + raise SystemExit(0) +raise SystemExit(1) +PYEOF +} + ac_media_nixos_data_partition_start_sector() { - ac_media_partition_start_sector "$1" 3 + local image_path="$1" + local data_part + + data_part="$(ac_media_partition_number_for_type_guid "${image_path}" "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7")" || return 1 + ac_media_partition_start_sector "${image_path}" "${data_part}" } ac_media_generate_manifest() { @@ -348,7 +373,13 @@ ac_media_customize_nixos_efi_boot() { return 1 fi - if ! efi_start="$(ac_media_partition_start_sector "${image_path}" 2)"; then + local efi_part + if ! efi_part="$(ac_media_partition_number_for_type_guid "${image_path}" "C12A7328-F81F-11D2-BA4B-00A0C93EC93B")"; then + echo "No EFI boot partition found in ${image_path}" >&2 + return 1 + fi + + if ! efi_start="$(ac_media_partition_start_sector "${image_path}" "${efi_part}")"; then echo "No EFI boot partition found in ${image_path}" >&2 return 1 fi diff --git a/fedac/native/scripts/nixos-image-helper.sh b/fedac/native/scripts/nixos-image-helper.sh index 2b1bdd9bb9..a89bdd7e94 100644 --- a/fedac/native/scripts/nixos-image-helper.sh +++ b/fedac/native/scripts/nixos-image-helper.sh @@ -9,14 +9,39 @@ CONFIG_JSON_PATH="${2:?usage: nixos-image-helper.sh }" log() { echo "[nixos-image-helper] $*"; } err() { echo "[nixos-image-helper] $*" >&2; } -part_path() { - local dev="$1" - local idx="$2" - if [[ "${dev}" =~ [0-9]$ ]]; then - printf '%sp%s\n' "${dev}" "${idx}" - else - printf '%s%s\n' "${dev}" "${idx}" - fi +partition_sector_field() { + local image_path="$1" + local part_number="$2" + local field_name="$3" + python3 - "$image_path" "$part_number" "$field_name" <<'PYEOF' +import re +import subprocess +import sys + +image_path, part_number, field_name = sys.argv[1:] +part_number = int(part_number) +dump = subprocess.check_output(["sfdisk", "-d", image_path], text=True, stderr=subprocess.DEVNULL) +pattern = re.compile(rf"{re.escape(image_path)}(\d+)\s*:(.*)") + +for line in dump.splitlines(): + match = pattern.match(line.strip()) + if not match or int(match.group(1)) != part_number: + continue + fields = {} + for field in match.group(2).split(","): + field = field.strip() + if "=" not in field: + continue + key, value = field.split("=", 1) + fields[key.strip()] = value.strip().strip('"') + value = fields.get(field_name) + if value and re.fullmatch(r"\d+", value): + print(value) + raise SystemExit(0) + raise SystemExit(1) + +raise SystemExit(1) +PYEOF } partition_number_for_type() { @@ -85,7 +110,7 @@ append_partition() { sfdisk --no-reread -N "${part_number}" "${image_path}" >/dev/null } -wait_for_partition() { +wait_for_block_device() { local part="$1" for _ in $(seq 1 40); do [ -b "${part}" ] && return 0 @@ -95,7 +120,27 @@ wait_for_partition() { return 1 } -LOOP_DEV="" +bind_partition_loop() { + local image_path="$1" + local part_number="$2" + local sector_size=512 + local start_sector + local size_sectors + local offset_bytes + local size_bytes + local loop_dev + + start_sector="$(partition_sector_field "${image_path}" "${part_number}" "start")" + size_sectors="$(partition_sector_field "${image_path}" "${part_number}" "size")" + offset_bytes=$(( start_sector * sector_size )) + size_bytes=$(( size_sectors * sector_size )) + + loop_dev="$(losetup --find --show --offset "${offset_bytes}" --sizelimit "${size_bytes}" "${image_path}")" + LOOP_DEVS+=("${loop_dev}") + printf '%s\n' "${loop_dev}" +} + +declare -a LOOP_DEVS=() TMP_DIR="" EFI_MOUNT="" MAC_MOUNT="" @@ -105,8 +150,11 @@ cleanup() { umount "${EFI_MOUNT:-}" 2>/dev/null || true umount "${MAC_MOUNT:-}" 2>/dev/null || true umount "${DATA_MOUNT:-}" 2>/dev/null || true - if [ -n "${LOOP_DEV}" ]; then - losetup -d "${LOOP_DEV}" 2>/dev/null || true + if [ "${#LOOP_DEVS[@]}" -gt 0 ]; then + local idx + for (( idx=${#LOOP_DEVS[@]}-1; idx>=0; idx-- )); do + losetup -d "${LOOP_DEVS[$idx]}" 2>/dev/null || true + done fi rm -rf "${TMP_DIR:-}" } @@ -152,14 +200,13 @@ if [ -z "${DATA_PART_NUM}" ]; then "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" "$(ac_media_nixos_data_label)" fi -LOOP_DEV="$(losetup --find --show --partscan "${IMAGE_PATH}")" -EFI_PART="$(part_path "${LOOP_DEV}" "${EFI_PART_NUM}")" -MAC_PART="$(part_path "${LOOP_DEV}" "${MAC_PART_NUM}")" -DATA_PART="$(part_path "${LOOP_DEV}" "${DATA_PART_NUM}")" +EFI_PART="$(bind_partition_loop "${IMAGE_PATH}" "${EFI_PART_NUM}")" +MAC_PART="$(bind_partition_loop "${IMAGE_PATH}" "${MAC_PART_NUM}")" +DATA_PART="$(bind_partition_loop "${IMAGE_PATH}" "${DATA_PART_NUM}")" -wait_for_partition "${EFI_PART}" -wait_for_partition "${MAC_PART}" -wait_for_partition "${DATA_PART}" +wait_for_block_device "${EFI_PART}" +wait_for_block_device "${MAC_PART}" +wait_for_block_device "${DATA_PART}" if ! blkid -o value -s LABEL "${MAC_PART}" >/dev/null 2>&1; then mkfs.hfsplus -v AC-MAC "${MAC_PART}" >/dev/null diff --git a/fedac/native/scripts/upload-release.sh b/fedac/native/scripts/upload-release.sh index 474cf13e20..c90970354a 100755 --- a/fedac/native/scripts/upload-release.sh +++ b/fedac/native/scripts/upload-release.sh @@ -10,7 +10,7 @@ set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" IMAGE_ONLY=0 -if [ "${1:-}" = "--image" ] || [ "${1:-}" = "--iso" ]; then +if [ "${1:-}" = "--image" ]; then IMAGE_ONLY=1 IMAGE_PATH="${2:-${SCRIPT_DIR}/../build/ac-os.img}" if [ ! -f "$IMAGE_PATH" ]; then diff --git a/fedac/nixos/configuration.nix b/fedac/nixos/configuration.nix index bcab885575..fe0f82a124 100644 --- a/fedac/nixos/configuration.nix +++ b/fedac/nixos/configuration.nix @@ -24,7 +24,6 @@ in "rd.systemd.show_status=1" "udev.log_priority=info" "consoleblank=0" - "nomodeset" ]; boot.consoleLogLevel = 7; diff --git a/fedac/nixos/flake.lock b/fedac/nixos/flake.lock index 7e80c5e52d..8be25e949e 100644 --- a/fedac/nixos/flake.lock +++ b/fedac/nixos/flake.lock @@ -1,41 +1,5 @@ { "nodes": { - "nixlib": { - "locked": { - "lastModified": 1736643958, - "narHash": "sha256-tmpqTSWVRJVhpvfSN9KXBvKEXplrwKnSZNAoNPf/S/s=", - "owner": "nix-community", - "repo": "nixpkgs.lib", - "rev": "1418bc28a52126761c02dd3d89b2d8ca0f521181", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixpkgs.lib", - "type": "github" - } - }, - "nixos-generators": { - "inputs": { - "nixlib": "nixlib", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1769813415, - "narHash": "sha256-nnVmNNKBi1YiBNPhKclNYDORoHkuKipoz7EtVnXO50A=", - "owner": "nix-community", - "repo": "nixos-generators", - "rev": "8946737ff703382fda7623b9fab071d037e897d5", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nixos-generators", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1774709303, @@ -54,7 +18,6 @@ }, "root": { "inputs": { - "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs" } } diff --git a/oven-edge/worker.mjs b/oven-edge/worker.mjs index 95b0b7e075..af4a9bfbc4 100644 --- a/oven-edge/worker.mjs +++ b/oven-edge/worker.mjs @@ -184,7 +184,7 @@ export default { return applyHeaders(ovenRes, request, { "X-Patch": "origin-fallback" }); } - // 3. Get template ISO stream + // 3. Get template image stream const template = await getTemplateStream(env, manifest); if (!template) { // R2 + Spaces both failed — fall through to oven diff --git a/system/public/aesthetic.computer/disks/os.mjs b/system/public/aesthetic.computer/disks/os.mjs index 9a02420366..e1ef3f7e92 100644 --- a/system/public/aesthetic.computer/disks/os.mjs +++ b/system/public/aesthetic.computer/disks/os.mjs @@ -37,7 +37,7 @@ let bootPieceIdx = 0; // index into BOOT_PIECES let bootBtn = null; // "boot to: X" button let variantIdx = 0; // index into VARIANTS (0=C, 1=Common Lisp) let variantBtn = null; // "build: C" selector -let clAvailable = false; // true once we confirm CL ISO exists on CDN +let clAvailable = false; // true once we confirm the CL image exists on CDN let wifiEnabled = true; let wifiBtn = null; // "internet: ON/OFF" toggle let scrollY = 0;