-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexport.sh
More file actions
executable file
·33 lines (28 loc) · 1.15 KB
/
export.sh
File metadata and controls
executable file
·33 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -euo pipefail
ROOTDIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")/../")
export ROOTDIR
cd "$ROOTDIR"
source "./includes/utils.sh"
ARCH="${1:-}"
if [[ "$ARCH" != "x86_64" && "$ARCH" != "arm64" ]]; then
fatal 129 "Missing architecture argument"
fi
GIT_VERSION="$(cat ./git_version)"
step "Generating layer zip from ${ARCH} image"
filename="layer-git-${GIT_VERSION}-${ARCH}.zip"
if [[ -f "outputs/${filename}" ]]; then
info "Skipping extraction, layer zip already exists (${filename})"
else
info "Extracting /opt using a temporary Docker container"
rm -rf .cache
docker run --rm -v "${ROOTDIR}/.cache:/tmp/layer" lambda-git-build:${GIT_VERSION}-${ARCH} bash -c \
"cd /opt && zip -yr /tmp/layer/layer.zip ." >docker-run.log 2>&1 \
|| fatal 133 "Unable to extract layer data. Refer to ${ROOTDIR}/docker-run.log for details."
rm -f docker-run.log
info "Moving extracted data into target directory"
mkdir -p outputs
mv .cache/layer.zip outputs/${filename} || fatal 134 "Unable to move layer zip to target directory"
rm -rf .cache
fi
info "layer-git-${GIT_VERSION}-${ARCH}.zip created successfully"