Skip to content

Commit b5c791b

Browse files
authored
Remove external script sources (#117)
1 parent 2024162 commit b5c791b

7 files changed

Lines changed: 175 additions & 142 deletions

File tree

issue-report.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ ffmpeg_version=ffmpeg
99
# shellcheck source=/.github/workflows/mock/VERSION
1010
source "/etc/VERSION"
1111

12-
# shellcheck source=/utils/patch_config.sh
13-
source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null ||
14-
source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null ||
15-
echo "No patch_config.sh"
16-
17-
# shellcheck source=/utils/patch_config.sh
18-
source "/var/packages/VideoStation/patch/patch_config.sh" 2> /dev/null ||
19-
source "/var/packages/CodecPack/patch/patch_config.sh" 2> /dev/null ||
20-
echo "No patch_utils.sh"
21-
2212
dsm_version="$productversion $buildnumber-$smallfixnumber"
2313
vs_path=/var/packages/VideoStation
2414
cp_path=/var/packages/CodecPack

patcher.sh

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ patch() {
207207
chmod u+s "$vs_path/bin/$filename"
208208

209209
sed -i -e "s/@package_name@/VideoStation/" "$vs_path/bin/$filename"
210+
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$vs_path/bin/$filename"
210211
fi
211212
done
212213

@@ -224,6 +225,7 @@ patch() {
224225
chmod u+s "$cp_bin_path/$filename"
225226

226227
sed -i -e "s/@package_name@/CodecPack/" "$cp_bin_path/$filename"
228+
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$cp_bin_path/$filename"
227229
fi
228230
done
229231

@@ -247,13 +249,6 @@ patch() {
247249
download "Gstreamer library: $lib" "$repo_base_url/$branch/libs/$lib" "$gst_lib_path/$lib"
248250
done
249251
fi
250-
251-
mkdir "$cp_base_path/patch"
252-
download "CodecPack's patch_config.sh" "$repo_base_url/$branch/utils/patch_config.sh" "$cp_base_path/patch/patch_config.sh"
253-
download "CodecPack's patch_utils.sh" "$repo_base_url/$branch/utils/patch_utils.sh" "$cp_base_path/patch/patch_utils.sh"
254-
255-
info "Setting CodecPack's ffmpeg version to: ffmpeg$ffmpegversion"
256-
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$cp_base_path/patch/patch_config.sh"
257252
fi
258253

259254
if [[ -f "$vs_path/bin/gst-launch-1.0" ]]; then
@@ -283,13 +278,6 @@ patch() {
283278
cp -n "$cp_path/etc/gstomx.conf" "$vs_path/etc/gstomx.conf"
284279
fi
285280

286-
mkdir "$vs_base_path/patch"
287-
download "VideoStation's patch_config.sh" "$repo_base_url/$branch/utils/patch_config.sh" "$vs_base_path/patch/patch_config.sh"
288-
download "VideoStation's patch_utils.sh" "$repo_base_url/$branch/utils/patch_utils.sh" "$vs_base_path/patch/patch_utils.sh"
289-
290-
info "Setting ffmpeg version to: ffmpeg$ffmpegversion"
291-
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$vs_base_path/patch/patch_config.sh"
292-
293281
info "Saving current libsynovte.so as libsynovte.so.orig"
294282
cp -n "$libsynovte_path" "$libsynovte_path.orig"
295283
chown VideoStation:VideoStation "$libsynovte_path.orig"
@@ -336,9 +324,6 @@ unpatch() {
336324
rm -rf "$cp_path/lib/gstreamer/patch"
337325
rm -rf "$cp_path/lib/gstreamer/gstreamer-1.0/patch"
338326
fi
339-
340-
info "Remove CodecPack's patch directory"
341-
rm -rf "$cp_base_path/patch"
342327
fi
343328

344329
if [[ -f "$vs_path/bin/gst-launch-1.0" ]]; then
@@ -354,9 +339,6 @@ unpatch() {
354339
fi
355340
fi
356341

357-
info "Remove VideoStation's patch directory."
358-
rm -rf "$vs_base_path/patch"
359-
360342
restart_packages
361343
clean
362344

utils/patch_config.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

utils/patch_utils.sh

Lines changed: 0 additions & 87 deletions
This file was deleted.

wrappers/ffmpeg.sh

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
#!/bin/bash
22

3-
# shellcheck source=/utils/patch_utils.sh
4-
source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null ||
5-
source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null ||
6-
{ echo "Cannot load patch_utils.sh" >> "/tmp/ffmpeg-0.stderr.prev" && echo "Cannot load patch_utils.sh" && exit 1; }
7-
83
#########################
94
# VARS
105
#########################
116

12-
ffmpeg_version=ffmpeg
7+
ffmpeg_version=@ffmpeg_version@
138
pid=$$
149
child=""
1510
stderrfile="/tmp/ffmpeg-$pid.stderr"
@@ -18,13 +13,90 @@ path=$(realpath "$0")
1813
args=()
1914

2015
#########################
21-
# LOAD CONFIG
16+
# UTILS
2217
#########################
2318

24-
# shellcheck source=/utils/patch_config.sh
25-
source "/var/packages/VideoStation/patch/patch_config.sh" 2> /dev/null ||
26-
source "/var/packages/CodecPack/patch/patch_config.sh" 2> /dev/null ||
27-
{ echo "Cannot load patch_config.sh" >> "/tmp/ffmpeg-0.stderr.prev" && echo "Cannot load patch_config.sh" && exit 1; }
19+
log() {
20+
local now
21+
now=$(date '+%Y-%m-%d %H:%M:%S')
22+
echo "[$now] [$1] $2" >> "$stderrfile"
23+
}
24+
25+
newline() {
26+
echo "" >> "$stderrfile"
27+
}
28+
29+
info() {
30+
log "INFO" "$1"
31+
}
32+
33+
kill_child() {
34+
if [[ "$child" != "" ]]; then
35+
kill "$child" > /dev/null 2> /dev/null || :
36+
fi
37+
}
38+
39+
endprocess() {
40+
info "========================================[end $0 $pid]"
41+
newline
42+
43+
if [[ $errcode -eq 1 ]]; then
44+
cp "$stderrfile" "$stderrfile.prev"
45+
fi
46+
47+
kill_child
48+
rm -f "$stderrfile"
49+
50+
exit "$errcode"
51+
}
52+
53+
handle_error() {
54+
log "ERROR" "An error occurred"
55+
newline
56+
errcode=1
57+
kill_child
58+
}
59+
60+
fix_args() {
61+
while [[ $# -gt 0 ]]; do
62+
case "$1" in
63+
-acodec)
64+
shift
65+
if [[ "$1" = "libfaac" ]]; then
66+
args+=("-acodec" "aac")
67+
else
68+
args+=("-acodec" "libfdk_aac")
69+
fi
70+
;;
71+
72+
-vf)
73+
shift
74+
arg="$1"
75+
76+
if [[ "$arg" =~ "scale_vaapi" ]]; then
77+
scale_w=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\1/p')
78+
scale_h=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\2/p')
79+
80+
if (( scale_w && scale_h )); then
81+
arg="scale_vaapi=w=$scale_w:h=$scale_h:format=nv12,hwupload,setsar=sar=1"
82+
else
83+
arg="scale_vaapi=format=nv12,hwupload,setsar=sar=1"
84+
fi
85+
fi
86+
87+
args+=("-vf" "$arg")
88+
;;
89+
90+
-r)
91+
shift
92+
;;
93+
94+
*) args+=("$1") ;;
95+
esac
96+
97+
shift
98+
done
99+
}
28100

29101
#########################
30102
# ENTRYPOINT

wrappers/gst-inspect-1.0.sh

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
export GST_DEBUG=1 #1: ERROR (Log fatal errors only).
44

5-
# shellcheck source=/utils/patch_utils.sh
6-
source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null ||
7-
source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null ||
8-
{ echo "Cannot load patch_utils.sh" >> "/tmp/gstinspect-0.stderr.prev" && echo "Cannot load patch_utils.sh" && exit 1; }
9-
105
#########################
116
# VARS
127
#########################
@@ -17,6 +12,51 @@ stderrfile="/tmp/gstinspect-$pid.stderr"
1712
path=$(realpath "$0")
1813
errcode=0
1914

15+
#########################
16+
# UTILS
17+
#########################
18+
19+
log() {
20+
local now
21+
now=$(date '+%Y-%m-%d %H:%M:%S')
22+
echo "[$now] [$1] $2" >> "$stderrfile"
23+
}
24+
25+
newline() {
26+
echo "" >> "$stderrfile"
27+
}
28+
29+
info() {
30+
log "INFO" "$1"
31+
}
32+
33+
kill_child() {
34+
if [[ "$child" != "" ]]; then
35+
kill "$child" > /dev/null 2> /dev/null || :
36+
fi
37+
}
38+
39+
endprocess() {
40+
info "========================================[end $0 $pid]"
41+
newline
42+
43+
if [[ $errcode -eq 1 ]]; then
44+
cp "$stderrfile" "$stderrfile.prev"
45+
fi
46+
47+
kill_child
48+
rm -f "$stderrfile"
49+
50+
exit "$errcode"
51+
}
52+
53+
handle_error() {
54+
log "ERROR" "An error occurred"
55+
newline
56+
errcode=1
57+
kill_child
58+
}
59+
2060
#########################
2161
# ENTRYPOINT
2262
#########################

0 commit comments

Comments
 (0)