# ArkOS Build Tools The build orchestration layer for ArkOS. These tools compile, sign, pack, and assemble the entire operating system into bootable disk images. ## Components ### `build.c` — Build Orchestrator The main build driver. Accepts the ArkOS base directory as its first argument and executes all build phases sequentially with modular `[step/total]` progress output. **Usage:** ```bash # Called automatically by the top-level Makefile: ./build /path/to/arkos # Or build the tool manually: make # Compiles build.c + ark_parser.c → ./build make clean # Removes compiled binary ``` **What it does (14 steps):** 1. Cleans previous build artifacts 2. Creates staging directories (`out_staging/`) 3. Copies frameworks to staging 4. Copies boot files to staging 5. Copies vendor files to staging 6. Verifies kernel `.config` exists 7. Compiles `fb_helper.c` with prebuilt Clang 8. Compiles `swift_splash.swift` with `swiftc` 9. Signs `swift_splash` binary (Verified Boot) 10. Compiles `init.c` + `sha256.c` with prebuilt Clang 11. Packs initramfs (base + init + swift_splash + signature) 12. Assembles bootloader + stage2 with `nasm` 13. Generates `boot.img` via `pack_boot.py` 14. Generates disk images (`sys.img`, `vend.img`, `avb.img`, etc.) All intermediate artifacts go into `out_staging/`. Final outputs go into `finished/`. --- ### `ark_parser.c` / `ark_parser.h` — `.ark` Config Parser A lightweight C library for parsing ArkOS's custom `.ark` configuration file format. **Supported syntax:** ``` # Comments start with # key = value # Global key-value pairs standalone_value # Standalone values (e.g., signing keys) [SectionName] # Named sections section_key = value ``` **API:** ```c ArkConfig* ark_parse(const char* filepath); const char* ark_get_global(ArkConfig* config, const char* key); const char* ark_get_section_val(ArkConfig* config, const char* section, const char* key); void ark_set_global(ArkConfig* config, const char* key, const char* value); void ark_dump(ArkConfig* config, const char* filepath); void ark_free(ArkConfig* config); ``` --- ### `pack_boot.py` — Boot Image Packager Assembles the final `boot.img` by concatenating the bootloader, stage2, animation frames, kernel, and initramfs into a single raw disk image. Patches stage2 binary variables (LBA offsets, sector counts) in-place. **Usage:** ```bash python3 pack_boot.py --base-dir /path/to/arkos ``` **Disk layout:** ``` Sector 0 : Stage 1 bootloader (512 bytes) Sectors 1-7 : Stage 2 bootloader (3.5 KB) Sectors 8+ : Animation data Sectors N+ : bzImage (Linux kernel) Sectors M+ : initramfs.img ``` ## License See [LICENSE](LICENSE) for details.