VHSgunzo / sharun

Run dynamically linked ELF binaries everywhere
MIT License
16 stars 2 forks source link
appimage rust

sharun

Run dynamically linked ELF binaries everywhere (musl and glibc are supported).

sharun

Supported architectures:

To get started:

Usage sharun:

[ Usage ]: sharun [OPTIONS] [EXEC ARGS]...
    Use lib4bin for create 'bin' and 'shared' dirs

[ Arguments ]:
    [EXEC ARGS]...              Command line arguments for execution

[ Options ]:
     l,  lib4bin [ARGS]         Launch the built-in lib4bin
    -g,  --gen-lib-path         Generate library path file
    -v,  --version              Print version
    -h,  --help                 Print help

[ Environments ]:
    SHARUN_WORKING_DIR=/path    Specifies the path to the working directory
    SHARUN_LDNAME=ld.so         Specifies the name of the interpreter
    SHARUN_DIR                  Sharun directory

Usage lib4bin:

[ Usage ]: lib4bin [OPTIONS] /path/executable -- [STRACE CMD ARGS]

[ Options ]:
  -a, --any-executable     Pack any executable (env: ANY_EXECUTABLE=1)
  -d, --dst-dir '/path'    Destination directory (env: DST_DIR=/path)
  -e, --strace-mode        Use strace for get libs (env: STRACE_MODE=1, STRACE_TIME=5)
  -g, --gen-lib-path       Generate a lib.path file (env: GEN_LIB_PATH=1)
  -h, --help               Show this message
  -i, --patch-interpreter  Patch INTERPRETER to a relative path (env: PATCH_INTERPRETER=1)
  -l, --libs-only          Pack only libraries (env: LIBS_ONLY=1)
  -n, --not-one-dir        Separate directories for each executable (env: ONE_DIR=0)
  -p, --hard-links         Pack sharun and create hard links (env: HARD_LINKS=1)
  -q, --quiet-mode         Show only errors (env: QUIET_MODE=1)
  -r, --patch-rpath        Patch RPATH to a relative path (env: PATCH_RPATH=1)
  -s, --strip              Strip binaries and libraries (env: STRIP=1)
  -v, --verbose            Verbose mode (env: VERBOSE=1)
  -w, --with-sharun        Pack sharun from PATH or env or download 
  (env: WITH_SHARUN=1, SHARUN=/path|URL, SHARUN_URL=URL, UPX_SHARUN=1)

Examples:

# run lib4bin with the paths to the binary files that you want to make portable
./sharun lib4bin --with-sharun --dst-dir test /bin/bash

# or for correct /proc/self/exe you can use --hard-links flag
./sharun lib4bin --hard-links --dst-dir test /bin/bash
# this will create hard links from 'test/sharun' in the 'test/bin' directory

# now you can move 'test' dir to other linux system and run binaries from the 'bin' dir
./test/bin/bash --version

# or specify them as an argument to 'sharun'
./test/sharun bash --version

Screenshots:

tree

Environment variables that are set if sharun finds a directory or file:

Projects that use sharun:

References