-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use static libraries from built image
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
- Loading branch information
Paulo Gomes
committed
Jan 26, 2022
1 parent
93c636e
commit 3a14cb8
Showing
3 changed files
with
73 additions
and
87 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,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
|
||
IMG_TAG="${IMG_TAG:-.}" | ||
|
||
function extract(){ | ||
PLATFORM=$1 | ||
DIR=$2 | ||
|
||
id=$(docker create --platform="${PLATFORM}" "${IMG_TAG}") | ||
docker cp "${id}":/usr/local - > output.tar.gz | ||
docker rm -v "${id}" | ||
|
||
tar -xf output.tar.gz "local/${DIR}" --strip-component=1 | ||
rm output.tar.gz | ||
} | ||
|
||
function setup() { | ||
PLATFORM=$1 | ||
DIR=$2 | ||
|
||
extract "${PLATFORM}" "${DIR}" | ||
|
||
NEW_DIR=$(realpath "./hack/libgit2") | ||
INSTALLED_DIR="/usr/local/${DIR}" | ||
|
||
mv "${DIR}" "libgit2" | ||
mv "libgit2" "./hack/" | ||
|
||
# Update the prefix paths included in the .pc files. | ||
# This will make it easier to update to the location in which they will be used. | ||
find "${NEW_DIR}" -type f -name "*.pc" | xargs -I {} sed -i "s;${INSTALLED_DIR};${NEW_DIR};g" {} | ||
} | ||
|
||
function setup_current() { | ||
if [ -d "./hack/libgit2" ]; then | ||
echo "Skipping libgit2 setup as it already exists" | ||
exit 0 | ||
fi | ||
|
||
DIR="x86_64-alpine-linux-musl" | ||
PLATFORM="linux/amd64" | ||
|
||
if [ "$(uname -m)" = "armv7l" ]; then | ||
DIR="armv7-alpine-linux-musleabihf" | ||
PLATFORM="linux/arm/v7" | ||
fi | ||
if [ "$(uname -m)" = "aarch64" ]; then | ||
DIR="aarch64-alpine-linux-musl" | ||
PLATFORM="linux/amd64" | ||
fi | ||
|
||
setup "${PLATFORM}" "${DIR}" | ||
} | ||
|
||
setup_current |