Skip to content

Commit 966a439

Browse files
committed
Initial commit
0 parents  commit 966a439

File tree

5 files changed

+240
-0
lines changed

5 files changed

+240
-0
lines changed

.github/workflows/build-alpine.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: Build Alpine Image
3+
4+
on:
5+
push:
6+
branches: [ main ]
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
branches: [ main ]
11+
paths-ignore:
12+
- '**.md'
13+
workflow_dispatch:
14+
15+
jobs:
16+
shellcheck:
17+
name: Shellcheck
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Run ShellCheck
22+
uses: ludeeus/action-shellcheck@master
23+
env:
24+
SHELLCHECK_OPTS: -x
25+
26+
build:
27+
name: Build Alpine Image
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
33+
- name: Checkout image-builder
34+
uses: actions/checkout@v3
35+
with:
36+
repository: 'OpsBoost/image-builder'
37+
path: 'image-builder'
38+
39+
- name: Build
40+
run: |
41+
sudo ./image-builder/image-builder install
42+
image-builder build alpine
43+
44+
- name: Release image
45+
uses: "marvinpinto/action-automatic-releases@latest"
46+
with:
47+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
48+
prerelease: false
49+
automatic_release_tag: "latest"
50+
files: |
51+
iss-screen-device.img.xz
52+
iss-screen-device.img.xz.sha384

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bzImage*
2+
iss-screen-device.img
3+
stage3*
4+
video.mp4
5+
wpa_supplicant.conf*

LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2022, OpsBoost
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

input/image.sh

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/sh
2+
3+
DISPLAY_CONTROLLER_URL=https://raw.githubusercontent.com/opsboost/iss-display-controller/main
4+
PYTHON_WAYLAND_VERSION=latest
5+
PYTHON_WAYLAND_ARCHIVE=python-wayland-${PYTHON_WAYLAND_VERSION}.tar.xz
6+
PYTHON_WAYLAND_URL=https://github.com/bbusse/python-wayland/releases/download/latest/${PYTHON_WAYLAND_ARCHIVE}
7+
SWAY_CONFIG_URL=https://raw.githubusercontent.com/bbusse/swayvnc/main/config
8+
SERVICE_USER=iss
9+
PAYLOAD="mpv /home/${SERVICE_USER}/video.mp4"
10+
STREAMS_PLAYLIST_URL="https://raw.githubusercontent.com/jnk22/kodinerds-iptv/master/iptv/clean/clean_tv.m3u"
11+
12+
setup_sway() {
13+
printf "Fetching sway config\n"
14+
curl --output-dir "${ROOTFS_PATH}"/etc/sway -LO "${SWAY_CONFIG_URL}"
15+
16+
# Write Sway start script
17+
printf "Writing sway-launcher\n"
18+
sway_write_launcher
19+
20+
# Write Sway openrc startup file
21+
printf "Writing openrc start script\n"
22+
mkdir -p "${ROOTFS_PATH}"/etc/local.d
23+
sway_write_start_script
24+
25+
# Write exec to sway's config.d
26+
sway_configure_payload
27+
28+
chmod +x "${ROOTFS_PATH}"/usr/bin/sway-launcher
29+
chmod +x "${ROOTFS_PATH}"/etc/local.d/sway.start
30+
}
31+
32+
sway_configure_payload() {
33+
mkdir "${ROOTFS_PATH}"/etc/sway/config.d
34+
printf "exec %s" "${PAYLOAD}" >> "${ROOTFS_PATH}"/etc/sway/config.d/exec-payload
35+
}
36+
37+
sway_write_launcher() {
38+
cat << \EOF > "${ROOTFS_PATH}"/usr/bin/sway-launcher
39+
#!/bin/sh
40+
41+
# Launch sway with a specific user, from a specific Virtual Terminal (vt)
42+
# Two arguments are expected: a username (e.g., larry) and the id of a free vt (e.g., 7)
43+
44+
# Prepare the tty for the user
45+
chown ${1} "/dev/tty${2}"
46+
chmod 600 "/dev/tty${2}"
47+
48+
# Setup a clean environment for the user, take over the target vt, then launch sway as non-root user
49+
su -l root -c "openvt -s -c ${2} -- su -l ${1} -c \"XDG_RUNTIME_DIR=/tmp WLR_LIBINPUT_NO_DEVICES=1 sway\""
50+
EOF
51+
}
52+
53+
sway_write_start_script() {
54+
cat << EOF > "${ROOTFS_PATH}"/etc/local.d/sway.start
55+
#!/bin/sh
56+
sway-launcher ${SERVICE_USER} 2
57+
EOF
58+
}
59+
60+
main() {
61+
printf "Adding packages\n"
62+
chroot_exec apk add ffmpeg \
63+
gstreamer \
64+
gstreamer-tools \
65+
gst-plugins-base \
66+
gst-plugins-bad \
67+
gst-plugins-good \
68+
iw \
69+
linux-firmware-cypress \
70+
mesa-dri-gallium \
71+
mpv \
72+
py3-pip \
73+
podman \
74+
seatd \
75+
sway \
76+
wpa_supplicant \
77+
xz
78+
79+
# Build dependencies - we remove them again later
80+
chroot_exec apk add gcc \
81+
git \
82+
jpeg-dev \
83+
libc-dev \
84+
libffi-dev \
85+
libxkbcommon-dev \
86+
py3-wheel \
87+
python3-dev \
88+
zlib-dev \
89+
90+
printf "Creating user\n"
91+
chroot_exec adduser --disabled-password ${SERVICE_USER}
92+
chroot_exec adduser ${SERVICE_USER} video
93+
chroot_exec adduser ${SERVICE_USER} seat
94+
95+
# Enable services
96+
chroot_exec rc-update add seatd
97+
chroot_exec rc-update add wpa_supplicant
98+
99+
# Add kernel modules to load
100+
cp /input/modules "${ROOTFS_PATH}"/etc/
101+
102+
# Load device tree overlay
103+
echo "dtoverlay=vc4-kms-v3d" >> "${BOOTFS_PATH}"/config.txt
104+
105+
setup_sway
106+
107+
# Add display-controller for stream handling
108+
printf "Adding display-controller\n"
109+
curl -s -S --output-dir "${ROOTFS_PATH}/usr/bin" -LO "${DISPLAY_CONTROLLER_URL}/controller.py"
110+
curl -s -S --output-dir "${ROOTFS_PATH}/home/${SERVICE_USER}" -LO "${DISPLAY_CONTROLLER_URL}/requirements.txt"
111+
chroot_exec pip install -r /home/${SERVICE_USER}/requirements.txt
112+
chmod +x "${ROOTFS_PATH}"/usr/bin/controller.py
113+
114+
# Add python-wayland
115+
printf "Adding python-wayland\n"
116+
mkdir -p "${ROOTFS_PATH}/usr/local/src"
117+
curl -s -S --output-dir "${ROOTFS_PATH}/usr/local/src/" -LO "${PYTHON_WAYLAND_URL}"
118+
chroot_exec cd /usr/local/src && tar xf "${PYTHON_WAYLAND_ARCHIVE}"
119+
120+
# Remove build dependencies
121+
chroot_exec apk del gcc \
122+
git \
123+
jpeg-dev \
124+
libc-dev \
125+
libffi-dev \
126+
libxkbcommon-dev \
127+
py3-wheel \
128+
python3-dev \
129+
zlib-dev
130+
131+
# Fetching streams playlist
132+
printf "Fetching streams playlist\n"
133+
curl -s -S --output-dir "${ROOTFS_PATH}"/home/${SERVICE_USER} -LO ${STREAMS_PLAYLIST_URL}
134+
}
135+
136+
main "$@"

input/modules

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
bcm2835_codec
2+
bcm2835_isp
3+
bcm2835_mmal_vchiq
4+
bcm2835_v4l2
5+
brcmfmac
6+
brcmutil
7+
i2c_bcm2835
8+
i2c-dev
9+
snd_bcm2835
10+
snd_soc_core
11+
snd_soc_hdmi_codec
12+
v4l2_mem2mem
13+
vc4
14+
videobuf2_common
15+
videobuf2_dma_config
16+
videobuf2_memops
17+
videobuf2_v4l2
18+
videobuf2_vmalloc

0 commit comments

Comments
 (0)