1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-14 16:46:28 +01:00

Change bash scripts to be POSIX-compatible

some Unix-like operating systems, namely Alpine, don't come with bash
preinstalled.
scripts in the lib-src/ directory were left untouched.

Signed-off-by: Sol Fisher Romanoff <sol@solfisher.com>
This commit is contained in:
Sol Fisher Romanoff
2021-12-02 09:32:47 +02:00
parent d118b79a04
commit f395687c9f
16 changed files with 149 additions and 144 deletions

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Run this script on a directory to "degimpify" all XPM files
# within that directory (meaning any file ending with .XPM)

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env bash
#!/bin/sh
# The AppImage runtime sets some special environment variables. We provide
# default values here in case the user tries to run this script outside an
# AppImage where the variables would otherwise be undefined.
if [[ ! "${APPIMAGE}" || ! "${APPDIR}" ]]; then
if [ ! "${APPIMAGE}" ] || [ ! "${APPDIR}" ]; then
export APPIMAGE="$(readlink -f "${0}")"
export APPDIR="$(dirname "${APPIMAGE}")"
fi
@@ -12,8 +12,7 @@ export LD_LIBRARY_PATH="${APPDIR}/lib:${LD_LIBRARY_PATH}"
export AUDACITY_PATH="${AUDACITY_PATH}:${APPDIR}/share/tenacity"
export AUDACITY_MODULES_PATH="${AUDACITY_MODULES_PATH}:${APPDIR}/lib/modules"
function help()
{
help() {
# Normal tenacity help
"${APPDIR}/bin/tenacity" --help
# Special options handled by this script

View File

@@ -1,7 +1,9 @@
#!/bin/sh
export TZ=Europe/London
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
apt_packages_basic=(
apt_packages_basic="
build-essential
python3-minimal
python3-pip
@@ -9,16 +11,16 @@ apt_packages_basic=(
libstdc++-9-dev
cmake
git
)
"
apt_packages_minimal_deps=(
apt_packages_minimal_deps="
libgtk2.0-dev
libasound2-dev
libavformat-dev
libjack-jackd2-dev
)
"
apt_packages_full_deps=(
apt_packages_full_deps="
zlib1g-dev
libexpat1-dev
libmp3lame-dev
@@ -51,12 +53,12 @@ apt_packages_full_deps=(
libcurl4-openssl-dev
libpng-dev
libjpeg-turbo8-dev
)
"
apt-get install -y --no-install-recommends \
"${apt_packages_basic[@]}" \
"${apt_packages_minimal_deps[@]}" \
"${apt_packages_full_deps[@]}"
"$apt_packages_basic" \
"$apt_packages_minimal_deps" \
"$apt_packages_full_deps"
pip3 install conan

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
conan --version

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
version="@CPACK_PACKAGE_NAME@ v@CPACK_PACKAGE_VERSION@ @CPACK_AUDACITY_ARCH_LABEL@"

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Report how complete each translation catalog is
@@ -8,9 +8,11 @@ total=`grep '^msgid' audacity.pot | wc -l`
#CSV header
echo "Name,Completed,Pct. completed,Bad lines"
declare -i badlines
badlines=0
for filename in *.po; do
[ -e "$filename" ] || break
for filename in `ls *.po`; do
# If there are errors from msgcmp, then the last line on standard error
# contains a count of problematic messages; else it won't match the
# pattern in awk, so assume no errors
@@ -20,7 +22,7 @@ for filename in `ls *.po`; do
# detect whether this sequence occurs in any .po file. It will break
# msgfmt on Windows.
badlines=`fgrep '#~|' ${filename} | wc -l`
badlines=`grep -Fc '#~|' "${filename}"`
# produce comma-separated values
echo "$filename,$complete,$((complete*100/total)),$badlines"

View File

@@ -1,3 +1,5 @@
#!/bin/sh
for i in *.po; do
sed -i '/^Project/d' $i
done
done

View File

@@ -1,16 +1,13 @@
#!/bin/bash
#!/bin/sh
# Run this script on a directory to handle PO files with no id
shopt -s nullglob
input_dirs="$*"
DIRNAME=$(dirname "$0")
if [ $# -eq 0 ]; then
input_dirs[0]="${BASH_SOURCE[0]}/../"
set -- "$DIRNAME/../"
fi
for dir in "${input_dirs[@]}"
for dir in "$@"
do
for po_file in "${dir}"/*.po; do
sed -i '/^Project/d' "$po_file"

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Report how complete each translation catalog is

View File

@@ -1,16 +1,18 @@
#!/bin/bash
#!/bin/sh
# Run this script with /locale/script/ as the current directory
set -o errexit
DIRNAME=$(dirname "$0")
echo ";; Recreating tenacity.pot using .h, .cpp and .mm files"
for path in "${BASH_SOURCE[0]}/../modules/mod-*" "${BASH_SOURCE[0]}/../libraries/lib-*" "${BASH_SOURCE[0]}/../include" "${BASH_SOURCE[0]}/../src" ; do
for path in "$DIRNAME/../modules/mod-*" "$DIRNAME/../libraries/lib-*" "$DIRNAME/../include" "$DIRNAME/../src" ; do
find "$path" -name \*.h -o -name \*.cpp -o -name \*.mm
done | LANG=c sort | \
sed -E 's/\.\.\///g' |\
xargs xgettext \
--no-wrap \
--default-domain=tenacity \
--directory="${BASH_SOURCE[0]}/../.." \
--directory="$DIRNAME/../.." \
--keyword=_ --keyword=XO --keyword=XC:1,2c --keyword=XXO --keyword=XXC:1,2c --keyword=XP:1,2 --keyword=XPC:1,2,4c \
--add-comments=" i18n" \
--add-location=file \
@@ -18,15 +20,15 @@ xargs xgettext \
--package-name="tenacity" \
--package-version='3.0.4' \
--msgid-bugs-address="emabrey@tenacityaudio.org" \
--add-location=file -L C -o "${BASH_SOURCE[0]}/../tenacity.pot"
--add-location=file -L C -o "$DIRNAME/../tenacity.pot"
echo ";; Adding nyquist files to tenacity.pot"
for path in "${BASH_SOURCE[0]}/../../plug-ins/"* ; do find "$path" -name \*.ny -not -name rms.ny; done | LANG=c sort | \
for path in "$DIRNAME/../../plug-ins/"* ; do find "$path" -name \*.ny -not -name rms.ny; done | LANG=c sort | \
sed -E 's/\.\.\///g' |\
xargs xgettext \
--no-wrap \
--default-domain=tenacity \
--directory="${BASH_SOURCE[0]}/../.." \
--directory="$DIRNAME/../.." \
--keyword=_ --keyword=_C:1,2c --keyword=ngettext:1,2 --keyword=ngettextc:1,2,4c \
--add-comments=" i18n" \
--add-location=file \
@@ -34,11 +36,11 @@ xargs xgettext \
--package-name="tenacity" \
--package-version='3.0.4' \
--msgid-bugs-address="emabrey@tenacityaudio.org" \
--add-location=file -L Lisp -j -o "${BASH_SOURCE[0]}/../tenacity.pot"
--add-location=file -L Lisp -j -o "$DIRNAME/../tenacity.pot"
echo ""
echo ";; POT file generated"
echo ""
head -n 11 "${BASH_SOURCE[0]}/../tenacity.pot" | tail -n 3
wc -l "${BASH_SOURCE[0]}/../tenacity.pot"
head -n 11 "$DIRNAME/../tenacity.pot" | tail -n 3
wc -l "$DIRNAME/../tenacity.pot"

View File

@@ -1,19 +1,19 @@
#!/bin/bash
#!/bin/sh
# Function to retrieve a value from a plist
function plist
plist()
{
/usr/libexec/PlistBuddy -c "Print ${2}" "${1}"
}
function realpath
realpath()
{
python -c "import os; import sys; print(os.path.realpath(sys.argv[1]))" "${1}"
}
# Function to notarize a file (APP or DMG)
function notarize
notarize()
{
# Bail if not signing
if [ -z "${SIGNING}" ]
@@ -80,7 +80,7 @@ function notarize
rm "${OUTPUT}"
}
if [ -z "${SRCROOT}" -o -z "${DSTROOT}" ]
if [ -z "${SRCROOT}" ] || [ -z "${DSTROOT}" ]
then
if [ "${#}" -ne 2 ]
then
@@ -129,8 +129,9 @@ IDENT=$(plist "${DSTROOT}/Tenacity.app/Contents/Info.plist" "CFBundleIdentifier"
SIGNING=
if [ -r ~/.tenacity_signing ]
then
source ~/.tenacity_signing
if [ -n "${CODESIGN_APP_IDENTITY}" -a -n "${NOTARIZE_USERNAME}" -a -n "${NOTARIZE_PASSWORD}" ]
. ~/.tenacity_signing
if [ -n "${CODESIGN_APP_IDENTITY}" ] && [ -n "${NOTARIZE_USERNAME}" ] &&
[ -n "${NOTARIZE_PASSWORD}" ]
then
SIGNING="y"
fi
@@ -144,7 +145,7 @@ cd "${DSTROOT}/.."
# Make sure we have consistent ownership and permissions
chmod -RH 755 "${DSTROOT}"
chown -RH $(id -u):$(id -g) "${DSTROOT}"
chown -RH "$(id -u):$(id -g)" "${DSTROOT}"
# Preclean
rm -rf "$DMG" "$DMG.dmg" TMP.dmg

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# You can use this to build wxWidgets. Just run it from within the root of the
# wxWidgets source tree like so:
@@ -13,7 +13,7 @@ minver=10.7
sdkdir=""
# Build a specific configuration
function bld
bld()
{
flavour="${1}"
shift
@@ -21,34 +21,35 @@ function bld
# Create and change to our build directory
rm -rf "bld_${flavour}_${arch}"
mkdir -p "bld_${flavour}_${arch}"
pushd "bld_${flavour}_${arch}"
(
cd "bld_${flavour}_${arch}"
# Force Audacity specific options
export CXX="g++ -std=c++1z -stdlib=libc++"
export LD="g++ -std=c++1z -stdlib=libc++"
# Force Audacity specific options
export CXX="g++ -std=c++1z -stdlib=libc++"
export LD="g++ -std=c++1z -stdlib=libc++"
# NOTES: liblzma isn't available on MacOS 10.8 or older and Audacity doesn't
# need it. So, build wxWidgets without the support to allow Audacity
# to run on MacOS 10.7 or newer.
../configure --prefix="/usr/local/${arch}" \
--enable-macosx-arch="${arch}" \
--enable-shared=yes \
--enable-unicode=yes \
--enable-universal_binary=no \
--enable-webkit=no \
--with-expat=builtin \
--with-flavour="${flavour}" \
--with-libjpeg=builtin \
--with-libpng=builtin \
--with-libtiff=builtin \
--with-macosx-sdk="${sdkdir}" \
--with-macosx-version-min="${minver}" \
--with-regex=builtin \
--with-zlib=builtin \
--without-liblzma \
${@}
make -j $(sysctl -n hw.ncpu) install
popd
# NOTES: liblzma isn't available on MacOS 10.8 or older and Audacity doesn't
# need it. So, build wxWidgets without the support to allow Audacity
# to run on MacOS 10.7 or newer.
../configure --prefix="/usr/local/${arch}" \
--enable-macosx-arch="${arch}" \
--enable-shared=yes \
--enable-unicode=yes \
--enable-universal_binary=no \
--enable-webkit=no \
--with-expat=builtin \
--with-flavour="${flavour}" \
--with-libjpeg=builtin \
--with-libpng=builtin \
--with-libtiff=builtin \
--with-macosx-sdk="${sdkdir}" \
--with-macosx-version-min="${minver}" \
--with-regex=builtin \
--with-zlib=builtin \
--without-liblzma \
"${@}"
make -j "$(sysctl -n hw.ncpu)" install
)
}
# Only build 32-bit version if running on 10.14 or older and
@@ -56,8 +57,7 @@ function bld
arches="x86_64"
osver="$(sw_vers -productVersion)"
sdkver="$(xcrun --show-sdk-version)"
if [ "${osver}" \< "10.15" -a "${sdkver}" \< "10.14" ]
then
if expr "${osver}" \< "10.15" && expr "${sdkver}" \< "10.14"; then
arches="${arches} i386"
fi

View File

@@ -14,26 +14,26 @@ resolve()
update_paths()
{
local indent="${1}"
local path=$(resolve "${2}")
local base="${path##*/}"
_indent="${1}"
_path=$(resolve "${2}")
_base="${_path##*/}"
if [ -e "${LIBPATH}/${base}" ]
if [ -e "${LIBPATH}/${_base}" ]
then
return
fi
printf "%${indent}.${indent}cCopying '${path}' into bundle\n" " "
cp -p "${path}" "${LIBPATH}"
for lib in $(otool -L "${path}" | awk '/libwx.*dylib /{print $1}')
printf "%${_indent}.${_indent}cCopying '${_path}' into bundle\n" " "
cp -p "${_path}" "${LIBPATH}"
for lib in $(otool -L "${_path}" | awk '/libwx.*dylib /{print $1}')
do
path=$(resolve "${lib}")
_path=$(resolve "${lib}")
printf "%${indent}.${indent}cChanging '${lib}' to '@loader_path/../Frameworks/${path##*/}'\n" " "
install_name_tool -change "${lib}" "@loader_path/../Frameworks/${path##*/}" "${LIBPATH}/${base}"
printf "%${_indent}.${_indent}cChanging '${lib}' to '@loader_path/../Frameworks/${path##*/}'\n" " "
install_name_tool -change "${lib}" "@loader_path/../Frameworks/${path##*/}" "${LIBPATH}/${_base}"
update_paths $((indent + 2)) "${path}"
update_paths $((_indent + 2)) "${_path}"
done
}

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
set -x
objcopy --only-keep-debug --compress-debug-section=zlib "${1}" "${1}.debug"

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
((${BASH_VERSION%%.*} >= 4)) || { echo >&2 "$0: Error: Please upgrade Bash."; exit 1; }
@@ -8,7 +8,7 @@ max_retry=12
counter=0
num_secs_await_retry=20
echo "Trying: /usr/bin/hdiutil $@"
echo "Trying: /usr/bin/hdiutil $*"
until /usr/bin/hdiutil "$@"; do
sleep $num_secs_await_retry

View File

@@ -1,15 +1,15 @@
#!/bin/bash
#!/bin/sh
# Copyright 2003, 2004, 2005 Dominic Mazzoni and Matt Brubeck
# Distributed under the GNU General Public License 2.0.
# See the file LICENSE.txt for details.
# Re-written in Bash by Richard Ash 2006 - 2013
function myrmrvf {
myrmrvf() {
# a replacement for rm -rvf that has it's output controlled
# by the value of the first argument
# setting it to 1 makes it verbose, to anything else makes it quiet
if [ $1 -eq 1 ] ; then #verbose mode
if [ "$1" -eq 1 ] ; then #verbose mode
shift
echo "rm -rf $*"
rm -rf $*
@@ -20,11 +20,11 @@ function myrmrvf {
fi
}
function myrmvf {
myrmvf() {
# a replacement for rm -vf that has it's output controlled
# by the value of the first argument
# setting it to 1 makes it verbose, to anything else makes it quiet
if [ $1 -eq 1 ] ; then #verbose mode
if [ "$1" -eq 1 ] ; then #verbose mode
shift
echo "rm -f $*"
rm -f $*
@@ -35,23 +35,23 @@ function myrmvf {
fi
}
function myfindrm {
myfindrm() {
# search the file tree removing files that match the specified pattern in
# the second argument, with output controlled by the value of the first
# argument.
# setting it to 1 makes it verbose, to anything else makes it quiet
if [ $1 -eq 1 ] ; then
if [ "$1" -eq 1 ] ; then
find . -name "$2" -print -delete
else
find . -name "$2" -delete
fi
}
function cleanfulltree {
cleanfulltree() {
# does the clean-up op on the full source tree prior to building the full
# tarball
printf "making distclean ... "
if [ $1 -eq 1 ] ; then
if [ "$1" -eq 1 ] ; then
make distclean
else
make distclean 2>/dev/null > /dev/null
@@ -65,98 +65,98 @@ function cleanfulltree {
fi
printf "removing GIT directories ... "
myrmrvf $1 .git .gitignore
myrmrvf $1 .gitignore
myrmrvf $1 .gitattributes
myrmrvf "$1" .git .gitignore
myrmrvf "$1" .gitignore
myrmrvf "$1" .gitattributes
printf "Done\n"
printf "removing vim / emacs temp files ... "
myfindrm $1 "*~"
myfindrm "$1" "*~"
printf "Done\n"
printf "removing Python droppings ... "
myfindrm $1 "*.pyc"
myfindrm "$1" "*.pyc"
printf "Done\n"
printf "removing executable and other intermediate files ... "
myrmvf $1 src/tenacity src/.depend src/.gchdepend
myfindrm $1 config.status
myfindrm $1 config.log
myfindrm $1 config.cache
myrmvf "$1" src/tenacity src/.depend src/.gchdepend
myfindrm "$1" config.status
myfindrm "$1" config.log
myfindrm "$1" config.cache
find . -depth -name 'autom4te.cache' -execdir rm -rf '{}' ';'
find . -depth -name '.deps' -execdir rm -rf '{}' ';'
myfindrm $1 aclocal.m4
myfindrm "$1" aclocal.m4
printf "Done\n"
printf "removing orphaned symlinks in lib-src/ ... "
myrmvf $1 lib-src/*.a
myrmvf "$1" lib-src/*.a
printf "Done\n"
printf "removing doxygen output files ... "
myrmrvf $1 dox
myrmrvf "$1" dox
printf "Done\n"
printf "removing unused libraries from GIT tree ..."
myrmrvf $1 lib-src/libscorealign
myrmrvf "$1" lib-src/libscorealign
printf "Done\n"
}
# remove all the things we have in GIT for convenience rather than being
# necessary
function slimtree {
slimtree() {
printf "removing todo lists ... "
myrmvf $1 todo.txt
myrmvf "$1" todo.txt
printf "Done\n"
# we cannot remove tests/ because subsequent builds fail ...
printf "removing scripts and tests ... "
myrmrvf $1 scripts tests/ProjectCheckTests/
myrmrvf "$1" scripts tests/ProjectCheckTests/
printf "Done\n"
printf "removing libraries that should be installed locally ... "
myrmrvf $1 lib-src/expat lib-src/libid3tag
myrmrvf $1 lib-src/libmad lib-src/libogg
myrmrvf $1 lib-src/libvorbis lib-src/soundtouch
myrmrvf "$1" lib-src/expat lib-src/libid3tag
myrmrvf "$1" lib-src/libmad lib-src/libogg
myrmrvf "$1" lib-src/libvorbis lib-src/soundtouch
# these bindings aren't built by default, we don't need them
myrmrvf $1 lib-src/portaudio-v19/bindings/
myrmrvf "$1" lib-src/portaudio-v19/bindings/
printf "Done\n"
printf "removing qa ... "
myrmrvf $1 qa
myrmrvf "$1" qa
printf "Done\n"
printf "removing unused portaudio-v19 directories ... "
myrmrvf $1 lib-src/portaudio-v19/docs
myrmrvf $1 lib-src/portaudio-v19/pa_asio
myrmrvf $1 lib-src/portaudio-v19/pa_sgi
myrmrvf $1 lib-src/portaudio-v19/pa_mac_sm
myrmrvf $1 lib-src/portaudio-v19/testcvs
myrmrvf "$1" lib-src/portaudio-v19/docs
myrmrvf "$1" lib-src/portaudio-v19/pa_asio
myrmrvf "$1" lib-src/portaudio-v19/pa_sgi
myrmrvf "$1" lib-src/portaudio-v19/pa_mac_sm
myrmrvf "$1" lib-src/portaudio-v19/testcvs
printf "Done\n"
printf "removing unused portmidi directories ... "
myrmrvf $1 lib-src/portmidi/pm_cl
myrmrvf $1 lib-src/portmidi/pm_csharp
myrmrvf $1 lib-src/portmidi/pm_dylib
myrmrvf $1 lib-src/portmidi/pm_java
myrmrvf $1 lib-src/portmidi/pm_mingw
myrmrvf $1 lib-src/portmidi/pm_python
myrmrvf $1 lib-src/portmidi/pm_qt
myrmrvf $1 lib-src/portmidi/pm_test
myrmrvf $1 lib-src/portmidi/portmidi_cdt.zip
myrmrvf "$1" lib-src/portmidi/pm_cl
myrmrvf "$1" lib-src/portmidi/pm_csharp
myrmrvf "$1" lib-src/portmidi/pm_dylib
myrmrvf "$1" lib-src/portmidi/pm_java
myrmrvf "$1" lib-src/portmidi/pm_mingw
myrmrvf "$1" lib-src/portmidi/pm_python
myrmrvf "$1" lib-src/portmidi/pm_qt
myrmrvf "$1" lib-src/portmidi/pm_test
myrmrvf "$1" lib-src/portmidi/portmidi_cdt.zip
printf "Done\n"
printf "removing Nyquist plug-ins that are just for show ... "
myrmvf $1 plug-ins/analyze.ny plug-ins/fadein.ny plug-ins/fadeout.ny
myrmvf $1 plug-ins/undcbias.ny
myrmvf "$1" plug-ins/analyze.ny plug-ins/fadein.ny plug-ins/fadeout.ny
myrmvf "$1" plug-ins/undcbias.ny
printf "Done\n"
printf "Removing developer scripts not needed to build tenacity ... "
myrmrvf $1 scripts/mw2html_audacity
myrmrvf "$1" scripts/mw2html_audacity
printf "Done\n"
printf "Removing Mac and Windows build files ... "
myrmrvf $1 mac
myrmrvf $1 win
myrmrvf "$1" mac
myrmrvf "$1" win
printf "Done\n"
}
@@ -209,7 +209,7 @@ if [ -f "lib-src/Makefile" ] ; then
# we have a Makefile - is it new enough?
t2=$(date +%s -r "lib-src/Makefile")
t1=$(date +%s -r "lib-src/Makefile.in")
if [ $t1 -gt $t2 ] ; then
if [ "$t1" -gt "$t2" ] ; then
# not new enough, reconfigure
reconf=1
fi
@@ -251,7 +251,7 @@ if [ ! -x "config.status" ] ; then
exit 1
fi
echo -n "Getting program version ... "
printf "Getting program version ... "
# first off, find out what C++ pre-processor configure has found for us to use
# (because we want the same one that will be used to build Audacity). This is a
# neat trick using the config.status script left behind after configure has
@@ -260,7 +260,7 @@ cppprog="$(echo '@CXX@' | ./config.status --file=-)"
# run the preprocessor, convert output to shell variables, and evaluate to
# define them
eval $(cpp -E <<CPPEOF | sed -e 's/wxT("//g' \
eval "$(cpp -E <<CPPEOF | sed -e 's/wxT("//g' \
-e 's/")//g' \
-e 's/ //g' \
-e "s/__TDATE__/$(date +%Y%m%d)/" \
@@ -270,7 +270,7 @@ eval $(cpp -E <<CPPEOF | sed -e 's/wxT("//g' \
-e 'd'
#include "src/Audacity.h"
CPPEOF
)
)"
version="${GIT_DESCRIBE}"
printf "${version}\n"