This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 1deec946d645fddfa6ba838dfb86ca47516d0460 Author: Mihai Moldovan <ionic@ionic.de> Date: Fri May 7 09:01:27 2021 +0200 debian/: new file "proprocess.sh". Used to apply replacement tokens and run our new preprocessor. --- debian/changelog | 2 ++ debian/preprocess.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/debian/changelog b/debian/changelog index d2dcc19..1b2ec99 100644 --- a/debian/changelog +++ b/debian/changelog @@ -62,6 +62,8 @@ x2goclient (4.1.2.3-0x2go1) UNRELEASED; urgency=medium Mike's changes. + New file "preprocessor.pl". Simple text file preprocessor supporting basic condition logic. + + New file "proprocess.sh". Used to apply replacement tokens and run our + new preprocessor. [ Mike Gabriel ] * New upstream version (4.1.2.3): diff --git a/debian/preprocess.sh b/debian/preprocess.sh new file mode 100755 index 0000000..b1cde04 --- /dev/null +++ b/debian/preprocess.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +set -e + +typeset tmpfile="$('printf' 'mkstemp(template)\n' | 'm4' '-D' "template=${TMPDIR:-/tmp}/preprocTMPXXXXXXXXXXXXXXXX")" + +function cleanup () { + if [ -n "${tmpfile}" ] && [ -f "${tmpfile}" ]; then + 'rm' '-fv' "${tmpfile}" >&'2' + fi +} + +trap 'cleanup' 'EXIT' '6' 'BUS' 'ILL' 'KILL' 'QUIT' 'TERM' 'INT' 'PIPE' 'ALRM' 'USR1' 'USR2' + +function replace_kv () { + typeset key="${1:?'No key passed to replace_kv (), this is illegal.'}" + typeset value="${2:?'No value passed to replace_kv (), this is illegal.'}" + + 'sed' '-i' '-e' "s#@@${key}@@#${value}#g" "${tmpfile}" +} + +function main () { + typeset in_file="${1:?'No input file passed to main (), this is illegal.'}" + typeset out_file="${in_file%'.in'}" + + shift + + # Check if temporary file is set up correctly. + if [ -z "${tmpfile}" ]; then + printf 'No temporary file to write to available, erroring out.\n' >&'2' + return '1' + fi + + if ! [ -f "${tmpfile}" ]; then + printf 'Temporary file to write to "%s" not a regular file, erorring out.\n' "${tmpfile}" >&'2' + return '2' + fi + + # Check if in_file ends on ".in". + if [ "${in_file}" = "${out_file}" ]; then + printf 'Input file "%s" does not end in ".in", this is unsupported.\n' "${in_file}" >&'2' + return '3' + fi + + # Key-value pair arguments handling. + if [ '1' -gt "${#}" ]; then + printf 'At least one key-value pair must be provided.\n' >&'2' + return '4' + fi + + # Copy file contents to temporary file. + 'cp' "${in_file}" "${tmpfile}" + + typeset kv_i='' + for kv_i in "${@}"; do + typeset key="${kv_i%%'='*}" + typeset value="${kv_i#*'='}" + + if [ -z "${key}" ]; then + printf 'Key-value pair "%s" is invalid since it contains no key.\n' "${kv_i}" >&'2' + return '5' + fi + + 'replace_kv' "${key}" "${value}" + done + + # Now that all key-value pairs have been replaced, run the real + # preprocessor. + # We'll assume that cwd is the top source directory. Any other method, like + # autodetection, would be difficult to pull off portably. + 'debian/preprocessor.pl' "${tmpfile}" + + # And, eventually, replace the actual file. + 'cp' "${tmpfile}" "${out_file}" +} + +'main' "${@}" -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git