Skip to content

Commit 76f372b

Browse files
committed
zarf: streamlink update
1 parent 8707772 commit 76f372b

2 files changed

Lines changed: 18 additions & 61 deletions

File tree

zarf/docker/dockerfile.olive

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ WORKDIR /ctl
1919
RUN go build -ldflags "-X github.com/go-olive/olive/command.build=${BUILD_REF}"
2020

2121
# Run the Go Binary in Alpine.
22-
FROM alpine:3.16
22+
FROM alpine:3.17
2323
ENV OUTPUT_DIR="/downloads"
2424
ARG BUILD_DATE
2525
ARG BUILD_REF

zarf/streamlink/init.sh

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# Repo: https://github.com/cgomesu/tvhlink
1313
###########################################################################################
1414
# Notes
15+
# - System-wide Python3 pkgs now managed by APK. 'testing' repo of the 'edge' branch seems
16+
# to be pretty quick with release updates.
17+
# - PEP 668 in Python 3.11 disables global pip3 install
1518
# - Linuxserver.io changed location of custom scripts dir from /config/custom-cont-init.d
1619
# to /custom-cont-init.d
1720
# - Python 3.10.1 (edge branch) changes Python pkg directory
@@ -27,7 +30,7 @@
2730
# ghcr.io/linuxserver/tvheadend
2831
#
2932
# Script installs or upgrades the following pkg:
30-
# python3, python3-dev, pip, setuptools, streamlink
33+
# python3, streamlink
3134
#
3235
# Tested images (tvheadend:latest):
3336
# arm64:
@@ -38,7 +41,7 @@
3841
APK_BRANCH='edge'
3942
APK_MAIN="http://dl-cdn.alpinelinux.org/alpine/${APK_BRANCH:-edge}/main"
4043
APK_COMMUNITY="http://dl-cdn.alpinelinux.org/alpine/${APK_BRANCH:-edge}/community"
41-
APK_PY3_LXML='4.6.4'
44+
APK_TESTING="http://dl-cdn.alpinelinux.org/alpine/${APK_BRANCH:-edge}/testing"
4245

4346
# takes msg ($1) and status ($2) as args
4447
end () {
@@ -73,59 +76,17 @@ check_root () {
7376
if [ "$(id -u)" -eq 0 ]; then return 0; else return 1; fi
7477
}
7578

76-
python3_upgrade () {
77-
message "APK: Installing packages from the $APK_BRANCH branch." 'info'
78-
if ! apk add --upgrade --no-cache -X "$APK_MAIN" -X "$APK_COMMUNITY" python3 py3-pip "py3-lxml>$APK_PY3_LXML"; then
79-
end "APK: Critical error. Unable to upgrade or install Python3 and related packages from Alpine's $APK_BRANCH branch." 1
79+
streamlink_apk () {
80+
if ! apk add --upgrade -U -X "$APK_MAIN" -X "$APK_COMMUNITY" -X "$APK_TESTING" streamlink; then
81+
end 'APK: Critical error. Unable install required packages. Check previous messages.' 1
8082
fi
8183
}
8284

83-
streamlink_install () {
84-
message 'APK and PIP3: Installing required packages.' 'info'
85-
# install temporary build dependencies in .build-deps from default /etc/apk/repositories
86-
# this is required for building a few of the streamlink dependencies
87-
if ! apk add --no-cache --virtual .build-deps gcc musl-dev; then
88-
end 'APK: Critical error. Unable install required packages.' 1
89-
fi
90-
91-
if check_py3_pkg_exist pip; then
92-
# upgrade setuptools and pip before streamlink installation
93-
if ! pip3 install --no-cache-dir -U setuptools pip; then
94-
message 'PIP3: Error while upgrading setuptools and pip.' 'error'
95-
fi
96-
# after upgrade, let pip3 try to install streamlink until it succeed
97-
message 'PIP3: Installing Streamlink.' 'info'
98-
pip3 install --no-cache-dir streamlink
99-
else
100-
message 'PIP3: Critical error. pip3 should be installed but is not.' 'error'
101-
fi
102-
103-
# cleanup for temporary apk build dependencies
104-
message 'APK: Removing packages no longer required.' 'info'
105-
apk del .build-deps
106-
107-
# check that script succeeded to install streamlink or raise critical error
108-
if ! check_py3_pkg_exist streamlink; then
109-
end 'PIP3: Critical error. Cannot find Streamlink. Check above for installation errors.' 1
110-
fi
85+
python3_remove_all () {
86+
message 'APK: Python3 packages are now going to be managed by APK instead of PIP.' 'warning'
87+
apk del --no-cache streamlink py3-lxml py3-requests py3-pip python3
11188
}
11289

113-
streamlink_upgrade () {
114-
if check_py3_pkg_exist pip; then
115-
# upgrade setuptools and pip first
116-
if ! pip3 install --no-cache-dir -U setuptools pip; then
117-
message 'PIP3: Error while upgrading setuptools and pip.' 'error'
118-
fi
119-
# upgrade streamlink last and exit on error
120-
if ! pip3 install --no-cache-dir -U streamlink; then
121-
end "PIP3: Critical error. Unable to upgrade Streamlink. Current version is still $(streamlink --version)." 1
122-
fi
123-
else
124-
end 'PIP3: Critical error. pip3 should be installed but is not.' 1
125-
fi
126-
}
127-
128-
12990
############
13091
# main logic
13192
start
@@ -134,16 +95,12 @@ trap "end 'Received a signal to stop' 1" INT HUP TERM
13495

13596
if ! check_root; then end 'User is not root. This script needs root permission.' 1; fi
13697

137-
# upgrade to the latest available Python3 version and related APK packages
138-
# see https://github.com/cgomesu/tvhlink/issues/10
139-
# see https://github.com/cgomesu/tvhlink/issues/12
140-
message 'Upgrading Python3...' 'info'; python3_upgrade
141-
142-
if check_py3_pkg_exist streamlink; then
143-
message 'Upgrading Streamlink...' 'info'; streamlink_upgrade
144-
else
145-
message 'Installing Streamlink...' 'info'; streamlink_install
146-
fi
98+
# for backward compatibility, let APK manage Python3 pkgs
99+
# see https://github.com/cgomesu/tvhlink/issues/21
100+
if check_py3_pkg_exist pip; then python3_remove_all; fi
101+
message 'Installing/upgrading Streamlink...' 'info'
102+
streamlink_apk
147103

104+
# EOF
148105
message "Streamlink version: $(streamlink --version)." 'info'
149106
end 'Reached EOF without critical errors.' 0

0 commit comments

Comments
 (0)