Skip to content

Commit

Permalink
Remove external script sources (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPresso committed Dec 22, 2023
1 parent 2024162 commit b5c791b
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 142 deletions.
10 changes: 0 additions & 10 deletions issue-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ ffmpeg_version=ffmpeg
# shellcheck source=/.github/workflows/mock/VERSION
source "/etc/VERSION"

# shellcheck source=/utils/patch_config.sh
source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null ||
source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null ||
echo "No patch_config.sh"

# shellcheck source=/utils/patch_config.sh
source "/var/packages/VideoStation/patch/patch_config.sh" 2> /dev/null ||
source "/var/packages/CodecPack/patch/patch_config.sh" 2> /dev/null ||
echo "No patch_utils.sh"

dsm_version="$productversion $buildnumber-$smallfixnumber"
vs_path=/var/packages/VideoStation
cp_path=/var/packages/CodecPack
Expand Down
22 changes: 2 additions & 20 deletions patcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ patch() {
chmod u+s "$vs_path/bin/$filename"

sed -i -e "s/@package_name@/VideoStation/" "$vs_path/bin/$filename"
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$vs_path/bin/$filename"
fi
done

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

sed -i -e "s/@package_name@/CodecPack/" "$cp_bin_path/$filename"
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$cp_bin_path/$filename"
fi
done

Expand All @@ -247,13 +249,6 @@ patch() {
download "Gstreamer library: $lib" "$repo_base_url/$branch/libs/$lib" "$gst_lib_path/$lib"
done
fi

mkdir "$cp_base_path/patch"
download "CodecPack's patch_config.sh" "$repo_base_url/$branch/utils/patch_config.sh" "$cp_base_path/patch/patch_config.sh"
download "CodecPack's patch_utils.sh" "$repo_base_url/$branch/utils/patch_utils.sh" "$cp_base_path/patch/patch_utils.sh"

info "Setting CodecPack's ffmpeg version to: ffmpeg$ffmpegversion"
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$cp_base_path/patch/patch_config.sh"
fi

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

mkdir "$vs_base_path/patch"
download "VideoStation's patch_config.sh" "$repo_base_url/$branch/utils/patch_config.sh" "$vs_base_path/patch/patch_config.sh"
download "VideoStation's patch_utils.sh" "$repo_base_url/$branch/utils/patch_utils.sh" "$vs_base_path/patch/patch_utils.sh"

info "Setting ffmpeg version to: ffmpeg$ffmpegversion"
sed -i -e "s/@ffmpeg_version@/ffmpeg$ffmpegversion/" "$vs_base_path/patch/patch_config.sh"

info "Saving current libsynovte.so as libsynovte.so.orig"
cp -n "$libsynovte_path" "$libsynovte_path.orig"
chown VideoStation:VideoStation "$libsynovte_path.orig"
Expand Down Expand Up @@ -336,9 +324,6 @@ unpatch() {
rm -rf "$cp_path/lib/gstreamer/patch"
rm -rf "$cp_path/lib/gstreamer/gstreamer-1.0/patch"
fi

info "Remove CodecPack's patch directory"
rm -rf "$cp_base_path/patch"
fi

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

info "Remove VideoStation's patch directory."
rm -rf "$vs_base_path/patch"

restart_packages
clean

Expand Down
4 changes: 0 additions & 4 deletions utils/patch_config.sh

This file was deleted.

87 changes: 0 additions & 87 deletions utils/patch_utils.sh

This file was deleted.

94 changes: 83 additions & 11 deletions wrappers/ffmpeg.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#!/bin/bash

# shellcheck source=/utils/patch_utils.sh
source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null ||
source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null ||
{ echo "Cannot load patch_utils.sh" >> "/tmp/ffmpeg-0.stderr.prev" && echo "Cannot load patch_utils.sh" && exit 1; }

#########################
# VARS
#########################

ffmpeg_version=ffmpeg
ffmpeg_version=@ffmpeg_version@
pid=$$
child=""
stderrfile="/tmp/ffmpeg-$pid.stderr"
Expand All @@ -18,13 +13,90 @@ path=$(realpath "$0")
args=()

#########################
# LOAD CONFIG
# UTILS
#########################

# shellcheck source=/utils/patch_config.sh
source "/var/packages/VideoStation/patch/patch_config.sh" 2> /dev/null ||
source "/var/packages/CodecPack/patch/patch_config.sh" 2> /dev/null ||
{ echo "Cannot load patch_config.sh" >> "/tmp/ffmpeg-0.stderr.prev" && echo "Cannot load patch_config.sh" && exit 1; }
log() {
local now
now=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$now] [$1] $2" >> "$stderrfile"
}

newline() {
echo "" >> "$stderrfile"
}

info() {
log "INFO" "$1"
}

kill_child() {
if [[ "$child" != "" ]]; then
kill "$child" > /dev/null 2> /dev/null || :
fi
}

endprocess() {
info "========================================[end $0 $pid]"
newline

if [[ $errcode -eq 1 ]]; then
cp "$stderrfile" "$stderrfile.prev"
fi

kill_child
rm -f "$stderrfile"

exit "$errcode"
}

handle_error() {
log "ERROR" "An error occurred"
newline
errcode=1
kill_child
}

fix_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
-acodec)
shift
if [[ "$1" = "libfaac" ]]; then
args+=("-acodec" "aac")
else
args+=("-acodec" "libfdk_aac")
fi
;;

-vf)
shift
arg="$1"

if [[ "$arg" =~ "scale_vaapi" ]]; then
scale_w=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\1/p')
scale_h=$(echo "$arg" | sed -n 's/.*w=\([0-9]\+\):h=\([0-9]\+\).*/\2/p')

if (( scale_w && scale_h )); then
arg="scale_vaapi=w=$scale_w:h=$scale_h:format=nv12,hwupload,setsar=sar=1"
else
arg="scale_vaapi=format=nv12,hwupload,setsar=sar=1"
fi
fi

args+=("-vf" "$arg")
;;

-r)
shift
;;

*) args+=("$1") ;;
esac

shift
done
}

#########################
# ENTRYPOINT
Expand Down
50 changes: 45 additions & 5 deletions wrappers/gst-inspect-1.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

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

# shellcheck source=/utils/patch_utils.sh
source "/var/packages/VideoStation/patch/patch_utils.sh" 2> /dev/null ||
source "/var/packages/CodecPack/patch/patch_utils.sh" 2> /dev/null ||
{ echo "Cannot load patch_utils.sh" >> "/tmp/gstinspect-0.stderr.prev" && echo "Cannot load patch_utils.sh" && exit 1; }

#########################
# VARS
#########################
Expand All @@ -17,6 +12,51 @@ stderrfile="/tmp/gstinspect-$pid.stderr"
path=$(realpath "$0")
errcode=0

#########################
# UTILS
#########################

log() {
local now
now=$(date '+%Y-%m-%d %H:%M:%S')
echo "[$now] [$1] $2" >> "$stderrfile"
}

newline() {
echo "" >> "$stderrfile"
}

info() {
log "INFO" "$1"
}

kill_child() {
if [[ "$child" != "" ]]; then
kill "$child" > /dev/null 2> /dev/null || :
fi
}

endprocess() {
info "========================================[end $0 $pid]"
newline

if [[ $errcode -eq 1 ]]; then
cp "$stderrfile" "$stderrfile.prev"
fi

kill_child
rm -f "$stderrfile"

exit "$errcode"
}

handle_error() {
log "ERROR" "An error occurred"
newline
errcode=1
kill_child
}

#########################
# ENTRYPOINT
#########################
Expand Down
Loading

0 comments on commit b5c791b

Please sign in to comment.