Skip to content

ixbin: Add util script to update image contents #1042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

ixbin: Add util script to update image contents #1042

wants to merge 1 commit into from

Conversation

wkz
Copy link
Contributor

@wkz wkz commented May 7, 2025

Description

usage: ixbin COMMAND [ARGS...]

Update contents of Infix images

Commands:

  unpack PKG KEY-DIR DIR

    Unpack the RAUC bundle PKG and the root filesystem contained in
    it, using the keys stored in KEY-DIR, and store the results in
    DIR.

  pack DIR [KEY-DIR] PKG

    Repackage the (possibly modified) root filesystem in DIR, updating
    all signatures as necessary using the keys stored in KEY-DIR (or
    the keys used to unpack the bundle, if not specified) and store
    the resulting bundle in PKG.

  exec DIR COMMAND [ARGS...]

    Run COMMAND, possibly with ARGS, from the root of the filesystem
    in DIR, inside of a fakeroot context that allows otherwise
    privileged operations such as ownership modifications.

  help

    Show this message and exit.

Key directories:

  KEY-DIR arguments must reference a directory that contains the
  public/private keypair used to verify/sign an image. Most commonly,
  board/common/signing-keys/development from the Infix source tree is
  used to validate the input image.

Example:

  Include a custom file inside a prebuilt Infix image, assign it to
  the UID/GID 1337; and package up the results, signing it with the
  same developer key that was used to create it:

    ixbin unpack infix-aarch64.pkg ~/infix/board/common/signing-keys/development tmp
    cp VBRUN300.DLL tmp/rootfs/lib/
    ixbin exec tmp chown 1337:1337 lib/VBRUN300.DLL
    ixbin pack tmp infix-vb3-aarch64.pkg

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe): Utility script

@wkz wkz requested a review from troglobit May 7, 2025 11:56
Copy link
Contributor

@troglobit troglobit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work!

utils/ixbin Outdated
ensuredeps()
{
DEPS="fakeroot mksquashfs unsquashfs awk env mkimage truncate dtc fdtget rauc"
which -s $DEPS && return 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get error about -s flag for which on Ubuntu 22.

Illegal option -s
Usage: /usr/bin/which [-a] args

Maybe something about the version for which changing between Ubuntu 22 and Ubuntu 24...?

which is mostly just an alias for type with some flags on some distros. I would probably use type here for better portability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Here's another alternative I often use myself, example from another (POSIX shell compliant) script:

error()
{
    printf "\033[1;31mError: %s\033[0m\n" "$*" >&2
}

fatal()
{
    error "$*"
    exit 1
}

# Check for required programs
for proggy in $DEPS; do
    if ! command -v $proggy >/dev/null 2>&1; then
        fatal "$proggy not found, required."
    fi
done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL: which is not in POSIX.

The shame, the absolute SHAME! 😆

Updated the script to use command -v instead.

@abbenteprizer is it working as expected otherwise?

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.

3 participants