-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This streamlines the resulting archive in three ways: 1. It only includes mcrouter and mcpiper from /bin (no thrift, zfmt, etc) 2. It only includes the libraries that mcrouter and mcpiper actually link against. This removes a bunch of boost libraries from the archive. 3. It includes the dynamic libraries not only from INSTALL_DIR, but also from the host system (e.g. libssl and libz). This archive is *NOT PORTABLE* in any meaningful way, it is only meant to run on essentially the same target system, amazon linux 2.
- Loading branch information
Paul Groudas
committed
May 21, 2021
1 parent
4a245b9
commit 5fa72da
Showing
3 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This creates an archive suitable for distribution to other hosts with the same system. | ||
|
||
set -euo pipefail | ||
|
||
INSTALL_DIR="$1" | ||
ARCHIVE="$2" | ||
|
||
function die() { | ||
printf "%s: %s\n" "$0" "$@" | ||
exit 1 | ||
} | ||
|
||
[ -n "$1" ] || die "INSTALL_DIR missing" | ||
[ -n "$2" ] || die "ARCHIVE missing" | ||
|
||
ARCHIVE_INSTALL_DIR=$(mktemp -d) | ||
mkdir "${ARCHIVE_INSTALL_DIR}"/lib | ||
mkdir "${ARCHIVE_INSTALL_DIR}"/bin | ||
|
||
# This expression uses "ldd" to locate all dynamically linked library dependencies. | ||
# We then copy them to a tempdir so we can simply create an archive of only the needed dependencies. | ||
# This will suck in libraries both from the "compiled from source" libraries (e.g. folly, thrift) as libraries | ||
# from the host system. | ||
|
||
LD_LIBRARY_PATH="${INSTALL_DIR}"/lib ldd "${INSTALL_DIR}"/bin/mcrouter "${INSTALL_DIR}"/bin/mcpiper \ | ||
| grep "=>" | tr -s "[:blank:]" " " | cut -d " " -f 4 | sort -u \ | ||
| xargs -I '%' cp '%' "${ARCHIVE_INSTALL_DIR}"/lib | ||
cp "${INSTALL_DIR}"/bin/mcrouter "${INSTALL_DIR}"/bin/mcpiper "${ARCHIVE_INSTALL_DIR}"/bin/ | ||
|
||
tar czfv "${ARCHIVE}" -C "${ARCHIVE_INSTALL_DIR}" . |