mirror of
https://github.com/certbot/certbot.git
synced 2026-06-09 00:32:12 -04:00
Various optimizations
This commit is contained in:
parent
44f0524b7f
commit
80ec562f44
5 changed files with 79 additions and 70 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -59,4 +59,4 @@ prime
|
|||
stage
|
||||
*.snap
|
||||
snap-constraints.txt
|
||||
qemu-*
|
||||
qemu-*
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ if [[ -z "${SNAP_ARCH}" ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
"${SCRIPT_DIR}/builder/prepare.sh" "${SNAP_ARCH}"
|
||||
source "${DIR}/builder/common.sh"
|
||||
|
||||
docker run --net=host -d --rm -v "${SCRIPT_DIR}/packages:/data/packages" --name pypiserver pypiserver/pypiserver
|
||||
"${DIR}/builder/prepare.sh" "${SNAP_ARCH}"
|
||||
|
||||
docker run --net=host -d --rm -v "${DIR}/packages:/data/packages" --name pypiserver pypiserver/pypiserver
|
||||
tools/strip_hashes.py letsencrypt-auto-source/pieces/dependency-requirements.txt > snap-constraints.txt
|
||||
|
||||
function cleanup() {
|
||||
|
|
@ -34,3 +36,7 @@ docker run \
|
|||
-e "PIP_EXTRA_INDEX_URL=http://localhost:8080/simple" \
|
||||
-t "builder:${SNAP_ARCH}" \
|
||||
snapcraft
|
||||
|
||||
if [[ "$(arch)" == "$(GetQemuArch "${SNAP_ARCH}")" ]]; then
|
||||
sudo snap install --dangerous --classic *.snap
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ COPY qemu-${QEMU_ARCH}-static /usr/bin/
|
|||
|
||||
# Grab dependencies
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates curl jq squashfs-tools \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl jq squashfs-tools \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG SNAP_ARCH
|
||||
|
|
@ -47,7 +47,7 @@ COPY --from=builder /snap/bin/snapcraft /snap/bin/snapcraft
|
|||
|
||||
# Generate locale and add runtime dependencies
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends sudo locales git \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends sudo locales git \
|
||||
&& locale-gen en_US.UTF-8 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
|
|
|
|||
66
snap/local/builder/common.sh
Normal file
66
snap/local/builder/common.sh
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Returns the translation from Snap architecture to Docker architecture
|
||||
# Usage: GetQemuArch [amd64|arm64|armhf]
|
||||
GetDockerArch() {
|
||||
SNAP_ARCH=$1
|
||||
|
||||
case "${SNAP_ARCH}" in
|
||||
"amd64")
|
||||
echo "amd64"
|
||||
;;
|
||||
"arm64")
|
||||
echo "arm64v8"
|
||||
;;
|
||||
"armhf")
|
||||
echo "arm32v7"
|
||||
;;
|
||||
"*")
|
||||
echo "Not supported build architecture '$1'." >&2
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
# Returns the translation from Snap architecture to QEMU architecture
|
||||
# Usage: GetQemuArch [amd64|arm64|armhf]
|
||||
GetQemuArch() {
|
||||
SNAP_ARCH=$1
|
||||
|
||||
case "${SNAP_ARCH}" in
|
||||
"amd64")
|
||||
echo "x86_64"
|
||||
;;
|
||||
"arm64")
|
||||
echo "aarch64"
|
||||
;;
|
||||
"armhf")
|
||||
echo "arm"
|
||||
;;
|
||||
"*")
|
||||
echo "Not supported build architecture '$1'." >&2
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
# Downloads QEMU static binary file for architecture
|
||||
# Usage: DownloadQemuStatic [x86_64|aarch64|arm]
|
||||
DownloadQemuStatic() {
|
||||
QEMU_ARCH=$1
|
||||
|
||||
if [ ! -f "${DIR}/qemu-${QEMU_ARCH}-static" ]; then
|
||||
QEMU_DOWNLOAD_URL="https://github.com/multiarch/qemu-user-static/releases/download"
|
||||
QEMU_LATEST_TAG=$(curl -s https://api.github.com/repos/multiarch/qemu-user-static/tags \
|
||||
| grep 'name.*v[0-9]' \
|
||||
| head -n 1 \
|
||||
| cut -d '"' -f 4)
|
||||
echo "${QEMU_DOWNLOAD_URL}/${QEMU_LATEST_TAG}/x86_64_qemu-${QEMU_ARCH}-static.tar.gz"
|
||||
curl -SL "${QEMU_DOWNLOAD_URL}/${QEMU_LATEST_TAG}/x86_64_qemu-${QEMU_ARCH}-static.tar.gz" \
|
||||
| tar xzv -C "${DIR}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Executes the QEMU register script
|
||||
# Usage: RegisterQemuHandlers
|
||||
RegisterQemuHandlers() {
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
}
|
||||
|
|
@ -3,70 +3,7 @@ set -e
|
|||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
# Returns the translation from Snap architecture to Docker architecture
|
||||
# Usage: GetQemuArch [amd64|arm64|armhf]
|
||||
GetDockerArch() {
|
||||
SNAP_ARCH=$1
|
||||
|
||||
case "${SNAP_ARCH}" in
|
||||
"amd64")
|
||||
echo "amd64"
|
||||
;;
|
||||
"arm64")
|
||||
echo "arm64v8"
|
||||
;;
|
||||
"armhf")
|
||||
echo "arm32v7"
|
||||
;;
|
||||
"*")
|
||||
echo "Not supported build architecture '$1'." >&2
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
# Returns the translation from Snap architecture to QEMU architecture
|
||||
# Usage: GetQemuArch [amd64|arm64|armhf]
|
||||
GetQemuArch() {
|
||||
SNAP_ARCH=$1
|
||||
|
||||
case "${SNAP_ARCH}" in
|
||||
"amd64")
|
||||
echo "x86_64"
|
||||
;;
|
||||
"arm64")
|
||||
echo "aarch64"
|
||||
;;
|
||||
"armhf")
|
||||
echo "arm"
|
||||
;;
|
||||
"*")
|
||||
echo "Not supported build architecture '$1'." >&2
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
# Downloads QEMU static binary file for architecture
|
||||
# Usage: DownloadQemuStatic [x86_64|aarch64|arm]
|
||||
DownloadQemuStatic() {
|
||||
QEMU_ARCH=$1
|
||||
|
||||
if [ ! -f "${DIR}/qemu-${QEMU_ARCH}-static" ]; then
|
||||
QEMU_DOWNLOAD_URL="https://github.com/multiarch/qemu-user-static/releases/download"
|
||||
QEMU_LATEST_TAG=$(curl -s https://api.github.com/repos/multiarch/qemu-user-static/tags \
|
||||
| grep 'name.*v[0-9]' \
|
||||
| head -n 1 \
|
||||
| cut -d '"' -f 4)
|
||||
echo "${QEMU_DOWNLOAD_URL}/${QEMU_LATEST_TAG}/x86_64_qemu-${QEMU_ARCH}-static.tar.gz"
|
||||
curl -SL "${QEMU_DOWNLOAD_URL}/${QEMU_LATEST_TAG}/x86_64_qemu-${QEMU_ARCH}-static.tar.gz" \
|
||||
| tar xzv -C "${DIR}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Executes the QEMU register script
|
||||
# Usage: RegisterQemuHandlers
|
||||
RegisterQemuHandlers() {
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
}
|
||||
source "${DIR}/common.sh"
|
||||
|
||||
SNAP_ARCH=$1
|
||||
TARGET_ARCH=$(GetDockerArch "${SNAP_ARCH}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue