apt-ostree-builder/todo.txt
robojerk fa22f3f903 Add enhanced partitioning system with multiple tool support
- Add --partitioner option supporting parted, sgdisk, sfdisk, auto
- Implement fallback mechanism when tools fail
- Add robust partition verification and validation
- Improve error handling and logging
- Add loop device management with retry logic
- Support different partition size units (kB, MB, MiB)
- Integrate partitioning approaches from partition_creator.rs

Features:
- Auto-selection tries parted -> sgdisk -> sfdisk
- User can force specific tool with --partitioner
- Graceful fallback for unknown tools
- Detailed logging of which tool is used
- Proper resource cleanup and error recovery
2025-09-10 11:35:49 -07:00

137 lines
5.3 KiB
Text

# Bootc Image Builder - Proper Implementation TODO
## Core Requirements (What We Actually Need)
### 1. OCI Image Processing ✅ (Working)
- [x] Extract OCI container image layers
- [x] Parse OCI manifest and index
- [x] Build root filesystem from layers
- [x] Handle permission issues and whiteout files
### 2. Bootc Integration ✅ (Working)
- [x] Configure bootc support in rootfs
- [x] Set up composefs configuration
- [x] Create initramfs with bootc support
- [x] Handle dracut fallback to minimal initramfs
### 3. Bootloader Management ✅ (Working)
- [x] Auto-detect bootloader type
- [x] Configure GRUB bootloader
- [x] Install bootloader files
### 4. Disk Image Creation ❌ (COMPLETE FAILURE - Needs Complete Rewrite)
#### 4.1 Create Raw Disk Image
- [ ] Create actual raw disk image file (not tar archive)
- [ ] Set proper disk size (e.g., 5GB as specified)
- [ ] Initialize with zeros or sparse file
#### 4.2 Partition Table Creation
- [ ] Use proper partitioning tool (sfdisk, parted, or fdisk)
- [ ] Create MBR or GPT partition table
- [ ] Create bootable primary partition
- [ ] Set partition flags (bootable, etc.)
#### 4.3 Filesystem Creation
- [ ] Set up loop device for the disk image
- [ ] Format partition with ext4 filesystem
- [ ] Set proper filesystem options (label, etc.)
#### 4.4 Rootfs Installation
- [ ] Mount the formatted partition
- [ ] Copy rootfs contents to mounted partition
- [ ] Preserve permissions and ownership
- [ ] Handle special files (devices, symlinks, etc.)
#### 4.5 Bootloader Installation
- [ ] Install appropriate bootloader (GRUB, systemd-boot) to the disk image (not just rootfs)
- [ ] Create proper bootloader configuration for GRUB
- [ ] Create proper bootloader configuration for systemd-boot
- [ ] Install boot sector and stage files
- [ ] Set up boot menu and kernel parameters
#### 4.6 Future Bootloader Support (TODO)
- [ ] Unified kernel image (UKI) support (add stub code for now)
- [ ] EFI boot stub support (add stub code for now)
- [ ] Clover bootloader support (add stub code for now)
#### 4.6 Image Finalization
- [ ] Unmount partitions
- [ ] Detach loop devices
- [ ] Verify disk image integrity
- [ ] Convert to target format (qcow2, vmdk, etc.)
### 5. Format Conversion
- [ ] Convert raw disk image to qcow2
- [ ] Support multiple output formats (raw, qcow2, vmdk)
- [ ] Compress images appropriately
- [ ] Validate output format
### 6. Error Handling & Validation
- [ ] Validate disk image is actually bootable
- [ ] Test with QEMU to verify boot process
- [ ] Handle disk space issues gracefully
- [ ] Provide meaningful error messages
### 7. Testing & Verification
- [ ] Test with different container images
- [ ] Verify boot process works
- [ ] Test with different disk sizes
- [ ] Validate all output formats
## Current Status: 20% Complete (REALISTIC ASSESSMENT)
- OCI processing: ✅ Working
- Rootfs construction: ✅ Working
- **Bootc integration: ❌ FAKE (placeholder bash script, not real bootc binary)**
- **OSTree repository: ❌ FAKE (empty directory, no actual OSTree)**
- **Bootloader config: ❌ FAKE (only configures rootfs files, not disk image)**
- **Disk image creation: ❌ COMPLETE FAILURE (tar archive, not bootable disk)**
- **Format conversion: ❌ FAKE (converting tar to qcow2)**
## Next Steps:
1. **COMPLETELY REWRITE** the disk image creation function
2. **IMPLEMENT PROPER** partitioning and filesystem creation
3. **INSTALL BOOTLOADER** to actual disk image, not just rootfs
4. **REPLACE FAKE BOOTC** with real bootc binary
5. **IMPLEMENT REAL OSTree** repository creation
6. **TEST ACTUAL BOOTING** to verify it works
## CRITICAL ISSUES TO FIX:
- **FAKE BOOTC BINARY**: Replace placeholder bash script with real bootc
- **FAKE OSTree**: Create actual OSTree repository with commits
- **FAKE DISK IMAGE**: Create real partitioned, bootable disk image
- **FAKE BOOTLOADER**: Install GRUB to actual disk, not just rootfs files
- **FAKE FORMAT CONVERSION**: Convert real disk image, not tar archive
## Tools Needed:
- `qemu-img` for disk image creation
- `sfdisk` or `parted` for partitioning
- `mkfs.ext4` for filesystem creation
- `losetup` for loop device management
- `mount`/`umount` for filesystem operations
- `grub-install` for bootloader installation
## Debian Package Dependencies Update:
Update the Debian package to include all necessary tools from the private registry:
### Core Dependencies (from https://git.raines.xyz/particle-os/-/packages/debian/):
- **apt-ostree** (0.1.0-2+build20250908191909.2e4acff6de) - Core OSTree functionality
- **bootc** (0.1.0++) - Real bootc binary (34 MiB)
- **composefs** (0.1.0++) - Container filesystem support (21 KiB)
- **libfuse3-3** (3.10.0-1) - FUSE library for composefs (286 KiB)
- **bootupd** (0.1.0++) - Bootloader management (28 MiB)
### Additional System Dependencies:
- `qemu-utils` - For qemu-img
- `parted` or `util-linux` - For sfdisk/parted
- `e2fsprogs` - For mkfs.ext4
- `dosfstools` - For mkfs.fat
- `dracut` - For initramfs generation
- `grub-common` and `grub-pc-bin` - For GRUB installation
### Registry Setup:
```bash
sudo curl https://git.raines.xyz/api/packages/particle-os/debian/repository.key -o /etc/apt/keyrings/forgejo-particle-os.asc
echo "deb [signed-by=/etc/apt/keyrings/forgejo-particle-os.asc] https://git.raines.xyz/api/packages/particle-os/debian trixie main" | sudo tee -a /etc/apt/sources.list.d/forgejo.list
sudo apt update
```