From 1ce9ca372ae74ba1e82990c613afee9a93b7d132 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Mon, 28 Mar 2022 10:18:49 +0200 Subject: [PATCH 1/3] Scripts: Add .editorconfig with shfmt style definition Related: #2474 --- .editorconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.editorconfig b/.editorconfig index 86a0452e5f..af2ccf4ca2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,5 @@ # See https://editorconfig.org/ +# This file is used by editors, but also by automation such as `shfmt`. # This is the top-most .editorconfig file root = true @@ -16,5 +17,13 @@ indent_size = 4 indent_style = space indent_size = 2 +[*.sh] +shell_variant = bash +binary_next_line = false +switch_case_indent = true +space_redirects = true +keep_padding = true +function_next_line = false + [libs/**] ignore = true From a8f18a289aad6b33deaaf70dc432f54fcdc76129 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Mon, 28 Mar 2022 10:21:35 +0200 Subject: [PATCH 2/3] Scripts: Adjust code which `shfmt` can't handle properly Related: #2474 --- tools/changelog-helper.sh | 33 ++++++++++--------- tools/create-translation-issues.sh | 51 ++++++++++++++---------------- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/tools/changelog-helper.sh b/tools/changelog-helper.sh index abdc8319e6..4e0dd5dbd8 100755 --- a/tools/changelog-helper.sh +++ b/tools/changelog-helper.sh @@ -14,19 +14,18 @@ export GH_REPO=jamulussoftware/jamulus PR_LIST_LIMIT=300 TRANSLATION_ENTRY_TEXT="GUI: Translations have been updated:" -declare -A LANGS=( - [de_DE]="German" - [fr_FR]="French" - [it_IT]="Italian" - [nl_NL]="Dutch" - [pl_PL]="Polish" - [pt_BR]="Portuguese Brazilian" - [pt_PT]="Portuguese European" - [sk_SK]="Slovak" - [es_ES]="Spanish" - [sv_SE]="Swedish" - [zh_CN]="Simplified Chinese" -) +declare -A LANGS +LANGS[de_DE]="German" +LANGS[fr_FR]="French" +LANGS[it_IT]="Italian" +LANGS[nl_NL]="Dutch" +LANGS[pl_PL]="Polish" +LANGS[pt_BR]="Portuguese Brazilian" +LANGS[pt_PT]="Portuguese European" +LANGS[sk_SK]="Slovak" +LANGS[es_ES]="Spanish" +LANGS[sv_SE]="Swedish" +LANGS[zh_CN]="Simplified Chinese" find_or_add_missing_entries() { local changelog @@ -123,7 +122,7 @@ group_entries() { changelog=$(sed -re 's/^[0-9]+ (- )/\1/' <<<"$changelog") # Rebuild the changelog and write back to file: - (echo "$changelog_header"; echo "$changelog"; echo; echo; echo "$changelog_prev_releases") > ChangeLog + (echo "$changelog_header" && echo "$changelog" && echo && echo && echo "$changelog_prev_releases") > ChangeLog } declare -A checked_ids=() @@ -182,8 +181,8 @@ check_or_add_pr() { local changelog_before changelog_before=$(head -n "${changelog_begin_position}" ChangeLog) local changelog_after - changelog_after=$(tail -n "+$((changelog_begin_position+1))" ChangeLog) - (echo "$changelog_before"; echo; echo "$new_entry"; echo "$changelog_after") > ChangeLog + changelog_after=$(tail -n "+$((changelog_begin_position + 1))" ChangeLog) + (echo "$changelog_before" && echo && echo "$new_entry" && echo "$changelog_after") > ChangeLog } add_translation_pr() { @@ -257,7 +256,7 @@ add_translation_pr() { fi fi # Rebuild the changelog and write back to file: - (echo "$changelog_header"; echo "$changelog"; echo; echo "$changelog_prev_releases") > ChangeLog + (echo "$changelog_header" && echo "$changelog" && echo && echo "$changelog_prev_releases") > ChangeLog } sanitize_title() { diff --git a/tools/create-translation-issues.sh b/tools/create-translation-issues.sh index e97883c042..50f283e5e1 100755 --- a/tools/create-translation-issues.sh +++ b/tools/create-translation-issues.sh @@ -36,33 +36,30 @@ EXTRA_TEXT=${4:-} MILESTONE="Release ${RELEASE}" PROJECT=Tracking -declare -A TRANSLATORS_BY_LANG=( - # Syntax: - # [TYPE_LANG]="github-handle1,github-handle2" - # with TYPE being either app or web and - # with LANG being the language code (different syntax for app and web!) - - # App translators: - [app_de_DE]="rolamos" - [app_es_ES]="ignotus666" - [app_fr_FR]="jujudusud" - [app_it_IT]="dzpex" - [app_nl_NL]="henkdegroot,jerogee" - [app_pl_PL]="SeeLook" - [app_pt_BR]="melcon" - [app_pt_PT]="Snayler" - [app_sk_SK]="jose1711" - [app_sv_SE]="genesisproject2020" - [app_zh_CN]="BLumia" - - # Web translators: - [web_de]="Helondeth,ewarning" - [web_es]="ignotus666" - [web_fr]="jujudusud,trebmuh" - [web_it]="dzpex" - [web_nl]="henkdegroot" - [web_pt]="Snayler,melcon,ewarning" -) +# Syntax: +# TRANSLATORS_BY_LANG[TYPE_LANG]="github-handle1,github-handle2" +# with TYPE being either app or web and +# with LANG being the language code (different syntax for app and web!) +declare -A TRANSLATORS_BY_LANG +# App translators: +TRANSLATORS_BY_LANG[app_de_DE]="rolamos" +TRANSLATORS_BY_LANG[app_es_ES]="ignotus666" +TRANSLATORS_BY_LANG[app_fr_FR]="jujudusud" +TRANSLATORS_BY_LANG[app_it_IT]="dzpex" +TRANSLATORS_BY_LANG[app_nl_NL]="henkdegroot,jerogee" +TRANSLATORS_BY_LANG[app_pl_PL]="SeeLook" +TRANSLATORS_BY_LANG[app_pt_BR]="melcon" +TRANSLATORS_BY_LANG[app_pt_PT]="Snayler" +TRANSLATORS_BY_LANG[app_sk_SK]="jose1711" +TRANSLATORS_BY_LANG[app_sv_SE]="genesisproject2020" +TRANSLATORS_BY_LANG[app_zh_CN]="BLumia" +# Web translators: +TRANSLATORS_BY_LANG[web_de]="Helondeth,ewarning" +TRANSLATORS_BY_LANG[web_es]="ignotus666" +TRANSLATORS_BY_LANG[web_fr]="jujudusud,trebmuh" +TRANSLATORS_BY_LANG[web_it]="dzpex" +TRANSLATORS_BY_LANG[web_nl]="henkdegroot" +TRANSLATORS_BY_LANG[web_pt]="Snayler,melcon,ewarning" # shellcheck disable=SC2016 # shellcheck can't know that this will be used with envsubst, so verbatim variables are correct here. BODY_TEMPLATE_APP='Hi ${SPLIT_TRANSLATORS}, From 66bdcf2cf8806855f4ad5b0c20942070af2a0d19 Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Mon, 28 Mar 2022 10:22:05 +0200 Subject: [PATCH 3/3] Scripts: Run `shfmt -w .` Related: #2474 --- .github/autobuild/android.sh | 1 + .github/autobuild/ios.sh | 1 + .github/autobuild/linux_deb.sh | 4 +- .github/autobuild/mac.sh | 1 + distributions/raspijamulus.sh | 98 ++++++++++++------------ linux/deploy_deb.sh | 3 +- mac/deploy_mac.sh | 35 ++++----- tools/changelog-helper.sh | 35 +++++---- tools/check-wininstaller-translations.sh | 8 +- tools/create-translation-issues.sh | 43 +++++------ tools/update-copyright-notices.sh | 1 - 11 files changed, 114 insertions(+), 116 deletions(-) diff --git a/.github/autobuild/android.sh b/.github/autobuild/android.sh index 429b318ae5..d0a9cde29e 100755 --- a/.github/autobuild/android.sh +++ b/.github/autobuild/android.sh @@ -109,4 +109,5 @@ case "${1:-}" in *) echo "Unknown stage '${1:-}'" exit 1 + ;; esac diff --git a/.github/autobuild/ios.sh b/.github/autobuild/ios.sh index 7075baacbd..34820f5fe9 100755 --- a/.github/autobuild/ios.sh +++ b/.github/autobuild/ios.sh @@ -56,4 +56,5 @@ case "${1:-}" in *) echo "Unknown stage '${1:-}'" exit 1 + ;; esac diff --git a/.github/autobuild/linux_deb.sh b/.github/autobuild/linux_deb.sh index 21047719d0..c85d688da0 100755 --- a/.github/autobuild/linux_deb.sh +++ b/.github/autobuild/linux_deb.sh @@ -17,6 +17,7 @@ case "${TARGET_ARCH}" in *) echo "Unsupported TARGET_ARCH ${TARGET_ARCH}" exit 1 + ;; esac setup() { @@ -33,7 +34,7 @@ setup() { setup_cross_compilation_apt_sources() { if [[ "${TARGET_ARCH}" == amd64 ]]; then - return + return fi sudo dpkg --add-architecture "${TARGET_ARCH}" sed -rne "s|^deb.*/ ([^ -]+(-updates)?) main.*|deb [arch=${TARGET_ARCH}] http://ports.ubuntu.com/ubuntu-ports \1 main universe multiverse restricted|p" /etc/apt/sources.list | sudo dd of=/etc/apt/sources.list.d/"${TARGET_ARCH}".list @@ -88,4 +89,5 @@ case "${1:-}" in *) echo "Unknown stage '${1:-}'" exit 1 + ;; esac diff --git a/.github/autobuild/mac.sh b/.github/autobuild/mac.sh index d1146aee98..63f310893c 100755 --- a/.github/autobuild/mac.sh +++ b/.github/autobuild/mac.sh @@ -83,4 +83,5 @@ case "${1:-}" in *) echo "Unknown stage '${1:-}'" exit 1 + ;; esac diff --git a/distributions/raspijamulus.sh b/distributions/raspijamulus.sh index 71f777dbbc..af0eb2909f 100755 --- a/distributions/raspijamulus.sh +++ b/distributions/raspijamulus.sh @@ -9,28 +9,28 @@ readonly NCORES # install required packages readonly pkgs=(alsamixergui build-essential qtbase5-dev qttools5-dev-tools libasound2-dev cmake libglib2.0-dev) -if ! dpkg -s "${pkgs[@]}" >/dev/null 2>&1; then - read -p "Do you want to install missing packages? " -n 1 -r - echo - if [[ ${REPLY} =~ ^[Yy]$ ]]; then - sudo apt-get install "${pkgs[@]}" -y - # Raspbian 10 needs qt5-default; Raspbian 11 doesn't need or provide it - if ! qtchooser -list-versions | grep -q default; then - sudo apt-get install qt5-default -y +if ! dpkg -s "${pkgs[@]}" > /dev/null 2>&1; then + read -p "Do you want to install missing packages? " -n 1 -r + echo + if [[ ${REPLY} =~ ^[Yy]$ ]]; then + sudo apt-get install "${pkgs[@]}" -y + # Raspbian 10 needs qt5-default; Raspbian 11 doesn't need or provide it + if ! qtchooser -list-versions | grep -q default; then + sudo apt-get install qt5-default -y + fi fi - fi fi # Opus audio codec, custom compilation with custom modes and fixed point support if [ -d "${OPUS}" ]; then - echo "The Opus directory is present, we assume it is compiled and ready to use. If not, delete the opus directory and call this script again." + echo "The Opus directory is present, we assume it is compiled and ready to use. If not, delete the opus directory and call this script again." else - wget https://archive.mozilla.org/pub/opus/"${OPUS}.tar.gz" - tar -xzf "${OPUS}.tar.gz" - rm "${OPUS}.tar.gz" - cd "${OPUS}" || exit 1 - if [ "${OPUS}" == "opus-1.3.1" ]; then - echo "@@ -117,13 +117,19 @@ void validate_celt_decoder(CELTDecoder *st) + wget https://archive.mozilla.org/pub/opus/"${OPUS}.tar.gz" + tar -xzf "${OPUS}.tar.gz" + rm "${OPUS}.tar.gz" + cd "${OPUS}" || exit 1 + if [ "${OPUS}" == "opus-1.3.1" ]; then + echo "@@ -117,13 +117,19 @@ void validate_celt_decoder(CELTDecoder *st) #ifndef CUSTOM_MODES celt_assert(st->mode == opus_custom_mode_create(48000, 960, NULL)); celt_assert(st->overlap == 120); @@ -51,37 +51,37 @@ else #ifdef OPUS_ARCHMASK celt_assert(st->arch >= 0); celt_assert(st->arch <= OPUS_ARCHMASK);" >> opus_patch_file.diff - patch celt/celt_decoder.c opus_patch_file.diff - fi - ./configure --enable-custom-modes --enable-fixed-point - make "-j${NCORES}" - mkdir include/opus - cp include/*.h include/opus - cd .. + patch celt/celt_decoder.c opus_patch_file.diff + fi + ./configure --enable-custom-modes --enable-fixed-point + make "-j${NCORES}" + mkdir include/opus + cp include/*.h include/opus + cd .. fi # Jack audio without DBUS support if [ -d "jack2" ]; then - echo "The Jack2 directory is present, we assume it is compiled and ready to use. If not, delete the jack2 directory and call this script again." + echo "The Jack2 directory is present, we assume it is compiled and ready to use. If not, delete the jack2 directory and call this script again." else - git clone https://github.com/jackaudio/jack2.git - cd jack2 || exit 1 - git checkout v1.9.20 - ./waf configure --alsa --prefix=/usr/local "--libdir=$(pwd)/build" - ./waf "-j${NCORES}" - mkdir build/jack - cp build/*.so build/jack - cp build/common/*.so build/jack - cp build/example-clients/*.so build/jack - cd .. + git clone https://github.com/jackaudio/jack2.git + cd jack2 || exit 1 + git checkout v1.9.20 + ./waf configure --alsa --prefix=/usr/local "--libdir=$(pwd)/build" + ./waf "-j${NCORES}" + mkdir build/jack + cp build/*.so build/jack + cp build/common/*.so build/jack + cp build/example-clients/*.so build/jack + cd .. - # give audio group rights to do realtime - if grep -Fq "@audio" /etc/security/limits.conf; then - echo "audio group already has realtime rights" - else - sudo sh -c 'echo "@audio - rtprio 95" >> /etc/security/limits.conf' - sudo sh -c 'echo "@audio - memlock unlimited" >> /etc/security/limits.conf' - fi + # give audio group rights to do realtime + if grep -Fq "@audio" /etc/security/limits.conf; then + echo "audio group already has realtime rights" + else + sudo sh -c 'echo "@audio - rtprio 95" >> /etc/security/limits.conf' + sudo sh -c 'echo "@audio - memlock unlimited" >> /etc/security/limits.conf' + fi fi # compile Jamulus with external Opus library @@ -90,21 +90,21 @@ qmake "CONFIG+=opus_shared_lib raspijamulus headless" "INCLUDEPATH+=distribution make "-j${NCORES}" # get first USB audio sound card device -ADEVICE=$(aplay -l|grep "USB Audio"|tail -1|cut -d' ' -f3) +ADEVICE=$(aplay -l | grep "USB Audio" | tail -1 | cut -d' ' -f3) echo "Using USB audio device: ${ADEVICE}" # write Jamulus ini file for setting the client name and buffer settings, if there is # just one CPU core, we assume that we are running on a Raspberry Pi Zero JAMULUSINIFILE="Jamulus.ini" -NAME64=$(echo "Raspi $(hostname)"|cut -c -16|tr -d $'\n'|base64) +NAME64=$(echo "Raspi $(hostname)" | cut -c -16 | tr -d $'\n' | base64) if [ "$NCORES" -gt "1" ]; then - echo -e "\n ${NAME64}" > ${JAMULUSINIFILE} - echo -e " 1\n 3\n 3" >> ${JAMULUSINIFILE} - echo -e " 2\n 1\n" >> ${JAMULUSINIFILE} + echo -e "\n ${NAME64}" > ${JAMULUSINIFILE} + echo -e " 1\n 3\n 3" >> ${JAMULUSINIFILE} + echo -e " 2\n 1\n" >> ${JAMULUSINIFILE} else - echo -e "\n ${NAME64}" > ${JAMULUSINIFILE} - echo -e " 1\n 3\n 3" >> ${JAMULUSINIFILE} - echo -e " 0\n 1\n" >> ${JAMULUSINIFILE} + echo -e "\n ${NAME64}" > ${JAMULUSINIFILE} + echo -e " 1\n 3\n 3" >> ${JAMULUSINIFILE} + echo -e " 0\n 1\n" >> ${JAMULUSINIFILE} fi # taken from "Raspberry Pi and realtime, low-latency audio" homepage at wiki.linuxaudio.org diff --git a/linux/deploy_deb.sh b/linux/deploy_deb.sh index 475463f5b7..ba2dd0e838 100755 --- a/linux/deploy_deb.sh +++ b/linux/deploy_deb.sh @@ -16,8 +16,7 @@ export DEBFULLNAME=GitHubActions DEBEMAIL=noemail@example.com echo -n generating changelog rm -f debian/changelog dch --create --package jamulus --empty --newversion "${VERSION}" '' -perl .github/actions_scripts/getChangelog.pl ChangeLog "${VERSION}" --line-per-entry | while read -r entry -do +perl .github/actions_scripts/getChangelog.pl ChangeLog "${VERSION}" --line-per-entry | while read -r entry; do echo -n . dch "$entry" done diff --git a/mac/deploy_mac.sh b/mac/deploy_mac.sh index 9a4514f379..5546ab36bc 100755 --- a/mac/deploy_mac.sh +++ b/mac/deploy_mac.sh @@ -26,8 +26,7 @@ while getopts 'hs:' flag; do esac done -cleanup() -{ +cleanup() { # Clean up previous deployments rm -rf "${build_path}" rm -rf "${deploy_path}" @@ -35,9 +34,7 @@ cleanup() mkdir -p "${deploy_path}" } - -build_app() -{ +build_app() { local client_or_server="${1}" # Build Jamulus @@ -71,11 +68,11 @@ build_app() *) echo "build_app: invalid parameter '${client_or_server}'" exit 1 + ;; esac } -build_installer_image() -{ +build_installer_image() { local client_target_name="${1}" local server_target_name="${2}" @@ -90,18 +87,18 @@ build_installer_image() # Build installer image create-dmg \ - --volname "${client_target_name} Installer" \ - --background "${resources_path}/installerbackground.png" \ - --window-pos 200 400 \ - --window-size 900 320 \ - --app-drop-link 820 210 \ - --text-size 12 \ - --icon-size 72 \ - --icon "${client_target_name}.app" 630 210 \ - --icon "${server_target_name}.app" 530 210 \ - --eula "${root_path}/COPYING" \ - "${deploy_path}/${client_target_name}-${app_version}-installer-mac.dmg" \ - "${deploy_path}/" + --volname "${client_target_name} Installer" \ + --background "${resources_path}/installerbackground.png" \ + --window-pos 200 400 \ + --window-size 900 320 \ + --app-drop-link 820 210 \ + --text-size 12 \ + --icon-size 72 \ + --icon "${client_target_name}.app" 630 210 \ + --icon "${server_target_name}.app" 530 210 \ + --eula "${root_path}/COPYING" \ + "${deploy_path}/${client_target_name}-${app_version}-installer-mac.dmg" \ + "${deploy_path}/" } brew_install_pinned() { diff --git a/tools/changelog-helper.sh b/tools/changelog-helper.sh index 4e0dd5dbd8..9255d40c65 100755 --- a/tools/changelog-helper.sh +++ b/tools/changelog-helper.sh @@ -46,7 +46,7 @@ find_or_add_missing_entries() { echo echo "Checking if all PR or references in git log since ${prev_release_tag} are included for ${target_release} based on ref ${target_ref}..." for id in $(git log "${prev_release_tag}..master" | grep -oP '#\K(\d+)'); do - gh pr view "${id}" --json title &>/dev/null || continue # Skip non-PRs + gh pr view "${id}" --json title &> /dev/null || continue # Skip non-PRs check_or_add_pr "${id}" done @@ -76,7 +76,7 @@ group_entries() { changelog=$(sed -rne '/^###.*'"${target_release//./\.}"'\b/,/^### '"${prev_release//./\.}"'\b/p' ChangeLog | tail -n +2 | head -n -1) # Remove trailing whitespace on all lines of the current changelog: - changelog=$(sed -re 's/\s+$//' <<<"$changelog") + changelog=$(sed -re 's/\s+$//' <<< "$changelog") # Prepend a number to known categories in order to make their sorting position consistent: category_order=( @@ -105,21 +105,21 @@ group_entries() { ) local index=0 for category in "${category_order[@]}"; do - changelog=$(sed -re 's/^(- '"${category}"')/'"${index}"' \1/' <<<"${changelog}") - index=$((index+1)) + changelog=$(sed -re 's/^(- '"${category}"')/'"${index}"' \1/' <<< "${changelog}") + index=$((index + 1)) done # Reduce blocks ("entries") to a single line by replacing \n with \v. # `sort` then works on those reduced lines and sorts them by the category (e.g. Server:) # Afterwards, convert \v to \n again: changelog=$( - sed -r ':r;/(^|\n)$/!{$!{N;br}};s/\n/\v/g' <<<"$changelog" | - LC_ALL=C sort --stable --numeric-sort --field-separator=':' -k1,1 | - sed 's/\v/\n/g' + sed -r ':r;/(^|\n)$/!{$!{N;br}};s/\n/\v/g' <<< "$changelog" | + LC_ALL=C sort --stable --numeric-sort --field-separator=':' -k1,1 | + sed 's/\v/\n/g' ) # Remove temporary sorting indices at line start again: - changelog=$(sed -re 's/^[0-9]+ (- )/\1/' <<<"$changelog") + changelog=$(sed -re 's/^[0-9]+ (- )/\1/' <<< "$changelog") # Rebuild the changelog and write back to file: (echo "$changelog_header" && echo "$changelog" && echo && echo && echo "$changelog_prev_releases") > ChangeLog @@ -132,7 +132,7 @@ check_or_add_pr() { return fi checked_ids[$id]=1 - if grep -qE "#$id\>" <<<"$changelog"; then + if grep -qE "#$id\>" <<< "$changelog"; then # Changelog already lists this PR ID -> nothing to do # (\> ensures that we only match full, standalone IDs) return @@ -140,11 +140,11 @@ check_or_add_pr() { local json json=$(gh pr view "${id/#/}" --json title,author,state) local state - state=$(jq -r .state <<<"${json}") + state=$(jq -r .state <<< "${json}") local title - title=$(jq -r .title <<<"${json}" | sanitize_title) + title=$(jq -r .title <<< "${json}" | sanitize_title) local author - author=$(jq -r .author.login <<<"${json}") + author=$(jq -r .author.login <<< "${json}") if [[ "${state}" != "MERGED" ]]; then echo "-> Ignoring PR #${id} as state ${state} != MERGED" return @@ -166,7 +166,7 @@ check_or_add_pr() { echo ", adding new entry" local new_entry="" local lang - lang=$(grep -oP 'Updated? \K(\S+)(?= app translations? for )' <<<"$title" || true) + lang=$(grep -oP 'Updated? \K(\S+)(?= app translations? for )' <<< "$title" || true) if [[ "${lang}" ]]; then # Note: This creates a top-level entry for each language. # group-entries can merge those to a single one. @@ -208,10 +208,10 @@ add_translation_pr() { local changelog_orig="${changelog}" # Is there an existing entry for this language already? - changelog=$(sed -re "s/^( \* ${full_lang}, by .+ \(.*)\)/\1, #${id})/" <<<"${changelog}") + changelog=$(sed -re "s/^( \* ${full_lang}, by .+ \(.*)\)/\1, #${id})/" <<< "${changelog}") if [[ "${changelog}" == "${changelog_orig}" ]]; then # No existing language entry. Check for an existing translation entry. - changelog=$(sed -re "s/^(- ${TRANSLATION_ENTRY_TEXT}.*)/\1\n * ${full_lang}, by @${author} (#${id})/" <<<"${changelog}") + changelog=$(sed -re "s/^(- ${TRANSLATION_ENTRY_TEXT}.*)/\1\n * ${full_lang}, by @${author} (#${id})/" <<< "${changelog}") if [[ "${changelog}" == "${changelog_orig}" ]]; then # No existing translation entry at all. Add a new one. changelog="${changelog}$( @@ -219,7 +219,7 @@ add_translation_pr() { echo echo "- ${TRANSLATION_ENTRY_TEXT}" echo " * ${full_lang}, by @${author} (#${id})" - )" + )" else # Existing translation entries, so sort them: local changelog_before_translations="" @@ -289,6 +289,7 @@ case "${1:-1}" in *) echo "ERROR: Bad invocation, see --help" exit 1 + ;; esac target_release=$(grep -oP '^### .*\K(\d+\.\d+\.\d+)\b' ChangeLog | head -n1) @@ -301,7 +302,7 @@ echo "Auto-detected previous release: ${prev_release}" echo case "$ACTION" in - find-missing-entries|add-missing-entries) + find-missing-entries | add-missing-entries) find_or_add_missing_entries ;; group-entries) diff --git a/tools/check-wininstaller-translations.sh b/tools/check-wininstaller-translations.sh index 098110a657..556e0d2c8c 100755 --- a/tools/check-wininstaller-translations.sh +++ b/tools/check-wininstaller-translations.sh @@ -15,7 +15,7 @@ for LANGUAGE_FILE in src/translation/wininstaller/{??.nsi,??_??.nsi}; do echo -n " - Checking language file is included in ${INSTALLERLNG}... " # shellcheck disable=SC2016 # shellcheck is confused here as NSI files use variables which look like shell variables # shellcheck disable=SC1003 # shellcheck misinterprets the verbatim backslash as an attempt to escape the single quote. it's not. - if grep -q '^!include "\${ROOT_PATH}\\'"$(sed -re 's|/|\\\\|g' <<<"${LANGUAGE_FILE}")"'"' "${BASE_DIR}/${INSTALLERLNG}"; then + if grep -q '^!include "\${ROOT_PATH}\\'"$(sed -re 's|/|\\\\|g' <<< "${LANGUAGE_FILE}")"'"' "${BASE_DIR}/${INSTALLERLNG}"; then echo "ok" else echo "ERROR" @@ -40,7 +40,7 @@ for LANGUAGE_FILE in src/translation/wininstaller/{??.nsi,??_??.nsi}; do echo -n " - Checking for wrong macros... " LANG_MACROS=$(grep -oP '\$\{LANG_[^}]+\}' "${LANGUAGE_FILE}") - if grep ENGLISH <<<"$LANG_MACROS"; then + if grep ENGLISH <<< "$LANG_MACROS"; then echo "ERROR, found LANG_ENGLISH" EXIT=1 else @@ -48,7 +48,7 @@ for LANGUAGE_FILE in src/translation/wininstaller/{??.nsi,??_??.nsi}; do fi echo -n " - Checking for multiple lang macros... " - if [[ $(sort -u <<<"$LANG_MACROS" | wc -l) != 1 ]]; then + if [[ $(sort -u <<< "$LANG_MACROS" | wc -l) != 1 ]]; then echo "ERROR, found multiple LANG_ macros" EXIT=1 else @@ -56,7 +56,7 @@ for LANGUAGE_FILE in src/translation/wininstaller/{??.nsi,??_??.nsi}; do fi echo -n " - Checking if LANG_ macro is in ${INSTALLERLNG}..." - LANG_NAME=$(sort -u <<<"${LANG_MACROS}" | sed -rne 's/\$\{LANG_(.*)\}/\1/p') + LANG_NAME=$(sort -u <<< "${LANG_MACROS}" | sed -rne 's/\$\{LANG_(.*)\}/\1/p') if grep -qi '^!insertmacro MUI_LANGUAGE "'"${LANG_NAME}"'"' "$BASE_DIR/${INSTALLERLNG}"; then echo "ok" else diff --git a/tools/create-translation-issues.sh b/tools/create-translation-issues.sh index 50f283e5e1..2a7d3cd11f 100755 --- a/tools/create-translation-issues.sh +++ b/tools/create-translation-issues.sh @@ -18,14 +18,14 @@ set -eu -if [[ -z ${1:-} ]] || [[ -z ${2:-} ]] || [[ -z ${3:-} ]] ; then +if [[ -z ${1:-} ]] || [[ -z ${2:-} ]] || [[ -z ${3:-} ]]; then echo "Syntax: $0 RELEASE DEADLINE app|web [EXTRA_TEXT]" exit 1 fi -if ! gh auth status &>/dev/null; then - echo "Error: Please ensure that Github CLI is installed and you are logged in" >/dev/stderr - echo "Cannot continue. Exit." >/dev/stderr +if ! gh auth status &> /dev/null; then + echo "Error: Please ensure that Github CLI is installed and you are logged in" > /dev/stderr + echo "Cannot continue. Exit." > /dev/stderr exit 1 fi @@ -86,7 +86,6 @@ Further documentation can be found in [TRANSLATING.md](https://github.com/jamulu Thanks for contributing to Jamulus!' - # shellcheck disable=SC2016 # shellcheck can't know that this will be used with envsubst, so verbatim variables are correct here. BODY_TEMPLATE_WEB='Hi ${SPLIT_TRANSLATORS}, @@ -130,22 +129,20 @@ Please [replace with new URLs](https://github.com/jamulussoftware/jamuluswebsite ' - - get_languages() { if [[ $TYPE == app ]]; then if [[ ! -f src/main.cpp ]]; then - echo "Error: Please ensure that you are at the root of a jamulus code checkout" >/dev/stderr + echo "Error: Please ensure that you are at the root of a jamulus code checkout" > /dev/stderr exit 1 fi for LANG_FILE in src/translation/*.ts; do - LANG=${LANG_FILE/*\/translation_} - LANG=${LANG/.ts} + LANG=${LANG_FILE/*\/translation_/} + LANG=${LANG/.ts/} echo "$LANG" done elif [[ $TYPE == web ]]; then if [[ ! -d wiki ]]; then - echo "Error: Please ensure that you are at the root of a jamuluswebsite checkout" >/dev/stderr + echo "Error: Please ensure that you are at the root of a jamuluswebsite checkout" > /dev/stderr exit 1 fi for LANG in $(cd _translator-files/po/ && ls -d -- *); do @@ -154,7 +151,7 @@ get_languages() { echo "$LANG" done else - echo "Error: Invalid type. Valid types: app or website" >/dev/stderr + echo "Error: Invalid type. Valid types: app or website" > /dev/stderr exit 1 fi } @@ -175,7 +172,7 @@ create_translation_issue_for_lang() { translators=${TRANSLATORS_BY_LANG[${TYPE}_${lang}]-} if [[ -z $translators ]]; then - echo "Warning: Can't create issue for $lang - who is responsible? Skipping." >/dev/stderr + echo "Warning: Can't create issue for $lang - who is responsible? Skipping." > /dev/stderr return fi @@ -188,14 +185,14 @@ create_translation_issue_for_lang() { # Note: Those line continuation backslashes are required for variables # to be passed through: DEADLINE="$DEADLINE" \ - EXTRA_TEXT="$EXTRA_TEXT" \ - LANG="$lang" \ - MULTIPLE_TRANSLATORS_TEXT="$multiple_translators_text" \ - RELEASE="$RELEASE" \ - SPLIT_TRANSLATORS=$(sed -re 's/^/@/; s/,/, @/g' <<<"$translators") \ - TITLE="$title" \ - TRANSLATE_BRANCH=next-release \ - envsubst <<<"$body_template" + EXTRA_TEXT="$EXTRA_TEXT" \ + LANG="$lang" \ + MULTIPLE_TRANSLATORS_TEXT="$multiple_translators_text" \ + RELEASE="$RELEASE" \ + SPLIT_TRANSLATORS=$(sed -re 's/^/@/; s/,/, @/g' <<< "$translators") \ + TITLE="$title" \ + TRANSLATE_BRANCH=next-release \ + envsubst <<< "$body_template" ) # Check for an existing issue @@ -206,7 +203,7 @@ create_translation_issue_for_lang() { if [[ -z $existing_issue ]]; then echo "Creating Issue to translate $lang for $RELEASE" URL=$(gh issue create --title "$title" --label translation --project "$PROJECT" --body "$body" --assignee "$translators" --milestone "$MILESTONE") - existing_issue=${URL/*\/} + existing_issue=${URL/*\//} else echo "Issue to translate $lang for $RELEASE already exists" fi @@ -220,7 +217,7 @@ create_translation_issue_for_lang() { body=${body///${existing_issue}} if [[ "$online_body" != "$body" ]]; then echo "Updating Issue to translate $lang for $RELEASE" - gh issue edit "$existing_issue" --body "$body" >/dev/null + gh issue edit "$existing_issue" --body "$body" > /dev/null fi } diff --git a/tools/update-copyright-notices.sh b/tools/update-copyright-notices.sh index 7eb3cbdd4f..11bd5b38a6 100755 --- a/tools/update-copyright-notices.sh +++ b/tools/update-copyright-notices.sh @@ -10,5 +10,4 @@ find android ios linux mac src windows -regex '.*\.\(cpp\|h\|mm\)' -not -regex ' sed -re 's/(\*.*Copyright.*[^-][0-9]{4})(\s*-\s*\b[0-9]{4})?\s*$/\1-'"${YEAR}"'/' -i "${file}" done - sed -re 's/^( [0-9]{4}-)[0-9]{4}( The Jamulus)/\1'"${YEAR}"'\2/' -i distributions/debian/copyright