27 Commits

Author SHA1 Message Date
f7987c3566 separate stop and rm 2025-12-19 13:40:02 +01:00
1ff66bcc45 no tac, use sed 2025-12-19 13:39:09 +01:00
d631e68422 only download once 2025-12-19 13:37:34 +01:00
606fc443fb fix umount 2025-12-19 13:36:26 +01:00
6b6815ab41 fix while loop 2025-12-19 13:34:32 +01:00
e187d49927 umount directly 2025-12-19 13:33:56 +01:00
895508b607 also uninstall 2025-12-19 13:31:22 +01:00
da863a96c1 fix cleanup: stop jail before rm 2025-12-19 13:29:55 +01:00
b6b11429f9 not needed anymore 2025-12-19 13:19:31 +01:00
7cbeadfcb0 fix link 2025-12-19 13:17:50 +01:00
f0ce477bb5 make rw before removing 2025-12-19 13:15:52 +01:00
16913d7c7d fix release name 2025-12-19 13:14:49 +01:00
4c28358936 fix vars 2025-12-19 13:11:25 +01:00
7284e90f01 add cpdup 2025-12-19 13:09:31 +01:00
c3544b8583 add docs and pipeline 2025-12-19 13:07:48 +01:00
ebee19e121 try local backend 2025-12-19 11:30:59 +01:00
6c9d025ff4 fix platform 2025-12-19 11:18:13 +01:00
928b6ec5c3 spacing 2025-12-19 11:17:35 +01:00
d032f45cbf use snap image 2025-12-19 11:12:29 +01:00
e69d2acc3c try freebsd agent 2025-12-19 11:06:43 +01:00
T. von Dein
6732d4e9b2 add build-base (#36) 2025-12-19 10:40:15 +01:00
09fe6c8df3 add release 2025-12-19 10:35:26 +01:00
13c3e3ea9b fix ci yaml path 2025-12-19 08:28:58 +01:00
61fc7342e3 add gh badge 2025-12-19 08:27:43 +01:00
e9a258223f use 14.3, 14.1 no longer available 2025-12-19 08:17:11 +01:00
9cabd79f98 run ci on github on main 2025-12-19 08:07:52 +01:00
T. von Dein
eabec94945 move to codeberg (#35) 2025-12-16 20:01:40 +01:00
8 changed files with 243 additions and 52 deletions

View File

@@ -1,52 +0,0 @@
name: Test-Jaildk
on: [push]
jobs:
test:
runs-on: ubuntu-latest
name: Test jaildk on FreeBSD
steps:
- name: checkout
uses: actions/checkout@v4
- name: Test in FreeBSD
uses: vmactions/freebsd-vm@v1
id: testjaildk
with:
release: "14.1"
usesh: true
prepare: |
pkg install -y curl cpdup
run: |
freebsd-version
sysctl hw.model
sysctl hw.ncpu
sysctl hw.physmem
sysctl hw.usermem
ls -la
ifconfig em0 172.16.0.1/32 alias
ifconfig -a
set -x -e
sysrc jail_enable="YES"
cp .github/assets/jail.conf /etc/
cp src/jaildk.sh jaildk
sh jaildk setup /jail
fetch https://download.freebsd.org/ftp/releases/amd64/amd64/14.1-RELEASE/base.txz -o /jail/base/14.1-RELEASE-base.txz
mkdir -p /jail/base/14.1-RELEASE
tar -xf /jail/base/14.1-RELEASE-base.txz -C /jail/base/14.1-RELEASE --unlink
/jail/bin/jaildk create test
ls -l /jail/etc/test
/jail/bin/jaildk build test -m start
df -h /jail/build/test/etc
echo 'sshd_enable="Yes"' > /jail/build/test/usr/local/etc/rc.conf
chroot /jail/build/test /etc/rc.d/sshd keygen
/jail/bin/jaildk start test
/jail/bin/jaildk status | grep -E "test|Jail"

67
.woodpecker/README.md Normal file
View File

@@ -0,0 +1,67 @@
## Running CI Tests with Woodpecker-CI on FreeBSD
By default the woodpecker intance on Codeberg doesn't support
FreeBSD. Running FreeBSD inside a qemu VM in a linux docker image
didn't work. Also, this particular tool needs to run outside a jail,
since it is a jail management tool.
So, this is my setup:
I deployed a freebsd VM on Hetzner Cloud: `ci-agent.daemon.de`. It
runs the `woodpecker-agent` build for freebsd. The agent runs as rool
directly on the host. This is a security risk and the reason why we
use a VM.
The VM does **NOT** run continuously. So in order to execute
workflows, first unsuspend the VM:
```default
hcloud server poweron ci-agent
```
When it's running, execute workflows (i.e. push).
## Setup
Deploy a new FreeBSD VM using the latest freebsd-snapshot.
Upgrade to latest Release (or the one you want to run tests on).
Clone [woodpecker-ci](https://github.com/woodpecker-ci/woodpecker).
Execute:
```default
make build-agent GOOS=freebsd
```
Clone [plugin-git](https://github.com/woodpecker-ci/plugin-git.git)
Execute:
```default
GOOS=freebsd go build
```
Copy the newly built binaries `dist/woodpecker-agent` into the VM to
`/usr/local/bin`.
```default
scp woodpecker-ci/dist/woodpecker-agent agent:/usr/local/bin/
scp plugin-git/plugin-git agent:/usr/local/bin/
```
Add the agent token to `/etc/rc.conf`:
```sh
woodpeckeragent_enable=YES
woodpeckeragent_token=*****
```
Create the [rc-Script](woodpeckeragent.sh) in
`/usr/local/etc/rc.d/woodpeckeragent`.
Install `git-lfs`: `pkg install bash cpdup git git-lfs`.
Start it: `service woodpeckeragent start`

55
.woodpecker/build.yaml Normal file
View File

@@ -0,0 +1,55 @@
#
# CAUTION: this pipeline needs a FreeBSD VM, refer for the README.md
# in this directory for details!
matrix:
release:
- 14.3-RELEASE-p7
releaselink:
- 14.3-RELEASE
labels:
platform: freebsd/amd64
steps:
test:
image: bash
when:
event: [push]
commands:
- freebsd-version
- uname -a
- sysctl hw.model
- sysctl hw.ncpu
- sysctl hw.physmem
- sysctl hw.usermem
# clean up earlier runs, if any
- if jls | grep -q test; then jail -r test; fi
- mount | cut -d' ' -f3 | grep /jail | sed '1!G;h;$!d' | while read D; do umount $D; done
- chflags -R noschg /jail
- rm -rf /jail
- ifconfig vtnet0 172.16.0.1/32 alias
- ifconfig vtnet0
- sysrc jail_enable="YES"
- cp .woodpecker/assets/jail.conf /etc/
- cp src/jaildk.sh jaildk
- sh jaildk setup /jail
- if ! test -e /jail/base/${release}-base.txz; then fetch https://download.freebsd.org/ftp/releases/amd64/amd64/${releaselink}/base.txz -o /jail/base/${release}-base.txz; fi
- mkdir -p /jail/base/${release}
- tar -xf /jail/base/${release}-base.txz -C /jail/base/${release} --unlink
- /jail/bin/jaildk create test
- ls -l /jail/etc/test
- /jail/bin/jaildk build test -m start
- df -h /jail/build/test/etc
- echo 'sshd_enable="Yes"' > /jail/build/test/usr/local/etc/rc.conf
- chroot /jail/build/test /etc/rc.d/sshd keygen
- /jail/bin/jaildk start test
- /jail/bin/jaildk status | grep -E "test|Jail"

54
.woodpecker/release.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
# This is my own simple codeberg generic releaser. It takes to
# binaries to be uploaded as arguments and takes every other args from
# env. Works on tags or normal commits (push), tags must start with v.
set -e
die() {
echo $*
exit 1
}
if test -z "$DEPLOY_TOKEN"; then
die "token DEPLOY_TOKEN not set"
fi
git fetch --all
# determine current tag or commit hash
version="$CI_COMMIT_TAG"
previous=""
log=""
if test -z "$version"; then
version="${CI_COMMIT_SHA:0:6}"
log=$(git log -1 --oneline)
else
previous=$(git tag -l | grep -E "^v" | tac | grep -A1 "$version" | tail -1)
log=$(git log -1 --oneline "${previous}..${version}" | sed 's|^|- |g')
fi
# release body
printf "# Changes\n\n %s\n" "$log" > body.txt
# create the release
https --ignore-stdin --check-status -b -A bearer -a "$DEPLOY_TOKEN" POST \
"https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases" \
tag_name="$version" name="Release $version" body=@body.txt > release.json
# we need the id to upload files
ID=$(jq -r .id < release.json)
if test -z "$ID"; then
cat release.json
die "failed to create release"
fi
# actually upload
for file in "$@"; do
https --ignore-stdin --check-status -A bearer -a "$DEPLOY_TOKEN" -f POST \
"https://codeberg.org/api/v1/repos/${CI_REPO_OWNER}/${CI_REPO_NAME}/releases/$ID/assets" \
"name=${file}" "attachment@${file}"
done

28
.woodpecker/release.yaml Normal file
View File

@@ -0,0 +1,28 @@
# build release
labels:
platform: linux/amd64
steps:
compile:
when:
event: [tag,manual]
image: alpine:latest
commands:
- apk update
- apk add --no-cache bash git build-base
- make
- file ${CI_REPO_NAME}
- mv ${CI_REPO_NAME} ${CI_REPO_NAME}-freebsd-all-$CI_COMMIT_TAG
release:
image: alpine:latest
when:
event: [tag,manual]
environment:
DEPLOY_TOKEN:
from_secret: DEPLOY_TOKEN
commands:
- apk update
- apk add --no-cache bash httpie jq git
- .woodpecker/release.sh ${CI_REPO_NAME}-*

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# PROVIDE: woodpeckeragent
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# woodpeckeragent_enable (bool): Set to NO by default.
# Set it to YES to enable woodpeckeragent.
. /etc/rc.subr
name=woodpeckeragent
rcvar=woodpeckeragent_enable
load_rc_config $name
: ${woodpeckeragent_enable:="NO"}
: ${woodpeckeragent_token:="foo"}
: ${woodpeckeragent_server:="grpc.ci.codeberg.org"}
pidfile=/var/run/woodpeckeragent.pid
command="/usr/sbin/daemon"
procname="/usr/local/bin/woodpecker-agent"
command_args="-f -p ${pidfile} -T ${name} \
/usr/bin/env PATH=$PATH:/usr/local/bin ${procname} \
--server ${woodpeckeragent_server} \
--grpc-token ${woodpeckeragent_token} \
--grpc-secure true \
--agent-config /tmp/woodpecker-agent \
--log-level debug"
load_rc_config $name
run_rc_command "$1"

View File

@@ -1,3 +1,5 @@
[![Test status](https://github.com/tlinden/jaildk/actions/workflows/ci.yaml/badge.svg)](https://github.com/tlinden/jaildk/actions/)
## jaildk - a FreeBSD jail development kit v2.0.4 ## jaildk - a FreeBSD jail development kit v2.0.4
## Breaking Changes ## Breaking Changes