Skip to content

Commit

Permalink
Merge pull request #1 from Vinetos/change-zfs-pool-name
Browse files Browse the repository at this point in the history
fix: Change ZFS pool name to build image on ZFS-enabled hosts
  • Loading branch information
kallioli authored May 6, 2024
2 parents 67a261f + 254a825 commit 8278369
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/create-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,41 @@ name: CI
on:
push:
tags:
- '*'
- '*'

# Allows you to run this workflow manually from the Actions tab
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: [self-hosted, freebsd]
runs-on: [ self-hosted, freebsd ]

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

- name: Get tag name
run: echo "REF_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV

- name: Debug
run: echo ${{ env.REF_NAME }}

# Run building script
- name: Run build.sh
run: |
export PATH=/usr/local/bin/:$PATH
sudo chmod +x build.sh
sudo ./build.sh ${{ env.REF_NAME }}
# Converting image
- name: Converting image to QCOW2 format
run: |
sudo qemu-img convert -f raw -O qcow2 -c -S 4k final.raw freebsd-${{ env.REF_NAME }}-amd64.qcow2
sudo md5sum freebsd-${{ env.REF_NAME }}-amd64.qcow2 > md5.txt
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -51,7 +52,7 @@ jobs:
prerelease: false

- name: Upload image to release asset
id: upload-release-asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 11 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env bash

version="${1:-13.0}"
repo="${2:-canonical/cloud-init}"
ref="${3:-main}"
Expand Down Expand Up @@ -38,12 +39,12 @@ function build {


if [ ${root_fs} = "zfs" ]; then
zpool create -o altroot=/mnt zroot ${md_dev}p4
zfs set compress=on zroot
zfs create -o mountpoint=none zroot/ROOT
zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/default
mount -t zfs zroot/ROOT/default /mnt
zpool set bootfs=zroot/ROOT/default zroot
zpool create -o altroot=/mnt zroot-mnt ${md_dev}p4
zfs set compress=on zroot-mnt
zfs create -o mountpoint=none zroot-mnt/ROOT
zfs create -o mountpoint=/ -o canmount=noauto zroot-mnt/ROOT/default
mount -t zfs zroot-mnt/ROOT/default /mnt
zpool set bootfs=zroot-mnt/ROOT/default zroot-mnt
else
newfs -U -L FreeBSD /dev/${md_dev}p4
mount /dev/${md_dev}p4 /mnt
Expand Down Expand Up @@ -103,9 +104,10 @@ touch /etc/rc.conf

if [ ${root_fs} = "zfs" ]; then
echo 'zfs_load="YES"' >> /mnt/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot/ROOT/default"' >> /mnt/boot/loader.conf
echo 'vfs.root.mountfrom="zfs:zroot-mnt/ROOT/default"' >> /mnt/boot/loader.conf
echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf

mkdir -p /mnt/etc/cloud

echo 'growpart:
mode: auto
Expand All @@ -121,8 +123,8 @@ touch /etc/rc.conf
ls /mnt/sbin
ls /mnt/sbin/init
zfs umount /mnt
zfs umount /mnt/zroot
zpool export zroot
zfs umount /mnt/zroot-mnt
zpool export zroot-mnt
else
umount /dev/${md_dev}p4
fi
Expand Down

0 comments on commit 8278369

Please sign in to comment.