Skip to content

Commit

Permalink
ci: add script to update rootfs URL
Browse files Browse the repository at this point in the history
for Finch on Windows runfinch/finch#492, we need to provide a rootfs to WSL2. This
rootfs lives in our dependencies bucket, and will be updated from
time-to-time for security patches, bug fixes, etc. This commit will
automatically pull the most recent rootfs from the depenedencies bucket
as part of the Update Deps action.

Signed-off-by: Gavin Inglis <[email protected]>
  • Loading branch information
ginglis13 committed Jul 28, 2023
1 parent 2fc49cd commit ad71bb1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
- name: update dependencies url
run: |
./bin/update-deps.sh -d ${{ secrets.DEPENDENCY_BUCKET_NAME }}
./bin/update-rootfs.sh -d ${{ secrets.DEPENDENCY_BUCKET_NAME }}
- name: create PR
uses: peter-evans/create-pull-request@v5
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ ifneq (,$(findstring arm64,$(ARCH)))
FINCH_OS_IMAGE_URL := $(FINCH_OS_AARCH64_URL)
FINCH_OS_DIGEST ?= $(FINCH_OS_AARCH64_DIGEST)
HOMEBREW_PREFIX ?= /opt/homebrew

# TODO: Use Finch rootfs in Finch on Windows testing
FINCH_ROOTFS_URL ?= https://deps.runfinch.com/finch-rootfs-production-arm64-1690563031.tar.zst
else ifneq (,$(findstring x86_64,$(ARCH)))
LIMA_ARCH = x86_64
LIMA_URL ?= https://deps.runfinch.com/x86-64/lima-and-qemu.macos-x86_64.1689037160.tar.gz
FINCH_OS_BASENAME := $(notdir $(FINCH_OS_x86_URL))
FINCH_OS_IMAGE_URL := $(FINCH_OS_x86_URL)
FINCH_OS_DIGEST ?= $(FINCH_OS_x86_DIGEST)
HOMEBREW_PREFIX ?= /usr/local

# TODO: Use Finch rootfs in Finch on Windows testing
FINCH_ROOTFS_URL ?= https://deps.runfinch.com/finch-rootfs-production-amd64-1690563027.tar.zst
endif

FINCH_OS_IMAGE_LOCATION ?= $(OUTDIR)/os/$(FINCH_OS_BASENAME)
Expand Down
26 changes: 26 additions & 0 deletions bin/update-rootfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -euxo pipefail

DEPENDENCY_CLOUDFRONT_URL="https://deps.runfinch.com/"
AARCH64_FILENAME_PATTERN="finch-rootfs-production-arm64-[0-9].*\.tar.zst$"
AMD64_FILENAME_PATTERN="finch-rootfs-production-amd64-[0-9].*\.tar.zst$"

while getopts d: flag
do
case "${flag}" in
d) dependency_bucket=${OPTARG};;
esac
done

[[ -z "$dependency_bucket" ]] && { echo "Error: Dependency bucket not set"; exit 1; }

aarch64Deps=$(aws s3 ls s3://${dependency_bucket}/ | grep "$AARCH64_FILENAME_PATTERN" | sort | tail -n 1 | awk '{print $4}')

[[ -z "$aarch64Deps" ]] && { echo "Error: aarch64 dependency not found"; exit 1; }

amd64Deps=$(aws s3 ls s3://${dependency_bucket}/ | grep "$AMD64_FILENAME_PATTERN" | sort | tail -n 1 | awk '{print $4}')

[[ -z "$amd64Deps" ]] && { echo "Error: x86_64 dependency not found"; exit 1; }

sed -E -i.bak 's|^([[:blank:]]*FINCH_ROOTFS_URL[[:blank:]]*\?=[[:blank:]]*'${DEPENDENCY_CLOUDFRONT_URL}')('${AARCH64_FILENAME_PATTERN}')|\1'$aarch64Deps'|' Makefile
sed -E -i.bak 's|^([[:blank:]]*FINCH_ROOTFS_URL[[:blank:]]*\?=[[:blank:]]*'${DEPENDENCY_CLOUDFRONT_URL}')('${AMD64_FILENAME_PATTERN}')|\1'$amd64Deps'|' Makefile

0 comments on commit ad71bb1

Please sign in to comment.