diff --git a/README.md b/README.md index f5a9e57..b084bcd 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,25 @@ `packelf` was inspired by [the idea of Klaus D](https://askubuntu.com/a/546305). It is used to package the elf executable and its dependent libraries into a single executable. - - ## usage ``` packelf.sh [ADDITIONAL_LIBS ...] ``` +Requirements on the machine: `touch`, `tar`, `sh` and `mktemp` +``` +packelf-kf.sh [ADDITIONAL_LIBS ...] +``` + +Requirements on the machine: `tar`, `sh` and `mkdir` + +This other version doens't extract everytime the package if already exists. +Perfect for tiny packages. + +## how works + +Generate a tar that include all the llibraries from the host, with a tiny shell script embedded use LS Preload to execute the program. ## example diff --git a/packelf-kf.sh b/packelf-kf.sh new file mode 100755 index 0000000..84a69b2 --- /dev/null +++ b/packelf-kf.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -eo pipefail + +[ $# -lt 2 ] && { + echo "usage: $0 [ADDITIONAL_LIBS ...]" + exit 1 +} + +src="$1" +dst="$2" +shift +shift + +libs="$(ldd "$src" | grep -F '/' | sed -E 's|[^/]*/([^ ]+).*?|/\1|')" +ld_so="$(echo "$libs" | grep -F '/ld-linux-')" +ld_so="$(basename "$ld_so")" +program="$(basename "$src")" + +cat >"$dst" <>"$dst" 2> >(grep -v 'Removing leading' >&2) +chmod +x "$dst" diff --git a/packelf.sh b/packelf.sh index f5ab6de..dca8a3a 100755 --- a/packelf.sh +++ b/packelf.sh @@ -17,7 +17,7 @@ ld_so="$(basename "$ld_so")" program="$(basename "$src")" cat >"$dst" <