Skip to content

TSI Architecture

Current Implementation (C)

TSI is implemented in pure C (C11 standard) with no runtime dependencies.

Advantages

  • Universal availability: C compiler (gcc/clang/cc) is available on virtually all systems
  • Single binary: Can be compiled as a static binary with no dependencies
  • Small footprint: Compiled binary is small and efficient
  • Easy bootstrap: Most minimal systems have a C compiler
  • No runtime dependency: Self-contained executable
  • Performance: Fast execution for package management operations
  • Distribution independence: Works on any Unix-like system with a C compiler

Implementation Details

  • Language: C11 (ISO/IEC 9899:2011)
  • Build System: Make
  • Dependencies: None (pure C standard library)
  • Linking: Static linking preferred (optional dynamic linking on macOS)

Core Components

  1. Package Management (package.c/h)
  2. JSON manifest parsing
  3. Package metadata handling
  4. Dependency tracking

  5. Dependency Resolution (resolver.c/h)

  6. Topological sorting
  7. Dependency graph construction
  8. Build order determination

  9. Source Fetching (fetcher.c/h)

  10. Git repository cloning
  11. Tarball/zip downloading
  12. Local source handling

  13. Build System Integration (builder.c/h)

  14. Autotools support
  15. CMake support
  16. Meson support
  17. Plain Makefile support
  18. Custom build commands

  19. Database (database.c/h)

  20. Installed package tracking
  21. JSON-based storage
  22. Package metadata persistence

  23. Repository (resolver.c/h)

  24. Package manifest loading
  25. Repository directory scanning
  26. Package lookup

  27. CLI (main.c)

  28. Command-line interface
  29. Install/remove/list commands
  30. Package information display

Design Principles

  1. Minimal Requirements: Only needs a C compiler
  2. Source-Based: Everything built from source
  3. Isolated Installation: Packages installed to separate prefix
  4. Distribution Independent: No reliance on system package managers
  5. Self-Contained: Single binary, no runtime dependencies

Future Considerations

Potential Enhancements

  • Parallel builds
  • Build caching
  • Binary package distribution (optional)
  • Cross-compilation support
  • Package signing/verification

Platform Support

  • Primary: Linux (all distributions)
  • Secondary: macOS, BSD variants
  • Target: Embedded systems (Xilinx, etc.)

Build Process

  1. Compile all C source files to object files
  2. Link into single binary (tsi)
  3. Optional: Static linking for maximum portability
  4. Install to system or user directory

Testing

Comprehensive Docker-based testing: - Minimal systems (no tools) - Systems with C compiler only - Various Linux distributions (Alpine, Ubuntu)

See the docker directory in the repository root for testing details.