File prepare_sources.sh of Package piper-voices

#!/bin/bash

PACKAGE="piper-voices"
VERSION="1.0.0"

if [ ! -d "${PACKAGE}" ]; then
    git clone https://huggingface.co/rhasspy/piper-voices/
    pushd "${PACKAGE}" || exit 1
    git co -b "v${VERSION}" "piper-voices-${VERSION}"
    popd || exit 1
else
    pushd "${PACKAGE}" || exit 1
    git co .
    git fetch
    git reset --hard "v${VERSION}"
    popd || exit 1
fi

# Get rid of the mp3 sample files
find "./${PACKAGE}" -type d -name "samples" -print0 | xargs -0 rm -rf

for lang in "${PACKAGE}"/*; do
    if [ ! -d "${lang}" ]; then
        continue
    fi
    l="$(basename "${lang}")"
    if [ "${l}" = "_script" ]; then
        continue
    fi
    if [ ! -f "${PACKAGE}-${l}-${VERSION}.tar.zst" ]; then
        echo "Creating tarball for ${l}"
        tar --zstd -cf "${PACKAGE}-${l}-${VERSION}.tar.zst" "${lang}" "${PACKAGE}/README.md"
    fi

    sed -e "s/@LANG@/${l}/" piper-voices-lang.spec.in > "piper-voices-${l}.spec"
done

echo "Creating common tarball"
tar --zstd -cf "${PACKAGE}-${VERSION}.tar.zst" "${PACKAGE}/README.md" "${PACKAGE}/voices.json"
openSUSE Build Service is sponsored by