From ed6ab15a5c44f8c70e5d23dd513b4dd9f2a0f47f Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Sun, 21 Aug 2022 19:13:08 -0700 Subject: [PATCH 1/8] Bump Signed-off-by: dubo-dubon-duponey --- Dockerfile | 10 +++++----- README.md | 6 +++--- .../pkg/duponey.cloud/buildkit/buildctl/buildctl.cue | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8696fbe..2c921b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ ARG FROM_REGISTRY=index.docker.io/dubodubonduponey -ARG FROM_IMAGE_FETCHER=base:golang-bullseye-2022-06-01@sha256:7780f88fc0da1a5fd87f91cbb229e6932fc1fc2993f9c2d04210f6b909b93172 -ARG FROM_IMAGE_BUILDER=base:builder-bullseye-2022-06-01@sha256:3fe68fe3e3eb1c295bd5213cc4a296e929ab59c139ba1a55a04f716c352229ee -ARG FROM_IMAGE_AUDITOR=base:auditor-bullseye-2022-06-01@sha256:a2f2097b9b24c3650e149acb25719f72e56b01df139f120fc1f783d46260a8ce -ARG FROM_IMAGE_TOOLS=tools:linux-bullseye-2022-05-01@sha256:6268013e3bd16eaaf7dd15c7689f8740bd00af1149c92795cc42fab4f3c6d07a -ARG FROM_IMAGE_RUNTIME=base:runtime-bullseye-2022-06-01@sha256:fe875fbfa104beb7afbcfafe3d8ab9b3640c7d25a0ea285a76bf3d71ca216300 +ARG FROM_IMAGE_FETCHER=base:golang-bullseye-2022-08-01 +ARG FROM_IMAGE_BUILDER=base:builder-bullseye-2022-08-01 +ARG FROM_IMAGE_AUDITOR=base:auditor-bullseye-2022-08-01 +ARG FROM_IMAGE_TOOLS=tools:linux-bullseye-2022-08-01 +ARG FROM_IMAGE_RUNTIME=base:runtime-bullseye-2022-08-01 FROM $FROM_REGISTRY/$FROM_IMAGE_TOOLS AS builder-tools diff --git a/README.md b/README.md index cfcd13c..aaab7d7 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The following is the most straight-forward example, using host networking: ```bash docker run -d --rm \ --name "spot" \ - --env "NAME=Super Name For Your Spotify Connect Endpoint" \ + --env "MDNS_NAME=Super Name For Your Spotify Connect Endpoint" \ --volume /tmp \ --group-add audio \ --device /dev/snd \ @@ -70,7 +70,7 @@ Here is an example: ```bash docker run -d --rm \ --name "spot" \ - --env "NAME=Super Name For Your Spotify Connect Endpoint" \ + --env "MDNS_NAME=Super Name For Your Spotify Connect Endpoint" \ --volume /tmp \ --group-add audio \ --device /dev/snd \ @@ -94,7 +94,7 @@ docker run --rm \ You may specify the following environment variables at runtime: - * `NAME` (eg: `Totale Croquette`) controls the "name" under which your endpoint will appear in Spotify + * `MDNS_NAME` (eg: `Totale Croquette`) controls the "name" under which your endpoint will appear in Spotify You can also tweak the following for control over which internal ports are being used: diff --git a/cue.mod/pkg/duponey.cloud/buildkit/buildctl/buildctl.cue b/cue.mod/pkg/duponey.cloud/buildkit/buildctl/buildctl.cue index 2cb902b..7a74ef0 100644 --- a/cue.mod/pkg/duponey.cloud/buildkit/buildctl/buildctl.cue +++ b/cue.mod/pkg/duponey.cloud/buildkit/buildctl/buildctl.cue @@ -72,6 +72,7 @@ import ( ["--local", "dockerfile=\(dockerfile)"] + ["--frontend", frontend] + + ["--trace", "buildctl.trace.json"] + ["--opt", "filename=\(filename)"] + ["--local", "context=\(context)"] + From 10ac92ba8e63f425bbc86de1b82a9b31c75660db Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Fri, 23 Dec 2022 18:34:09 -0800 Subject: [PATCH 2/8] Bump Signed-off-by: dubo-dubon-duponey --- .github/workflows/CI.yml | 9 ++++----- DEVELOP.md | 6 +++--- Dockerfile | 14 +++++++------- README.md | 6 +++--- hack/helpers/start-buildkit.sh | 2 +- hack/lint.sh | 2 +- hack/recipe.cue | 4 ++-- hack/test.sh | 4 ++-- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index acebbe5..31f466c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -5,7 +5,7 @@ on: [push, pull_request] jobs: test: # The type of runner that the job will run on - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -31,8 +31,6 @@ jobs: - name: Start apt proxy run: | - # Hiding the read-only token base64 to avoid github disabling it... - echo OWMyMGVhYzk4N2NhYWQxYmI3MzhmNTZkODNmOGMwOGJjZjlhNDc4YQo= | base64 -d | docker login ghcr.io -u dubo-dubon-duponey --password-stdin docker run --rm -d --expose 443 --expose 80 --pull always \ --name apt-front \ --read-only \ @@ -47,12 +45,13 @@ jobs: --env ADDITIONAL_DOMAINS=*.debian.org \ --volume "$GITHUB_WORKSPACE/cache/certs":/certs \ --volume "$GITHUB_WORKSPACE/cache/apt":/data \ - index.docker.io/dubodubonduponey/aptutil:bullseye-2021-08-01 + docker.io/dubodubonduponey/aptutil:bullseye-2021-08-01 - name: test run: | # Set the path and install the tools - BIN_LOCATION="$GITHUB_WORKSPACE/cache/bin" source ./hack/helpers/install-tools.sh + export PATH="$GITHUB_WORKSPACE/cache/bin:$PATH" + ./hack/helpers/install-tools.sh # Start buildkit bkaddr="$(./hack/helpers/start-buildkit.sh 2>/dev/null)" # Sanity check diff --git a/DEVELOP.md b/DEVELOP.md index 1758927..73dfe5a 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -10,11 +10,11 @@ ### The what -This image is built using: `index.docker.io/dubodubonduponey/base:builder-bullseye-2021-11-01` +This image is built using: `docker.io/dubodubonduponey/base:builder-bullseye-2022-12-01` -The runtime part is based on: `index.docker.io/dubodubonduponey/base:runtime-bullseye-2021-11-01` +The runtime part is based on: `docker.io/dubodubonduponey/base:runtime-bullseye-2022-12-01` -Both these images are built upon: `index.docker.io/dubodubonduponey/debian:bullseye-2021-11-01` +Both these images are built upon: `docker.io/dubodubonduponey/debian:bullseye-2022-12-01` You can find out more here: diff --git a/Dockerfile b/Dockerfile index 2c921b1..861f6df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -ARG FROM_REGISTRY=index.docker.io/dubodubonduponey +ARG FROM_REGISTRY=docker.io/dubodubonduponey -ARG FROM_IMAGE_FETCHER=base:golang-bullseye-2022-08-01 -ARG FROM_IMAGE_BUILDER=base:builder-bullseye-2022-08-01 -ARG FROM_IMAGE_AUDITOR=base:auditor-bullseye-2022-08-01 -ARG FROM_IMAGE_TOOLS=tools:linux-bullseye-2022-08-01 -ARG FROM_IMAGE_RUNTIME=base:runtime-bullseye-2022-08-01 +ARG FROM_IMAGE_FETCHER=base:golang-bullseye-2022-12-01 +ARG FROM_IMAGE_BUILDER=base:builder-bullseye-2022-12-01 +ARG FROM_IMAGE_AUDITOR=base:auditor-bullseye-2022-12-01 +ARG FROM_IMAGE_TOOLS=tools:linux-bullseye-2022-12-01 +ARG FROM_IMAGE_RUNTIME=base:runtime-bullseye-2022-12-01 FROM $FROM_REGISTRY/$FROM_IMAGE_TOOLS AS builder-tools @@ -164,7 +164,7 @@ RUN --mount=type=secret,uid=100,id=CA \ apt-get install -qq --no-install-recommends \ libasound2=1.2.4-1.1 \ libpulse0=14.2-2 \ - curl=7.74.0-1.3+deb11u1 \ + curl=7.74.0-1.3+deb11u3 \ fbi=2.10-4 \ jq=1.6-2.1 \ && apt-get -qq autoremove \ diff --git a/README.md b/README.md index aaab7d7..0545179 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ docker run -d --rm \ --net host \ --cap-drop ALL \ --read-only \ - index.docker.io/dubodubonduponey/spotify + docker.io/dubodubonduponey/spotify ``` ## Notes @@ -77,7 +77,7 @@ docker run -d --rm \ --net host \ --cap-drop ALL \ --read-only \ - index.docker.io/dubodubonduponey/spotify \ + docker.io/dubodubonduponey/spotify \ --device default:CARD=Mojo \ --enable-volume-normalisation \ -v @@ -86,7 +86,7 @@ docker run -d --rm \ For a reference of all librespot options, try: ```bash docker run --rm \ - index.docker.io/dubodubonduponey/spotify \ + docker.io/dubodubonduponey/spotify \ --help ``` diff --git a/hack/helpers/start-buildkit.sh b/hack/helpers/start-buildkit.sh index 3e07744..80702fa 100755 --- a/hack/helpers/start-buildkit.sh +++ b/hack/helpers/start-buildkit.sh @@ -4,7 +4,7 @@ set -o errexit -o errtrace -o functrace -o nounset -o pipefail export SUITE=bullseye export DATE=2021-08-01 -readonly IMAGE_BLDKT="${IMAGE_BLDKT:-index.docker.io/dubodubonduponey/buildkit:$SUITE-$DATE}" +readonly IMAGE_BLDKT="${IMAGE_BLDKT:-docker.io/dubodubonduponey/buildkit:$SUITE-$DATE}" setup::buildkit() { [ "$(docker container inspect -f '{{.State.Running}}' dbdbdp-buildkit 2>/dev/null)" == "true" ] || { diff --git a/hack/lint.sh b/hack/lint.sh index 0334f25..e39dd2d 100755 --- a/hack/lint.sh +++ b/hack/lint.sh @@ -24,4 +24,4 @@ if ! hadolint "${hadolint_ignore[@]}" "$root"/*Dockerfile*; then exit 1 fi -find "$root" -iname "*.sh" -not -path "*debuerreotype*" -exec shellcheck {} \; +find "$root" -iname "*.sh" -not -path "*debuerreotype*" -not -path "*cache*" -exec shellcheck {} \; diff --git a/hack/recipe.cue b/hack/recipe.cue index 442f333..9bf0365 100644 --- a/hack/recipe.cue +++ b/hack/recipe.cue @@ -12,7 +12,7 @@ cakes: { recipe: { input: { from: { - registry: * "index.docker.io/dubodubonduponey" | string + registry: * "docker.io/dubodubonduponey" | string } } @@ -45,7 +45,7 @@ cakes: { injectors: { suite: * "bullseye" | =~ "^(?:jessie|stretch|buster|bullseye|sid)$" @tag(suite, type=string) - date: * "2022-04-01" | =~ "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" @tag(date, type=string) + date: * "2022-12-01" | =~ "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" @tag(date, type=string) platforms: string @tag(platforms, type=string) registry: * "registry.local" | string @tag(registry, type=string) } diff --git a/hack/test.sh b/hack/test.sh index 844aa83..ac1a5a1 100755 --- a/hack/test.sh +++ b/hack/test.sh @@ -8,9 +8,9 @@ root="$(cd "$(dirname "${BASH_SOURCE[0]:-$PWD}")" 2>/dev/null 1>&2 && pwd)/../" # XXX Currently reduced to a single architecture to avoid using all disk space until we figure out our space efficiency problem (likely the fat builder image getting duplicated over and over) # Solution would probably be to do like buildkit and fetch with a lightweight go image while build mount from the previous stage instead of inheriting - annoying but probably the only way if ! "$root/hack/build.sh" \ - --inject registry="index.docker.io/dubodubonduponey" \ + --inject registry="docker.io/dubodubonduponey" \ --inject progress=plain \ - --inject date=2021-11-01 \ + --inject date=2022-12-01 \ --inject suite=bullseye \ --inject platforms=linux/arm64 \ "image" "$@"; then From 7c268ca883e0754165839336e1aef068d51cb7a0 Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Thu, 7 Sep 2023 16:12:53 -0700 Subject: [PATCH 3/8] Bump --- Dockerfile | 24 ++++++++++++------------ hack/recipe.cue | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 861f6df..c441ea1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ ARG FROM_REGISTRY=docker.io/dubodubonduponey -ARG FROM_IMAGE_FETCHER=base:golang-bullseye-2022-12-01 -ARG FROM_IMAGE_BUILDER=base:builder-bullseye-2022-12-01 -ARG FROM_IMAGE_AUDITOR=base:auditor-bullseye-2022-12-01 -ARG FROM_IMAGE_TOOLS=tools:linux-bullseye-2022-12-01 -ARG FROM_IMAGE_RUNTIME=base:runtime-bullseye-2022-12-01 +ARG FROM_IMAGE_FETCHER=base:golang-bookworm-2023-09-01 +ARG FROM_IMAGE_BUILDER=base:builder-bookworm-2023-09-01 +ARG FROM_IMAGE_AUDITOR=base:auditor-bookworm-2023-09-01 +ARG FROM_IMAGE_TOOLS=tools:linux-bookworm-2023-09-01 +ARG FROM_IMAGE_RUNTIME=base:runtime-bookworm-2023-09-01 FROM $FROM_REGISTRY/$FROM_IMAGE_TOOLS AS builder-tools @@ -41,8 +41,8 @@ RUN --mount=type=secret,uid=100,id=CA \ eval "$(dpkg-architecture -A "$(echo "$TARGETARCH$TARGETVARIANT" | sed -e "s/^armv6$/armel/" -e "s/^armv7$/armhf/" -e "s/^ppc64le$/ppc64el/" -e "s/^386$/i386/")")"; \ apt-get update -qq; \ apt-get install -qq --no-install-recommends \ - libpulse-dev:"$DEB_TARGET_ARCH"=14.2-2 \ - libasound2-dev:"$DEB_TARGET_ARCH"=1.2.4-1.1 + libpulse-dev:"$DEB_TARGET_ARCH"=16.1+dfsg1-2+b1 \ + libasound2-dev:"$DEB_TARGET_ARCH"=1.2.8-1+b1 # Maybe consider https://github.com/japaric/rust-cross for cross-compilation @@ -104,7 +104,7 @@ RUN --mount=type=secret,uid=100,id=CA \ eval "$(dpkg-architecture -A "$(echo "$TARGETARCH$TARGETVARIANT" | sed -e "s/^armv6$/armel/" -e "s/^armv7$/armhf/" -e "s/^ppc64le$/ppc64el/" -e "s/^386$/i386/")")"; \ apt-get update -qq && \ apt-get install -qq --no-install-recommends \ - fbi:"$DEB_TARGET_ARCH"=2.10-4 \ + fbi:"$DEB_TARGET_ARCH"=2.10-4+b1 \ && apt-get -qq autoremove \ && apt-get -qq clean \ && rm -rf /var/lib/apt/lists/* \ @@ -162,10 +162,10 @@ RUN --mount=type=secret,uid=100,id=CA \ --mount=type=secret,id=APT_CONFIG \ apt-get update -qq && \ apt-get install -qq --no-install-recommends \ - libasound2=1.2.4-1.1 \ - libpulse0=14.2-2 \ - curl=7.74.0-1.3+deb11u3 \ - fbi=2.10-4 \ + libasound2=1.2.8-1+b1 \ + libpulse0=16.1+dfsg1-2+b1 \ + curl=7.88.1-10+deb12u1 \ + fbi=2.10-4+b1 \ jq=1.6-2.1 \ && apt-get -qq autoremove \ && apt-get -qq clean \ diff --git a/hack/recipe.cue b/hack/recipe.cue index 9bf0365..9600876 100644 --- a/hack/recipe.cue +++ b/hack/recipe.cue @@ -20,11 +20,11 @@ cakes: { platforms: types.#Platforms | * [ types.#Platforms.#AMD64, types.#Platforms.#ARM64, - types.#Platforms.#I386, - types.#Platforms.#V7, - types.#Platforms.#V6, - types.#Platforms.#S390X, - types.#Platforms.#PPC64LE, + // types.#Platforms.#I386, + // types.#Platforms.#V7, + // types.#Platforms.#V6, + // types.#Platforms.#S390X, + // types.#Platforms.#PPC64LE, ] } @@ -44,7 +44,7 @@ cakes: { } injectors: { - suite: * "bullseye" | =~ "^(?:jessie|stretch|buster|bullseye|sid)$" @tag(suite, type=string) + suite: * "bullseye" | =~ "^(?:bullseye|bookworm|trixie|sid)$" @tag(suite, type=string) date: * "2022-12-01" | =~ "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" @tag(date, type=string) platforms: string @tag(platforms, type=string) registry: * "registry.local" | string @tag(registry, type=string) From d000bc371ccda3da639783db2049c10dbbc98af1 Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Mon, 18 Sep 2023 19:46:18 -0700 Subject: [PATCH 4/8] Bump --- .gitignore | 2 + Dockerfile | 21 +++---- context/runtime/boot/entrypoint.sh | 11 ++-- context/runtime/boot/mdns.sh | 92 +++++++++++++++++++++++++++--- hack/recipe.cue | 2 +- 5 files changed, 102 insertions(+), 26 deletions(-) mode change 100644 => 100755 context/runtime/boot/mdns.sh diff --git a/.gitignore b/.gitignore index 10b083a..507266e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ /.idea */cache/* cache +*trace.json +xxx-* diff --git a/Dockerfile b/Dockerfile index c441ea1..540b863 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ ARG FROM_REGISTRY=docker.io/dubodubonduponey -ARG FROM_IMAGE_FETCHER=base:golang-bookworm-2023-09-01 -ARG FROM_IMAGE_BUILDER=base:builder-bookworm-2023-09-01 -ARG FROM_IMAGE_AUDITOR=base:auditor-bookworm-2023-09-01 -ARG FROM_IMAGE_TOOLS=tools:linux-bookworm-2023-09-01 -ARG FROM_IMAGE_RUNTIME=base:runtime-bookworm-2023-09-01 +ARG FROM_IMAGE_FETCHER=base:golang-bookworm-2023-09-05 +ARG FROM_IMAGE_BUILDER=base:builder-bookworm-2023-09-05 +ARG FROM_IMAGE_AUDITOR=base:auditor-bookworm-2023-09-05 +ARG FROM_IMAGE_TOOLS=tools:linux-bookworm-2023-09-05 +ARG FROM_IMAGE_RUNTIME=base:runtime-bookworm-2023-09-05 FROM $FROM_REGISTRY/$FROM_IMAGE_TOOLS AS builder-tools @@ -182,16 +182,17 @@ ENV _SERVICE_TYPE="spotify-connect" COPY --from=assembly --chown=$BUILD_UID:root /dist / ### mDNS broadcasting +# XXX note this unfortunately does not work with librespot # Whether to enable MDNS broadcasting or not -ENV MDNS_ENABLED=true +ENV MOD_MDNS_ENABLED=false # Type to advertise -ENV MDNS_TYPE="_$_SERVICE_TYPE._tcp" +ENV MOD_MDNS_TYPE="_$_SERVICE_TYPE._tcp" # Name is used as a short description for the service -ENV MDNS_NAME="$_SERVICE_NICK mDNS display name" +ENV MOD_MDNS_NAME="$_SERVICE_NICK mDNS display name" # The service will be annonced and reachable at $MDNS_HOST.local (set to empty string to disable mDNS announces entirely) -ENV MDNS_HOST="$_SERVICE_NICK" +ENV MOD_MDNS_HOST="$_SERVICE_NICK" # Also announce the service as a workstation (for example for the benefit of coreDNS mDNS) -ENV MDNS_STATION=true +ENV ADVANCED_MOD_MDNS_STATION=true ENV LOG_LEVEL="warn" diff --git a/context/runtime/boot/entrypoint.sh b/context/runtime/boot/entrypoint.sh index ce95d09..0daa06f 100644 --- a/context/runtime/boot/entrypoint.sh +++ b/context/runtime/boot/entrypoint.sh @@ -12,20 +12,19 @@ helpers::dir::writable /tmp readonly PORT="${PORT:-10042}" # This is purely cached music, so, disposable and transient -args=(--cache-size-limit 8G --cache /tmp/cache --name "${MDNS_NAME:-Sproutify}" --bitrate 320 --device-type speaker --zeroconf-port "$PORT") +args=(--cache-size-limit 8G --cache /tmp/cache --name "${MOD_MDNS_NAME:-Sproutify}" --bitrate 320 --device-type speaker --zeroconf-port "$PORT") # Hook the experimental display script if asked to [ ! "$SPOTIFY_CLIENT_ID" ] || [ ! "$SPOTIFY_CLIENT_SECRET" ] || [ ! "$DISPLAY_ENABLED" ] || args+=(--onevent /boot/onevent.sh) # mDNS blast if asked to -[ "${MDNS_ENABLED:-}" != true ] || { - [ ! "${MDNS_STATION:-}" ] || mdns::records::add "_workstation._tcp" "$MDNS_HOST" "${MDNS_NAME:-}" "$PORT" - mdns::records::add "${MDNS_TYPE:-_spotify-connect._tcp}" "$MDNS_HOST" "${MDNS_NAME:-}" "$PORT" '["VERSION=1", "CPath=/"]' - mdns::records::broadcast & +[ "${MOD_MDNS_ENABLED:-}" != true ] || { + [ "${ADVANCED_MOD_MDNS_STATION:-}" != true ] || mdns::records::add "_workstation._tcp" "${MOD_MDNS_HOST}" "${MOD_MDNS_NAME:-}" "$PORT" + mdns::records::add "${ADVANCED_MOD_MDNS_TYPE:-_spotify-connect._tcp}" "${MOD_MDNS_HOST:-}" "${MOD_MDNS_NAME:-}" "$PORT" '["VERSION=1", "CPath=/"]' + mdns::start::broadcaster & args+=(--disable-discovery) } - [ "$(printf "%s" "$LOG_LEVEL" | tr '[:upper:]' '[:lower:]')" != "debug" ] || args+=(--verbose) [ ! "$OUTPUT" ] || args+=(--backend "$OUTPUT") [ ! "$DEVICE" ] || args+=(--device "$DEVICE") diff --git a/context/runtime/boot/mdns.sh b/context/runtime/boot/mdns.sh old mode 100644 new mode 100755 index 4d60fba..6f1b027 --- a/context/runtime/boot/mdns.sh +++ b/context/runtime/boot/mdns.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash set -o errexit -o errtrace -o functrace -o nounset -o pipefail -_mdns_records=() +readonly _default_mod_mdns_configuration_path="$XDG_CONFIG_DIRS/goello/main.json" +_internal_mod_mdns_records=() mdns::records::add(){ local type="$1" @@ -9,12 +10,18 @@ mdns::records::add(){ local name="${3:-$host}" local port="${4:-9}" local text="${5:-[]}" - _mdns_records+=("$(printf '{"Type": "%s", "Host": "%s", "Name": "%s", "Port": %s, "Text": %s}' "$type" "$host" "$name" "$port" "$text")") + _internal_mod_mdns_records+=("$(printf '{"Type": "%s", "Host": "%s", "Name": "%s", "Port": %s, "Text": %s}' "$type" "$host" "$name" "$port" "$text")") } -mdns::records::broadcast(){ - local IFS="," - goello-server-ng -json "[${_mdns_records[*]}]" +mdns::records::load(){ + local file="$1" + local records="" + while read line -r; do + records+="$line" + done < "$file" + records="${records%]*}" + records="${records#*[}" + _internal_mod_mdns_records+=("$records") } mdns::records::resolve(){ @@ -28,8 +35,75 @@ mdns::records::resolve(){ printf "%s %s" "$server" "$port" } -mdns::resolver::start(){ - helpers::dir::writable "$XDG_STATE_HOME/avahi-daemon" create - rm -f /run/avahi-daemon/pid - avahi-daemon -f /config/avahi/main.conf --daemonize --no-drop-root --no-chroot --debug +mdns::start::broadcaster(){ + [ ! -e "$_default_mod_mdns_configuration_path" ] || mdns::records::load "$_default_mod_mdns_configuration_path" + local IFS="," + goello-server-ng -json "[${_internal_mod_mdns_records[*]}]" +} + +mdns::start::avahi(){ + # Current issues with Avahi: + # - no way to change /run/avahi-daemon to another location - symlink works though + # - daemonization writing to syslog is a problem + # - avahi insists that /run/avahi-daemon must belong to avahi:avahi + # which is absolutely ridiculous - https://github.com/lathiat/avahi/blob/778fadb71cb923eee74f3f1967db88b8c2586830/avahi-daemon/main.c#L1434 + # Some variant of it: https://github.com/lathiat/avahi/issues/349 + # - project is half-dead: https://github.com/lathiat/avahi/issues/388 + + local args=() + local avahisocket="$XDG_STATE_HOME/avahi-daemon/socket" + + # Make sure we can write it + helpers::dir::writable "$(dirname "$avahisocket")" + + # Cleanup leftovers on container restart + rm -f "$(dirname "$avahisocket")/pid" + + [ "$(printf "%s" "$LOG_LEVEL" | tr '[:upper:]' '[:lower:]')" != "debug" ] || args+=(--debug) + + # -D/--daemonize implies -s/--syslog that we do not want, so, just background it + avahi-daemon -f /config/avahi/main.conf --no-drop-root --no-chroot "${args[@]}" & + + local tries=1 + # Wait until the socket is there + until [ -e "$avahisocket" ]; do + sleep 1s + tries=$(( tries + 1)) + [ $tries -lt 10 ] || { + printf >&2 "Failed starting avahi in a reasonable time. Something is quite wrong\n" + return 1 + } + done +} + +mdns::start::dbus(){ + # https://linux.die.net/man/1/dbus-daemon-1 + # https://man7.org/linux/man-pages/man3/sd_bus_default.3.html + # https://specifications.freedesktop.org/basedir-spec/latest/ar01s03.html + + # $XDG_STATE_HOME=/tmp/state + # Configuration file also has that ^ hardcoded, so, cannot use the variable... + + local dbussocket=/tmp/state/dbus/system_bus_socket + + # Ensure directory exists + helpers::dir::writable "$(dirname "$dbussocket")" create + + # Point it there for other systems + export DBUS_SYSTEM_BUS_ADDRESS=unix:path="$dbussocket" + export DBUS_SESSION_BUS_ADDRESS=unix:path="$dbussocket" + + # Start it, without a PID file + dbus-daemon --nopidfile --config-file /config/dbus/main.conf + + local tries=1 + # Wait until the socket is there + until [ -e "$dbussocket" ]; do + sleep 1s + tries=$(( tries + 1)) + [ $tries -lt 10 ] || { + printf >&2 "Failed starting dbus in a reasonable time. Something is quite wrong\n" + return 1 + } + done } diff --git a/hack/recipe.cue b/hack/recipe.cue index 9600876..db0136c 100644 --- a/hack/recipe.cue +++ b/hack/recipe.cue @@ -20,8 +20,8 @@ cakes: { platforms: types.#Platforms | * [ types.#Platforms.#AMD64, types.#Platforms.#ARM64, + types.#Platforms.#V7, // types.#Platforms.#I386, - // types.#Platforms.#V7, // types.#Platforms.#V6, // types.#Platforms.#S390X, // types.#Platforms.#PPC64LE, From 7279d824c7daa1f7d81aef0bce6a8b3ab2b6b138 Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Fri, 2 Feb 2024 11:05:19 -0800 Subject: [PATCH 5/8] Fix fbi leaking and goello announce issue --- context/runtime/boot/mdns.sh | 2 +- context/runtime/boot/onevent.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/context/runtime/boot/mdns.sh b/context/runtime/boot/mdns.sh index 6f1b027..ecece08 100755 --- a/context/runtime/boot/mdns.sh +++ b/context/runtime/boot/mdns.sh @@ -9,7 +9,7 @@ mdns::records::add(){ local host="$2" local name="${3:-$host}" local port="${4:-9}" - local text="${5:-[]}" + local text="${5:-[\"\"]}" # XXX Goello bug - if [] the announce if not visible _internal_mod_mdns_records+=("$(printf '{"Type": "%s", "Host": "%s", "Name": "%s", "Port": %s, "Text": %s}' "$type" "$host" "$name" "$port" "$text")") } diff --git a/context/runtime/boot/onevent.sh b/context/runtime/boot/onevent.sh index 0d1130e..0684b6a 100755 --- a/context/runtime/boot/onevent.sh +++ b/context/runtime/boot/onevent.sh @@ -23,8 +23,12 @@ get::url(){ display(){ local img="$1" + local prior + prior="$(pidof fbi)" # Should be smarter and verify permissions on the ttys or bail out fbi -a -noverbose -norandom -T 2 -once "$img" + # shellcheck disable=SC2086 + kill -s KILL $prior } call(){ From 0337202b8730080a841716389eb69e66e5ab8c94 Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Thu, 22 Feb 2024 20:36:23 -0800 Subject: [PATCH 6/8] Somewhat better logging and display fix --- context/runtime/boot/entrypoint.sh | 5 ++++- context/runtime/boot/onevent.sh | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/context/runtime/boot/entrypoint.sh b/context/runtime/boot/entrypoint.sh index 0daa06f..a1c9abc 100644 --- a/context/runtime/boot/entrypoint.sh +++ b/context/runtime/boot/entrypoint.sh @@ -25,7 +25,10 @@ args=(--cache-size-limit 8G --cache /tmp/cache --name "${MOD_MDNS_NAME:-Sproutif args+=(--disable-discovery) } -[ "$(printf "%s" "$LOG_LEVEL" | tr '[:upper:]' '[:lower:]')" != "debug" ] || args+=(--verbose) +normalized_log_level="$(printf "%s" "$LOG_LEVEL" | tr '[:upper:]' '[:lower:]')" +[ "$normalized_log_level" != "debug" ] || args+=(--verbose) +[ "$normalized_log_level" != "error" ] && [ "$normalized_log_level" != "warning" ] || args+=(--quiet) + [ ! "$OUTPUT" ] || args+=(--backend "$OUTPUT") [ ! "$DEVICE" ] || args+=(--device "$DEVICE") args+=("$@") diff --git a/context/runtime/boot/onevent.sh b/context/runtime/boot/onevent.sh index 0684b6a..eadc322 100755 --- a/context/runtime/boot/onevent.sh +++ b/context/runtime/boot/onevent.sh @@ -24,11 +24,13 @@ get::url(){ display(){ local img="$1" local prior - prior="$(pidof fbi)" + prior="$(pidof fbi || true)" + # shellcheck disable=SC2086 + [ "$prior" == "" ] || kill -s TERM $prior || true + + printf "Done cleanup. Starting another cover." # Should be smarter and verify permissions on the ttys or bail out fbi -a -noverbose -norandom -T 2 -once "$img" - # shellcheck disable=SC2086 - kill -s KILL $prior } call(){ From 9ee7a8877f67b02a4ee07339e74460d945cf0d8c Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Mon, 26 Feb 2024 16:42:58 -0800 Subject: [PATCH 7/8] bump --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 540b863..14e9475 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ ARG FROM_REGISTRY=docker.io/dubodubonduponey -ARG FROM_IMAGE_FETCHER=base:golang-bookworm-2023-09-05 -ARG FROM_IMAGE_BUILDER=base:builder-bookworm-2023-09-05 -ARG FROM_IMAGE_AUDITOR=base:auditor-bookworm-2023-09-05 -ARG FROM_IMAGE_TOOLS=tools:linux-bookworm-2023-09-05 -ARG FROM_IMAGE_RUNTIME=base:runtime-bookworm-2023-09-05 +ARG FROM_IMAGE_FETCHER=base:golang-bookworm-2024-02-20 +ARG FROM_IMAGE_BUILDER=base:builder-bookworm-2024-02-20 +ARG FROM_IMAGE_AUDITOR=base:auditor-bookworm-2024-02-20 +ARG FROM_IMAGE_TOOLS=tools:linux-bookworm-2024-02-20 +ARG FROM_IMAGE_RUNTIME=base:runtime-bookworm-2024-02-20 FROM $FROM_REGISTRY/$FROM_IMAGE_TOOLS AS builder-tools @@ -164,7 +164,7 @@ RUN --mount=type=secret,uid=100,id=CA \ apt-get install -qq --no-install-recommends \ libasound2=1.2.8-1+b1 \ libpulse0=16.1+dfsg1-2+b1 \ - curl=7.88.1-10+deb12u1 \ + curl=7.88.1-10+deb12u5 \ fbi=2.10-4+b1 \ jq=1.6-2.1 \ && apt-get -qq autoremove \ From 8938a569e3fd5b9fb9dcf2fdc95f8ffa9e65a4ed Mon Sep 17 00:00:00 2001 From: dubo-dubon-duponey Date: Wed, 13 Mar 2024 11:37:56 -0700 Subject: [PATCH 8/8] goello --- context/runtime/boot/mdns.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context/runtime/boot/mdns.sh b/context/runtime/boot/mdns.sh index ecece08..b0007c6 100755 --- a/context/runtime/boot/mdns.sh +++ b/context/runtime/boot/mdns.sh @@ -9,7 +9,7 @@ mdns::records::add(){ local host="$2" local name="${3:-$host}" local port="${4:-9}" - local text="${5:-[\"\"]}" # XXX Goello bug - if [] the announce if not visible + local text="${5:-[\"\"]}" # XXX Goello bug - if [] the announce is not visible _internal_mod_mdns_records+=("$(printf '{"Type": "%s", "Host": "%s", "Name": "%s", "Port": %s, "Text": %s}' "$type" "$host" "$name" "$port" "$text")") } @@ -54,7 +54,7 @@ mdns::start::avahi(){ local avahisocket="$XDG_STATE_HOME/avahi-daemon/socket" # Make sure we can write it - helpers::dir::writable "$(dirname "$avahisocket")" + helpers::dir::writable "$(dirname "$avahisocket")" true # Cleanup leftovers on container restart rm -f "$(dirname "$avahisocket")/pid"