Skip to content
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

Feature: CLI options for bundle directory and program name #284

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andria-dev
Copy link

@andria-dev andria-dev commented Jul 25, 2024

Implements #282. --bundle-dir will determine where the bootloader extracts the archive to. --prog-name will determine the name of the program within the archive. For example:

# We can specify the new options like so:
staticx --bundle-dir /tmp/ssh-6YD5uj0Xx7wI --prog-name agent.1542 myprogram ssh-agent

# And when we run the staticx program,
./ssh-agent
# it will extract to the folder /tmp/ssh-6YD5uj0Xx7wI,
# and the program will be extracted to /tmp/ssh-6YD5uj0Xx7wI/agent.1542

# The program will show up as two processes in a process listing:
# ./ssh-agent and its child process /tmp/ssh-6YD5uj0Xx7wI/agent.1542

Checklist

Testing

Testing done in test/bundle-dir-prog-name.sh.

  • Testing that $STATICX_BUNDLE_DIR is the same as --bundle-dir.
  • Testing that basename $0 is the same as --prog-name.

CLI

  • Added option --bundle-dir with help message.
  • Added option --prog-name with help message.

Documentation

  • Added --bundle-dir and --prog-name under the docs/usage.rst.
  • Updated old python functions docstrings to include --bundle-dir and --prog-name.
  • Documented new C functions get_symlink, move_bundle, and file_exists.
  • Documented new Python function add_bundle_dir_symlink.

Implementation

--prog-name

  • When adding the modified program to the archive, use --prog-name when specified instead of the basename of positional argument prog.

--bundle-dir

Unfortunately, I don't have the C skills to have it extract directly to the new bundle directory, so my solution here is to extract to the /tmp/staticx-XXXXXX and then move it to the new bundle directory, which is obviously not ideal. If anyone has any ideas about how to read the TAR archive to get the symlink before extracting please feel free to jump in.

  • Add a symlink file to the archive for --bundle-dir.
  • In the bootloader, check if the file exists.
  • If it does, read the symlink and move the bundle directory to the symlink's value.

Ignore #283. I just had some branch name issues there that caused it to auto close.

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