Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0a1f701
OpenBSD: add 6.6 support
goneri Dec 28, 2019
4af0aa1
OpenBSD: ability to resize wd0 disk too
goneri Dec 28, 2019
1428902
OpenBSD: enable the serial console
goneri Dec 28, 2019
33fd72e
OpenBSD: enable the serial console
goneri Dec 28, 2019
fba1044
OpenBSD: Write the /etc/installurl file
goneri Dec 28, 2019
377c7d1
OpenBSD: experimental cloud-init package
goneri Dec 28, 2019
ee1c1d1
doc: explain how to build the OpenBSD image
goneri Dec 28, 2019
39f5f01
OpenBSD: simplify the growfs image generation
goneri Dec 29, 2019
ad9f409
add entry-point for Cloud-Init BSD CI
goneri Dec 29, 2019
bb5e570
build.sh: add version parameter
goneri Dec 30, 2019
ae78ef1
OpenBSD: use the CDN in installurl
goneri Jan 1, 2020
2d27020
run cloud-init before 79-resolv-conf.sh
goneri Jan 1, 2020
4b729b9
blabla
goneri Feb 23, 2020
6666229
rename 99-root-pw.sh
goneri Feb 23, 2020
3a3e2a6
pass debug through a var
goneri Feb 25, 2020
4edfd35
disable root account
goneri Mar 28, 2020
c79b94d
enable getty on serial console
goneri Mar 28, 2020
7f400ef
openbsd: refresh relink checksum
goneri Mar 29, 2020
96e3548
cloud-init: guess os version from the current kernel
goneri Aug 5, 2020
7368ea6
support BSD 6.9
goneri May 9, 2021
f1b349a
do not redirect term on serial console
goneri Dec 1, 2021
33eff42
cloud-init: use the main branch
goneri Dec 4, 2021
9da8978
openbsd: run cloud-init from /etc/rc.local
goneri Dec 4, 2021
bb54e62
openbsd: generate a relink file without the tempdir prefix
goneri Dec 4, 2021
d0d0774
Revert "do not redirect term on serial console"
goneri Dec 11, 2021
295d1f7
boot: avoid the 5s timeout
goneri Dec 11, 2021
87f18b0
no more OpenBSD dir on UWaterloo mirror
goneri Dec 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions OpenBSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Build OpenBSD 6.6 image
=======================

```shell
sudo pkg_add coreutils bash gsed flock bash
git clone https://github.com/goneri/pcib
cd pcib
sudo mkdir /var/cache/pcib
sudo ./bin/pcib --config examples/openstack-openbsd66
```
43 changes: 43 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# entry-point for the Cloud-Init BSD CI
version=$1
repo=$2
ref=$3
debug=$4
if [ -z "$version" ]; then
version="12.1"
fi
if [ -z "${repo}" ]; then
repo="canonical/cloud-init"
fi
if [ -z "${ref}" ]; then
ref="master"
fi
if [ -z "${debug}" ]; then
debug=""
fi
set -eux


echo "os=openbsd
mirror=https://openbsd.cs.toronto.edu/pub/OpenBSD
arch=amd64
release=${version}

plugin=base/bootable
dhcp-interface=vio0

plugin=base/raw-image-file
image-basename=openstack-openbsd${version}
image-size=2

plugin=partitioner/disklabel
plugin=package/cloud-init
plugin=fs/ffs
plugin=package/sshd" > /tmp/openstack-openbsd


mkdir -p ~/builder
sudo mkdir -p /var/cache/pcib
sudo ./bin/pcib --config /tmp/openstack-openbsd
mv /var/cache/pcib/images/openstack-openbsd*.img ~/builder/final.raw
16 changes: 16 additions & 0 deletions examples/openstack-openbsd66
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
os=openbsd
mirror=http://mirror.csclub.uwaterloo.ca/pub/OpenBSD
arch=amd64
release=6.6

plugin=base/bootable
dhcp-interface=vio0

plugin=base/raw-image-file
image-basename=openstack-openbsd66
image-size=2

plugin=partitioner/disklabel
plugin=package/cloud-init
plugin=fs/ffs
plugin=package/sshd
298 changes: 298 additions & 0 deletions plugins/os/openbsd/files/upobsd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
#!/bin/ksh
#
# Copyright (c) 2017-2018 Sebastien Marie <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
set -eu
PATH='/sbin:/bin:/usr/sbin:/usr/bin'

VERBOSE=0
MIRROR=$(sed -e '/^$/d' -e '/^#/d' -e 'q' /etc/installurl)
ARCH=$(uname -m)
SIGNIFY_KEY=''
AUTO='no'
RESPONSE_FILE=''
OUTPUT="${PWD}/bsd.rd"
PROFILE_FILE=''

# get kernel version
set -A _KERNV -- $(sysctl -n kern.version | sed 's/^OpenBSD \([0-9]\)\.\([0-9]\)\([^ ]*\).*/\1.\2 \1\2 \3/;q')
if ((${#_KERNV[*]} == 2)) ; then
OS_VERSION=${_KERNV[0]}
else
OS_VERSION='snapshots'
fi
SIGNIFY_VERSION=${_KERNV[1]}

UID=$(id -u)
WRKDIR=''

uo_usage() {
echo "usage: ${0##*/} [-v] [-m mirror] [-V version] [-a arch] [-p signify-key] [-i install-response-file] [-u upgrade-response-file] [-P profile-file] [-o output]" >&2
exit 1
}

uo_cleanup() {
trap "" 1 2 3 13 15 ERR
set +e

if [[ -d "${WRKDIR}" ]]; then
rm -f -- \
"${WRKDIR}/SHA256.sig" \
"${WRKDIR}/bsd.rd" \
"${WRKDIR}/ramdisk"

[[ -d "${WRKDIR}/ramdisk.d" ]] && \
rmdir -- "${WRKDIR}/ramdisk.d"

rmdir -- "${WRKDIR}" || \
uo_err 1 "cleanup failed: ${WRKDIR}"
fi
}

uo_err() {
local exitcode=${1}
shift

echo "error: ${@}" >&2
uo_cleanup

exit ${exitcode}
}

uo_trap() {
uo_cleanup
exit 1
}
trap "uo_trap" 1 2 3 13 15 ERR

uo_verbose() {
[[ ${VERBOSE} != 0 ]] && echo "${@}"
}

uo_ftp() {
local dest=${1}
local url=${2}

ftp -V -o "${WRKDIR}/${dest}" -- "${url}"
}

uo_download() {
local url="${MIRROR}/${OS_VERSION}/${ARCH}"

uo_verbose "downloading bsd.rd (and SHA256.sig): ${url}"

uo_ftp SHA256.sig "${url}/SHA256.sig"
uo_ftp bsd.rd "${url}/bsd.rd"

uo_check_signature
}

uo_check_signature() {
[ -r "${WRKDIR}/SHA256.sig" ] || \
uo_err 2 "uo_check_signature: no SHA256.sig in WRKDIR"

if [ -z "${SIGNIFY_KEY}" ]; then
uo_signify \
"/etc/signify/openbsd-${SIGNIFY_VERSION}-base.pub" \
"/etc/signify/openbsd-$(( ${SIGNIFY_VERSION} + 1 ))-base.pub"
else
uo_signify "${SIGNIFY_KEY}"
fi
}

uo_signify() {
local signify_all_keys="$*"

while [[ $# != 0 ]]; do
local signify_key=${1}

echo "checking signature: ${signify_key}"

[ -e "${signify_key}" ] || \
uo_err 1 "uo_check_signature: file not found: ${signify_key}"

if ( cd "${WRKDIR}" && \
signify -qC -p "${signify_key}" -x SHA256.sig bsd.rd ) ; then
break
fi

shift
done

if [[ $# = 0 ]]; then
uo_err 1 "invalid signature: ${signify_all_keys}"
else
uo_verbose "signature is valid"
fi
}

uo_priv() {
/usr/local/bin/sudo "$@"
}

uo_addfile() {
local dest=${1}
local src=${2}
local vnd_n=0

[ -r "${WRKDIR}/bsd.rd" ] || uo_err 2 "uo_addfile: no bsd.rd in WRKDIR"
[ -r "${src}" ] || uo_err 1 "file not found: ${src}"

uo_verbose "adding response file: ${dest}: ${src}"

# Since 6.9, bsd.rd is gzipped
gunzip < ${WRKDIR}/bsd.rd > /tmp/bsd.rd2 && mv /tmp/bsd.rd2 ${WRKDIR}/bsd.rd
# extract ramdisk from bsd.rd
rdsetroot -x "${WRKDIR}/bsd.rd" "${WRKDIR}/ramdisk"

# create mountpoint
mkdir "${WRKDIR}/ramdisk.d"

# prepare ramdisk for mounting
while ! uo_priv vnconfig "vnd${vnd_n}" "${WRKDIR}/ramdisk"; do
vnd_n=$(( vnd_n + 1 ))

[[ ${vnd_n} > 4 ]] && \
uo_err 1 "no more vnd device available"
done

# mount ramdisk
if ! uo_priv mount -o nodev,nosuid,noexec "/dev/vnd${vnd_n}a" "${WRKDIR}/ramdisk.d"; then
uo_priv vnconfig -u "vnd${vnd_n}" || true

uo_err 1 "unable to mount: /dev/vnd${vnd_n}a"
fi

# copy the file
if ! uo_priv install -m 644 -o root -g wheel -- \
"${src}" "${WRKDIR}/ramdisk.d/${dest}"; then

uo_priv umount "/dev/vnd${vnd_n}a" || true
uo_priv vnconfig -u "vnd${vnd_n}" || true

uo_err 1 "unable to copy: ${src}: ramdisk.d/${dest}"
fi

# umount vndX
if ! uo_priv umount "/dev/vnd${vnd_n}a" ; then
uo_priv vnconfig -u "vnd${vnd_n}" || true

uo_err 1 "unable to umount: /dev/vnd${vnd_n}a"
fi

# unconfigure vndX
if ! uo_priv vnconfig -u "vnd${vnd_n}" ; then
uo_err 1 "unable to unconfigure: vnd${vnd_n}"
fi

# mountpoint cleanup (ensure it is empty)
rmdir "${WRKDIR}/ramdisk.d"

# put ramdisk back in bsd.rd
rdsetroot "${WRKDIR}/bsd.rd" "${WRKDIR}/ramdisk"
gzip "${WRKDIR}/bsd.rd"
mv "${WRKDIR}/bsd.rd.gz" "${WRKDIR}/bsd.rd"
}

uo_output() {
[ -r "${WRKDIR}/bsd.rd" ] || uo_err 2 "uo_output: no bsd.rd in WRKDIR"

uo_verbose "copying bsd.rd: ${OUTPUT}"
mv -- "${WRKDIR}/bsd.rd" "${OUTPUT}"
}

uo_arch_endianness() {
case "${1}" in
hppa|luna88k|macppc|octeon|sgi)
echo "MSB" ;;
alpha|amd64|arm64|armv7|i386|landisk|loongson)
echo "LSB" ;;
*)
uo_err 1 "unknown arch: ${1}"
echo "---" ;;
esac
}

uo_check_arch_endianness() {
[[ $(uo_arch_endianness "${1}") != $(uo_arch_endianness "${2}") ]] && \
uo_err 1 "incompatible endianness for patching: ${1} ${2}"
}

uo_check_arch_patchable() {
case "${1}" in
alpha|sparc64|hppa)
uo_err 1 "unpatchable arch (stripped): ${_arch}" ;;

arm64|i386|loongson|macppc|sgi|amd64|armv7|landisk|luna88k|octeon|socppc)
;;

*)
echo "warn: unknown arch (could be unpatchable): ${1}" >&2 ;;
esac
}

# parse command-line
while getopts 'hvm:V:a:p:i:u:o:P:' arg; do
case "${arg}" in
v) VERBOSE=1 ;;
m) MIRROR="${OPTARG}" ;;
V) OS_VERSION="${OPTARG}" ;;
a) ARCH="${OPTARG}" ;;
p) SIGNIFY_KEY="${OPTARG}" ;;
i) AUTO='install'; RESPONSE_FILE="${OPTARG}" ;;
u) AUTO='upgrade'; RESPONSE_FILE="${OPTARG}" ;;
o) OUTPUT="${OPTARG}" ;;
P) PROFILE_FILE="${OPTARG}" ;;
*) uo_usage ;;
esac
done

shift $(( OPTIND -1 ))
[[ $# -ne 0 ]] && uo_usage

# update SIGNIFY_VERSION according to OS_VERSION
case "${OS_VERSION}" in
[0-9].[0-9]) SIGNIFY_VERSION="${OS_VERSION%.[0-9]}${OS_VERSION#[0-9].}" ;;
esac

[[ -n "${RESPONSE_FILE}" && ! -e ${RESPONSE_FILE} ]] && \
uo_err 1 "file not found: ${RESPONSE_FILE}"

# check for patchable archs
if [[ ${AUTO} != 'no' ]]; then
uo_check_arch_endianness "$(uname -m)" "${ARCH}"
uo_check_arch_patchable "${ARCH}"
fi

# create working directory
WRKDIR=$(mktemp -dt upobsd.XXXXXXXXXX) || \
uo_err 1 "unable to create temporary directory"

# download and check files
uo_download

# add response-file if requested
#[[ ${AUTO} != 'no' ]] && \
# uo_addfile "auto_${AUTO}.conf" "${RESPONSE_FILE}"

if [ -n ${PROFILE_FILE} ]; then
uo_addfile .profile ${PROFILE_FILE}
fi

# place bsd.rd where asked
uo_output

# cleanup
uo_cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

.include "${.CURDIR}/../ramdiskA/Makefile"
.PATH: ${.CURDIR}/../ramdisk
RAMDISK=RAMDISK_CD
FLOPPYSIZE=6976
FLOPPYTYPE=mini34
FSSIZE=69760
FSDISKTYPE=mini34
XNAME=miniroot
LBA=1

.include "${.CURDIR}/../common/Makefile.inc"

LISTS+= ${.CURDIR}/list.local
Loading