staticx
staticx copied to clipboard
Feature: CLI options for bundle directory and program name
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.
- [x] Testing that
$STATICX_BUNDLE_DIRis the same as--bundle-dir. - [x] Testing that
basename $0is the same as--prog-name.
CLI
- [x] Added option
--bundle-dirwith help message. - [x] Added option
--prog-namewith help message.
Documentation
- [x] Added
--bundle-dirand--prog-nameunder thedocs/usage.rst. - [x] Updated old python functions docstrings to include
--bundle-dirand--prog-name. - [x] Documented new C functions
get_symlink,move_bundle, andfile_exists. - [x] Documented new Python function
add_bundle_dir_symlink.
Implementation
--prog-name
- [x] When adding the modified program to the archive, use
--prog-namewhen specified instead of thebasenameof positional argumentprog.
--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.
- [x] Add a symlink file to the archive for
--bundle-dir. - [x] In the bootloader, check if the file exists.
- [x] 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.