WIP for #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:
# ./myprog 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_DIR is the same as --bundle-dir.
[x] Testing that basename $0 is the same as --prog-name.
CLI
[x] Added option --bundle-dir with help message.
[x] Added option --prog-name with help message.
Documentation
[x] Added --bundle-dir and --prog-name under the docs/usage.rst.
[x] Updated old python functions docstrings to include --bundle-dir and --prog-name.
[x] Documented new C functions get_symlink, move_bundle, and file_exists.
[x] Documented new Python function add_bundle_dir_symlink.
Implementation
--prog-name
[x] 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.
[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.
WIP for #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:Checklist
Testing
Testing done in
test/bundle-dir-prog-name.sh
.$STATICX_BUNDLE_DIR
is the same as--bundle-dir
.basename $0
is the same as--prog-name
.CLI
--bundle-dir
with help message.--prog-name
with help message.Documentation
--bundle-dir
and--prog-name
under thedocs/usage.rst
.--bundle-dir
and--prog-name
.get_symlink
,move_bundle
, andfile_exists
.add_bundle_dir_symlink
.Implementation
--prog-name
--prog-name
when specified instead of thebasename
of 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.--bundle-dir
.