mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-28 16:58:03 +01:00
ci: update packer-builder (#4017)
This commit is contained in:
parent
f5302c7409
commit
8bbdd957fb
5 changed files with 74 additions and 96 deletions
|
@ -163,12 +163,12 @@ The build_sdcard.sh is downloaded from the source branch and built with the opti
|
|||
The github workflow is running the job in an ubuntu-22.04 image.
|
||||
|
||||
The amd64 image is built with running a qemu VM
|
||||
* installs the base OS (Debian 11.5)
|
||||
* installs the base OS (Debian)
|
||||
* connects with ssh and runs the scripts including the build_sdcard.sh
|
||||
|
||||
The arm64-rpi image genenaration runs in Docker in github actions and without Docker locally.
|
||||
* the base image (RasberryOS) is started in the qemu VM
|
||||
* packer runs the build_sdcard.sh directly in the VM
|
||||
The arm64-rpi image generation runs in Docker in github actions and without Docker locally.
|
||||
* the base image (RaspberryOS) is started in the qemu VM
|
||||
* Packer runs the build_sdcard.sh directly in the VM
|
||||
|
||||
After the image is built (and there is no exit with errors) the next steps are:
|
||||
* compute checksum of the qemu/raw image
|
||||
|
|
|
@ -11,27 +11,11 @@ sudo apt-get install -y packer
|
|||
echo -e "\nInstalling qemu..."
|
||||
sudo apt-get install -y qemu-system
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
pack=$1
|
||||
else
|
||||
pack=lean
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
github_user=$2
|
||||
else
|
||||
github_user=rootzoll
|
||||
fi
|
||||
|
||||
if [ $# -gt 2 ]; then
|
||||
branch=$3
|
||||
else
|
||||
branch=dev
|
||||
fi
|
||||
# set vars
|
||||
source ../set_variables.sh
|
||||
set_variables "$@"
|
||||
|
||||
# Build the image
|
||||
echo -e "\nBuilding image..."
|
||||
cd debian
|
||||
PACKER_LOG=1 packer build \
|
||||
--var pack=${pack} --var github_user=${github_user} --var branch=${branch} \
|
||||
-only=qemu amd64-debian.json
|
||||
PACKER_LOG=1 packer build ${vars} -only=qemu amd64-debian.json
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
echo "\n# Install dependencies with apt"
|
||||
echo -e "\n# Install dependencies with apt"
|
||||
if [ "$(uname -n)" = "ubuntu" ]; then
|
||||
sudo add-apt-repository -y universe
|
||||
fi
|
||||
|
@ -36,44 +36,33 @@ fi
|
|||
|
||||
echo -e "\n# Install Go"
|
||||
export PATH=$PATH:/usr/local/go/bin
|
||||
if ! go version 2>/dev/null | grep "1.18.9"; then
|
||||
wget --progress=bar:force https://go.dev/dl/go1.18.9.linux-amd64.tar.gz
|
||||
echo "015692d2a48e3496f1da3328cf33337c727c595011883f6fc74f9b5a9c86ffa8 go1.18.9.linux-amd64.tar.gz" | sha256sum -c - || exit 1
|
||||
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.18.9.linux-amd64.tar.gz
|
||||
sudo rm -rf go1.18.9.linux-amd64.tar.gz
|
||||
# https://go.dev/dl/
|
||||
GOVERSION="1.20.6"
|
||||
GOHASH="b945ae2bb5db01a0fb4786afde64e6fbab50b67f6fa0eb6cfa4924f16a7ff1eb"
|
||||
if ! go version 2>/dev/null | grep "${GOVERSION}"; then
|
||||
wget --progress=bar:force https://go.dev/dl/go${GOVERSION}.linux-amd64.tar.gz
|
||||
echo "${GOHASH} go${GOVERSION}.linux-amd64.tar.gz" | sha256sum -c - || exit 1
|
||||
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go${GOVERSION}.linux-amd64.tar.gz
|
||||
sudo rm -rf go${GOVERSION}.linux-amd64.tar.gz
|
||||
else
|
||||
echo "# Go 1.18.9 is installed"
|
||||
echo "# Go ${GOVERSION} is installed"
|
||||
fi
|
||||
|
||||
echo -e "\n# Download the packer-builder-arm plugin"
|
||||
git clone https://github.com/mkaczanowski/packer-builder-arm
|
||||
cd packer-builder-arm
|
||||
# pin to commit hash https://github.com/mkaczanowski/packer-builder-arm/commits/master
|
||||
git reset --hard 6636c687ece53f7d1f5f2b35aa41f0e6132949c4
|
||||
# https://github.com/mkaczanowski/packer-builder-arm/releases
|
||||
git reset --hard "v1.0.7"
|
||||
echo -e "\n# Build the packer-builder-arm plugin"
|
||||
go mod download
|
||||
go build || exit 1
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
pack=$1
|
||||
else
|
||||
pack=lean
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
github_user=$2
|
||||
else
|
||||
github_user=rootzoll
|
||||
fi
|
||||
|
||||
if [ $# -gt 2 ]; then
|
||||
branch=$3
|
||||
else
|
||||
branch=dev
|
||||
fi
|
||||
# set vars
|
||||
source ../set_variables.sh
|
||||
set_variables "$@"
|
||||
|
||||
cp ../arm64-rpi.pkr.hcl ./
|
||||
cp ../raspiblitz.sh ./
|
||||
|
||||
echo -e "\n# Build the image"
|
||||
packer build -var github_user=${github_user} -var branch=${branch} -var pack=${pack} arm64-rpi.pkr.hcl
|
||||
packer build ${vars} arm64-rpi.pkr.hcl
|
||||
|
|
|
@ -1,53 +1,12 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
pack=$1
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
github_user=$2
|
||||
fi
|
||||
|
||||
if [ $# -gt 2 ]; then
|
||||
branch=$3
|
||||
fi
|
||||
|
||||
if [ $# -gt 4 ]; then
|
||||
image_link="$4"
|
||||
image_checksum="$5"
|
||||
fi
|
||||
|
||||
# Initialize the variables string
|
||||
vars=""
|
||||
|
||||
# Add the pack variable if it is defined
|
||||
if [ -n "${pack}" ]; then
|
||||
vars="$vars -var pack=${pack}"
|
||||
fi
|
||||
|
||||
# Add the github_user variable if it is defined
|
||||
if [ -n "${github_user}" ]; then
|
||||
vars="$vars -var github_user=${github_user}"
|
||||
fi
|
||||
|
||||
# Add the branch variable if it is defined
|
||||
if [ -n "${branch}" ]; then
|
||||
vars="$vars -var branch=${branch}"
|
||||
fi
|
||||
|
||||
# Add the image_link variable if it is defined
|
||||
if [ -n "${image_link}" ]; then
|
||||
vars="$vars -var image_link=${image_link}"
|
||||
fi
|
||||
|
||||
# Add the image_checksum variable if it is defined
|
||||
if [ -n "${image_checksum}" ]; then
|
||||
vars="$vars -var image_checksum=${image_checksum}"
|
||||
fi
|
||||
# set vars
|
||||
source ../set_variables.sh
|
||||
set_variables "$@"
|
||||
|
||||
# Build the image in docker
|
||||
echo -e "\nBuild Packer image..."
|
||||
# from https://hub.docker.com/r/mkaczanowski/packer-builder-arm/tags
|
||||
docker run --rm --privileged -v /dev:/dev -v ${PWD}:/build \
|
||||
mkaczanowski/packer-builder-arm:1.0.6@sha256:ca758415f498e6d4a1d7e82380d6f166d97262cb44af624ff586e6a6c96ad795 \
|
||||
mkaczanowski/packer-builder-arm@sha256:0ff8ce0cf33e37be6c351c8bcb2643835c7f3525b7f591808b91c04238d45695 \
|
||||
build ${vars} arm64-rpi.pkr.hcl
|
||||
|
|
46
ci/set_variables.sh
Normal file
46
ci/set_variables.sh
Normal file
|
@ -0,0 +1,46 @@
|
|||
function set_variables() {
|
||||
if [ $# -gt 0 ]; then
|
||||
pack=$1
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
github_user=$2
|
||||
fi
|
||||
|
||||
if [ $# -gt 2 ]; then
|
||||
branch=$3
|
||||
fi
|
||||
|
||||
if [ $# -gt 4 ]; then
|
||||
image_link="$4"
|
||||
image_checksum="$5"
|
||||
fi
|
||||
|
||||
# Initialize the variables string
|
||||
vars=""
|
||||
|
||||
# Add the pack variable if it is defined
|
||||
if [ -n "${pack}" ]; then
|
||||
vars="$vars -var pack=${pack}"
|
||||
fi
|
||||
|
||||
# Add the github_user variable if it is defined
|
||||
if [ -n "${github_user}" ]; then
|
||||
vars="$vars -var github_user=${github_user}"
|
||||
fi
|
||||
|
||||
# Add the branch variable if it is defined
|
||||
if [ -n "${branch}" ]; then
|
||||
vars="$vars -var branch=${branch}"
|
||||
fi
|
||||
|
||||
# Add the image_link variable if it is defined
|
||||
if [ -n "${image_link}" ]; then
|
||||
vars="$vars -var image_link=${image_link}"
|
||||
fi
|
||||
|
||||
# Add the image_checksum variable if it is defined
|
||||
if [ -n "${image_checksum}" ]; then
|
||||
vars="$vars -var image_checksum=${image_checksum}"
|
||||
fi
|
||||
}
|
Loading…
Add table
Reference in a new issue