Continue refactoring

pull/109/head
AlexPresso 3 years ago
parent e85f6e7398
commit bf88223044

@ -197,21 +197,6 @@ patch() {
exit 1
fi
for filename in "${vs_scripts[@]}"; do
if [[ -f "$vs_base_path/scripts/$filename" ]]; then
info "Saving current $filename script as $filename.orig"
mv -n "$vs_base_path/scripts/$filename" "$vs_base_path/scripts/$filename.orig"
download "$filename.sh" "$repo_base_url/$branch/scripts/$filename.sh" "$vs_base_path/scripts/$filename"
info "Injecting script variables..."
repo_full_url="$repo_base_url/$branch"
sed -i -e "s|@repo_full_url@|$repo_full_url|" "$vs_base_path/scripts/$filename"
chmod 755 "$vs_base_path/scripts/$filename"
fi
done
for filename in "${wrappers[@]}"; do
if [[ -f "$vs_path/bin/$filename" ]]; then
info "Saving current $filename as $filename.orig"
@ -332,11 +317,6 @@ unpatch() {
mv -T -f "$filename" "${filename::-5}"
done
find "$vs_base_path/scripts" -type f -name "*.orig" | while read -r filename; do
info "Restoring VideoStation's $filename script"
mv -T -f "$filename" "${filename::-5}"
done
if [[ -d $cp_bin_path ]]; then
for file in "${cp_to_patch[@]}"; do
filename="${file%%:*}"

@ -1,6 +0,0 @@
#!/bin/sh
repo_full_url=@repo_full_url@
curl "$repo_full_url/patcher.sh" | bash -s -- -a unpatch
exit 0

@ -12,13 +12,17 @@ errcode=0
path=$(realpath "$0")
args=()
#########################
# UTILS
#########################
# shellcheck source=/utils/patch_config.sh
source "/var/packages/VideoStation/patch/patch_config.sh" | source "/var/packages/CodecPack/patch/patch_config.sh"
source "/var/packages/VideoStation/patch/patch_config.sh" || source "/var/packages/CodecPack/patch/patch_config.sh"
# shellcheck source=/utils/patch_utils.sh
source "/var/packages/VideoStation/patch/patch_utils.sh" | source "/var/packages/CodecPack/patch/patch_utils.sh"
source "/var/packages/VideoStation/patch/patch_utils.sh" || source "/var/packages/CodecPack/patch/patch_utils.sh"
#########################
# UTILS
# ENTRYPOINT
#########################
trap endprocess SIGINT SIGTERM
@ -29,11 +33,11 @@ rm -f /tmp/ffmpeg*.stderr.prev
fix_args "$@"
newline
info "========================================[start ffmpeg $pid]"
info "========================================[start $0 $pid]"
info "DEFAULT ARGS: $*"
info "UPDATED ARGS: ${args[*]}"
info "Trying fixed args with $path..."
info "Trying fixed args with $path.orig ..."
"${path}.orig" "${args[@]}" <&0 2>> $stderrfile &
child=$!
wait "$child"
@ -43,7 +47,7 @@ if [[ $errcode -eq 0 ]]; then
fi
errcode=0
info "Trying default args with $path..."
info "Trying default args with $path.orig ..."
"${path}.orig" "$@" <&0 2>> $stderrfile &
child=$!
wait "$child"
@ -53,7 +57,7 @@ if [[ $errcode -eq 0 ]]; then
fi
errcode=0
info "Trying with SC's ffmpeg and fixed args..."
info "Trying with SC's $ffmpeg_version and fixed args..."
"/var/packages/${ffmpeg_version}/target/bin/ffmpeg" "${args[@]}" <&0 2>> $stderrfile &
child=$!
wait "$child"

@ -9,47 +9,15 @@ export GST_DEBUG=1 #1: ERROR (Log fatal errors only).
pid=$$
child=""
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"
}
handle_error() {
log "ERROR" "An error occurred"
newline
errcode=1
endprocess
}
endprocess() {
info "========================================[end gst $pid]"
newline
if [[ $errcode -eq 1 ]]; then
cp "$stderrfile" "$stderrfile.prev"
fi
rm "$stderrfile"
if [[ "$child" != "" ]]; then
kill "$child"
fi
exit $errcode
}
# shellcheck source=/utils/patch_utils.sh
source "/var/packages/VideoStation/patch/patch_utils.sh" || source "/var/packages/CodecPack/patch/patch_utils.sh"
#########################
# ENTRYPOINT
@ -64,7 +32,7 @@ newline
info "========================================[start gst-inspect $pid]"
info "GST_ARGS: $*"
/var/packages/VideoStation/target/bin/gst-inspect-1.0.orig "$@" 2>> $stderrfile &
"$path.orig" "$@" 2>> $stderrfile &
child=$!
wait "$child"

@ -9,47 +9,15 @@ export GST_DEBUG=1 #1: ERROR (Log fatal errors only).
pid=$$
child=""
stderrfile="/tmp/gstlaunch-$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"
}
handle_error() {
log "ERROR" "An error occurred"
newline
errcode=1
endprocess
}
endprocess() {
info "========================================[end gst $pid]"
newline
if [[ $errcode -eq 1 ]]; then
cp "$stderrfile" "$stderrfile.prev"
fi
rm "$stderrfile"
if [[ "$child" != "" ]]; then
kill "$child"
fi
exit $errcode
}
# shellcheck source=/utils/patch_utils.sh
source "/var/packages/VideoStation/patch/patch_utils.sh" || source "/var/packages/CodecPack/patch/patch_utils.sh"
#########################
# ENTRYPOINT
@ -61,10 +29,10 @@ trap handle_error ERR
rm -f /tmp/gstlaunch*.stderr.prev
newline
info "========================================[start gst-launch $pid]"
info "========================================[start $0 $pid]"
info "GST_ARGS: $*"
/var/packages/VideoStation/target/bin/gst-launch-1.0.orig "$@" 2>> $stderrfile &
"$path.orig" "$@" 2>> $stderrfile &
child=$!
wait "$child"

Loading…
Cancel
Save