From dd282500993041e6f2ab758b303f16b70fc30387 Mon Sep 17 00:00:00 2001 From: outofmemo Date: Wed, 5 Oct 2022 10:46:42 +0800 Subject: [PATCH] packelf.sh --- README.md | 20 ++++++++++++++++++++ packelf.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 README.md create mode 100755 packelf.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5a9e57 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +`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 ...] +``` + + + +## example + +``` +~ # packelf.sh `which perf` /root/perf +~ # /root/perf --version +perf version 3.10.0-1160.49.1.el7.x86_64.debug +``` + diff --git a/packelf.sh b/packelf.sh new file mode 100755 index 0000000..b82a6b3 --- /dev/null +++ b/packelf.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 + +cat >"$dst" <>"$dst" "$@" 2> >(grep -v 'Removing leading' >&2) +chmod +x "$dst"