Skip to content

Commit 34e4b08

Browse files
authored
Add example extensions built with flix.sh and flatwrap.sh (#186)
To show how flix.sh and flatwrap.sh can be used to ship regular Linux packages as sysext we can add two examples. As flix example include an extension for the tilde text editor from Debian and as flatwrap example include an extension for btop from Alpine (originally I used htop but we might ship this in Flatcar later by default - note that you need to set LANG=en_US.UTF-8 or run with btop with --utf-force on Flatcar). ## How to use/Testing done `./bakery.sh create --sysupdate false btop 1.4.0` and `./bakery.sh create --sysupdate false tilde 1.1.2` with copying the extension to a Flatcar VM.
2 parents 61be83e + 60e2b71 commit 34e4b08

File tree

5 files changed

+89
-0
lines changed

5 files changed

+89
-0
lines changed

btop.sysext/create.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
# vim: et ts=2 syn=bash
3+
#
4+
# btop sysext.
5+
#
6+
7+
RELOAD_SERVICES_ON_MERGE="false"
8+
9+
function list_available_versions() {
10+
# Add sort for consuming all curl output
11+
# (When copying this, you might need to switch to 'main' from 'community')
12+
curl -sSfL https://dl-cdn.alpinelinux.org/alpine/latest-stable/community/x86_64/ | { sort || true ; } | grep -m1 -o "btop-.*apk" | cut -d - -f 2
13+
}
14+
# --
15+
16+
function populate_sysext_root() {
17+
local sysextroot="$1"
18+
local arch="$2"
19+
local version="$3"
20+
21+
local img_arch="$(arch_transform 'x86-64' 'amd64' "$arch")"
22+
img_arch="$(arch_transform 'arm64' 'arm64/v8' "$img_arch")"
23+
24+
docker run --rm \
25+
-i \
26+
-v "${scriptroot}/tools/":/tools \
27+
-v "${sysextroot}":/install_root \
28+
--platform "linux/${img_arch}" \
29+
--pull always \
30+
--network host \
31+
docker.io/alpine:latest \
32+
sh -c "apk add -U btop bash coreutils grep && cd /install_root && ETCMAP=chroot /tools/flatwrap.sh / btop /usr/bin/btop"
33+
# Alpine has /etc/terminfo instead of /usr/terminfo,
34+
# so above we need to skip mapping the host /etc into the flatwrap env
35+
mv "${sysextroot}"/btop/usr "${sysextroot}"/usr
36+
rmdir "${sysextroot}"/btop
37+
# Workaround: The bakery.sh tmp dir cleanup fails otherwise
38+
chmod -R u+w "${sysextroot}" || true
39+
}
40+
# --

btop.sysext/test.sh

Whitespace-only changes.

release_build_versions.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ cilium latest
9292

9393
bird 3.1.2
9494
bird latest
95+
96+
btop 1.4.0
97+
btop latest
98+
99+
tilde 1.1.2
100+
tilde latest

tilde.sysext/create.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# vim: et ts=2 syn=bash
3+
#
4+
# tilde sysext.
5+
#
6+
7+
RELOAD_SERVICES_ON_MERGE="false"
8+
9+
function list_available_versions() {
10+
# Add sort for consuming all curl output
11+
curl -sSfL https://packages.debian.org/bookworm/tilde | { sort || true ; } | grep -m1 -o "tilde_.*dsc" | cut -d _ -f 2 | cut -d - -f 1
12+
}
13+
# --
14+
15+
function populate_sysext_root() {
16+
local sysextroot="$1"
17+
local arch="$2"
18+
local version="$3"
19+
20+
local img_arch="$(arch_transform 'x86-64' 'amd64' "$arch")"
21+
img_arch="$(arch_transform 'arm64' 'arm64/v8' "$img_arch")"
22+
img_arch="$(arch_transform 'aarch64' 'arm64/v8' "$img_arch")"
23+
24+
local lib_arch="$(arch_transform 'amd64' 'x86_64' "$arch")"
25+
lib_arch="$(arch_transform 'x86-64' 'x86_64' "$lib_arch")"
26+
lib_arch="$(arch_transform 'arm64' 'aarch64' "$lib_arch")"
27+
28+
docker run --rm \
29+
-i \
30+
-v "${scriptroot}/tools/":/tools \
31+
-v "${sysextroot}":/install_root \
32+
--platform "linux/${img_arch}" \
33+
--pull always \
34+
--network host \
35+
docker.io/debian:bookworm-slim \
36+
sh -c "apt update && apt install -y tilde patchelf && cd /install_root && /tools/flix.sh / tilde /usr/bin/tilde /usr/lib/${lib_arch}-linux-gnu/transcript1 /usr/lib/${lib_arch}-linux-gnu/libt3widget"
37+
# We ship /usr/lib/...-linux-gnu/{transcript1,libt3widget} host folders.
38+
# But we assume that the host has /usr/share/terminfo around
39+
# otherwise we would need to add it as last argument above.
40+
mv "${sysextroot}"/tilde/usr "${sysextroot}"/usr
41+
rmdir "${sysextroot}"/tilde
42+
}
43+
# --

tilde.sysext/test.sh

Whitespace-only changes.

0 commit comments

Comments
 (0)