extract picons during build

This commit is contained in:
aptalca
2023-03-17 09:43:24 -04:00
parent 251f0dc45c
commit cf936490b9
6 changed files with 59 additions and 49 deletions

View File

@@ -1,5 +1,10 @@
# syntax=docker/dockerfile:1
############## picons stage ##############
# built by https://github.com/linuxserver/picons-builder
FROM ghcr.io/linuxserver/picons-builder as piconsstage
FROM ghcr.io/linuxserver/baseimage-alpine:3.17 as buildstage
############## build stage ##############
@@ -12,8 +17,9 @@ ARG TZ="Etc/UTC"
ARG TVHEADEND_COMMIT
ENV HOME="/config"
# copy patches
# copy patches and picons
COPY patches/ /tmp/patches/
COPY --from=piconsstage /picons.tar.bz2 /picons.tar.bz2
RUN \
echo "**** install build packages ****" && \
@@ -211,10 +217,12 @@ RUN \
make -j 2 && \
make DESTDIR=/tmp/comskip-build install
############## picons stage ##############
# built by https://github.com/linuxserver/picons-builder
FROM ghcr.io/linuxserver/picons-builder as piconsstage
RUN \
echo "***** extract picons ****" && \
mkdir -p /picons && \
tar xf \
/picons.tar.bz2 -C \
/picons
############## runtime stage ##############
FROM ghcr.io/linuxserver/baseimage-alpine:3.17
@@ -313,7 +321,7 @@ COPY --from=buildstage /tmp/tvheadend-build/usr/ /usr/
COPY --from=buildstage /tmp/xmltv-build/usr/ /usr/
COPY --from=buildstage /usr/local/share/man/ /usr/local/share/man/
COPY --from=buildstage /usr/local/share/perl5/ /usr/local/share/perl5/
COPY --from=piconsstage /picons.tar.bz2 /picons.tar.bz2
COPY --from=buildstage /picons /picons
COPY root/ /
# ports and volumes

View File

@@ -1,5 +1,10 @@
# syntax=docker/dockerfile:1
############## picons stage ##############
# built by https://github.com/linuxserver/picons-builder
FROM ghcr.io/linuxserver/picons-builder as piconsstage
FROM ghcr.io/linuxserver/baseimage-alpine:arm64v8-3.17 as buildstage
############## build stage ##############
@@ -12,8 +17,9 @@ ARG TZ="Etc/UTC"
ARG TVHEADEND_COMMIT
ENV HOME="/config"
# copy patches
# copy patches and picons
COPY patches/ /tmp/patches/
COPY --from=piconsstage /picons.tar.bz2 /picons.tar.bz2
RUN \
echo "**** install build packages ****" && \
@@ -211,9 +217,12 @@ RUN \
make -j 2 && \
make DESTDIR=/tmp/comskip-build install
############## picons stage ##############
# built by https://github.com/linuxserver/picons-builder
FROM ghcr.io/linuxserver/picons-builder as piconsstage
RUN \
echo "***** extract picons ****" && \
mkdir -p /picons && \
tar xf \
/picons.tar.bz2 -C \
/picons
############## runtime stage ##############
@@ -311,7 +320,7 @@ COPY --from=buildstage /tmp/tvheadend-build/usr/ /usr/
COPY --from=buildstage /tmp/xmltv-build/usr/ /usr/
COPY --from=buildstage /usr/local/share/man/ /usr/local/share/man/
COPY --from=buildstage /usr/local/share/perl5/ /usr/local/share/perl5/
COPY --from=piconsstage /picons.tar.bz2 /picons.tar.bz2
COPY --from=buildstage /picons /picons
COPY root/ /
# ports and volumes

View File

@@ -301,6 +301,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
## Versions
* **17.03.23:** - Extract picons during build instead of init.
* **23.02.23:** - Rebase to Alpine 3.17, migrate to s6v3, drop armhf support.
* **31.08.22:** - Update sample env vars and how RUN_OPTS are handled.
* **19.08.22:** - Switch to new picons builder.

View File

@@ -123,6 +123,7 @@ app_setup_block: |
# changelog
changelogs:
- { date: "17.03.23:", desc: "Extract picons during build instead of init." }
- { date: "23.02.23:", desc: "Rebase to Alpine 3.17, migrate to s6v3, drop armhf support." }
- { date: "31.08.22:", desc: "Update sample env vars and how RUN_OPTS are handled." }
- { date: "19.08.22:", desc: "Switch to new picons builder." }

View File

@@ -3,37 +3,28 @@
# make folders
mkdir -p \
/config/comskip
/config/comskip
# copy config
if [[ ! -e /config/dvr/config ]]; then
(mkdir -p /config/dvr/config && cp /defaults/7a5edfbe189851e5b1d1df19c93962f0 /config/dvr/config/7a5edfbe189851e5b1d1df19c93962f0)
(mkdir -p /config/dvr/config && cp /defaults/7a5edfbe189851e5b1d1df19c93962f0 /config/dvr/config/7a5edfbe189851e5b1d1df19c93962f0)
fi
if [[ ! -e /config/comskip/comskip.ini ]]; then
cp /defaults/comskip.ini.org /config/comskip/comskip.ini
cp /defaults/comskip.ini.org /config/comskip/comskip.ini
fi
if [[ ! -e /config/config ]]; then
(cp /defaults/config /config/config)
fi
# extract picons on first run
if [[ -f /picons.tar.bz2 ]]; then
mkdir -p /picons
tar xf \
/picons.tar.bz2 -C \
/picons &&
rm -f /picons.tar.bz2
fi
# function to randomly sample 5 files for their owner and only chown if not abc
chowner () {
files=(${1}/*)
for i in {1..5}; do
user=$(stat -c '%U' $(printf "%s\n" "${files[RANDOM % ${#files[@]}]}"))
if [ "${user}" != "abc" ]; then
chown -R abc:abc ${1}
break
fi
user=$(stat -c '%U' $(printf "%s\n" "${files[RANDOM % ${#files[@]}]}"))
if [ "${user}" != "abc" ]; then
chown -R abc:abc ${1}
break
fi
done
}
@@ -44,9 +35,9 @@ abc_dirs=( \
/picons \
)
for i in "${abc_dirs[@]}"; do
if [ "$(ls -A ${i})" ]; then
chowner ${i}
else
chown -R abc:abc ${i}
fi
if [ "$(ls -A ${i})" ]; then
chowner ${i}
else
chown -R abc:abc ${i}
fi
done

View File

@@ -5,23 +5,23 @@ FILES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)
for i in $FILES
do
VIDEO_GID=$(stat -c '%g' "$i")
if id -G abc | grep -qw "$VIDEO_GID"; then
touch /groupadd
else
if [ ! "${VIDEO_GID}" == '0' ]; then
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
if [ -z "${VIDEO_NAME}" ]; then
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-z0-9' | head -c8)"
groupadd "$VIDEO_NAME"
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
fi
usermod -a -G "$VIDEO_NAME" abc
touch /groupadd
fi
fi
VIDEO_GID=$(stat -c '%g' "$i")
if id -G abc | grep -qw "$VIDEO_GID"; then
touch /groupadd
else
if [ ! "${VIDEO_GID}" == '0' ]; then
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
if [ -z "${VIDEO_NAME}" ]; then
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-z0-9' | head -c8)"
groupadd "$VIDEO_NAME"
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
fi
usermod -a -G "$VIDEO_NAME" abc
touch /groupadd
fi
fi
done
if [ -n "${FILES}" ] && [ ! -f "/groupadd" ]; then
usermod -a -G root abc
usermod -a -G root abc
fi