Skip to content

tools: strip binaries to save disk space#3769

Draft
Williangalvani wants to merge 1 commit intobluerobotics:masterfrom
Williangalvani:strip_rust
Draft

tools: strip binaries to save disk space#3769
Williangalvani wants to merge 1 commit intobluerobotics:masterfrom
Williangalvani:strip_rust

Conversation

@Williangalvani
Copy link
Member

@Williangalvani Williangalvani commented Feb 5, 2026

saves ~40mb of ~346mb we currently have of rust binaries 🤔

Summary by Sourcery

Strip downloaded tool binaries in the core image to reduce disk usage.

Enhancements:

  • Strip all downloaded helper binaries in their bootstrap scripts after making them executable to reduce their size on disk.

Build:

  • Install binutils in the Docker image build stage to enable stripping of downloaded binaries.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR reduces disk usage by installing binutils in the image build stage and stripping downloaded Rust (and other) binaries as part of each tool’s bootstrap script.

Sequence diagram for updated tool bootstrap installation and stripping

sequenceDiagram
    actor User
    participant BootstrapScript
    participant RemoteServer
    participant FileSystem
    participant BinutilsStrip

    User->>BootstrapScript: Execute bootstrap.sh
    BootstrapScript->>BootstrapScript: Set BINARY_PATH and REMOTE_URL
    BootstrapScript->>RemoteServer: wget REMOTE_URL
    RemoteServer-->>BootstrapScript: Binary data
    BootstrapScript->>FileSystem: Write binary to BINARY_PATH
    BootstrapScript->>FileSystem: chmod +x BINARY_PATH
    BootstrapScript->>BinutilsStrip: strip BINARY_PATH
    BinutilsStrip-->>FileSystem: Stripped binary at BINARY_PATH
    BootstrapScript->>BootstrapScript: file BINARY_PATH
    BootstrapScript-->>User: Report installed binary type
Loading

Flow diagram for Docker image build with binutils installation

flowchart TD
    A[Base_image bluerobotics/blueos-base:0.2.2] --> B[Stage_download-binaries]
    B --> C[Copy tools to /home/pi/tools]
    C --> D[apt update]
    D --> E[apt install -y --no-install-recommends binutils]
    E --> F[Run install-static-binaries.sh]
    F --> G[Image_with_tools_and_binutils]

    subgraph Runtime_bootstrap_tools
        H[Bootstrap_script] --> I[wget binary to BINARY_PATH]
        I --> J[chmod +x BINARY_PATH]
        J --> K[strip BINARY_PATH using binutils]
        K --> L[Stripped_binary_ready]
    end
Loading

File-Level Changes

Change Details Files
Install binutils in the Docker build stage so binaries can be stripped during bootstrap.
  • Extend the download-binaries stage to run apt update and install binutils with no recommended packages.
  • Keep the rest of the Docker build pipeline unchanged so only the tools stage is affected.
core/Dockerfile
Strip all downloaded tool binaries after marking them executable to reduce their on-disk size.
  • Update each tool bootstrap script to invoke strip on the downloaded binary after chmod +x.
  • Apply the same strip logic across all Rust-based and related tools to keep behavior consistent.
  • Preserve existing logging of installed binary type without changing command behavior aside from file size.
core/tools/bridges/bootstrap.sh
core/tools/linux2rest/bootstrap.sh
core/tools/machineid/bootstrap.sh
core/tools/mavlink2rest/bootstrap.sh
core/tools/mavlink_camera_manager/bootstrap.sh
core/tools/mavlink_server/bootstrap.sh
core/tools/mcap-extractor/bootstrap.sh
core/tools/mcap/bootstrap.sh
core/tools/recorder/bootstrap.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant