From 7631dba599b4a05348bd1f630d1350439dafa11b Mon Sep 17 00:00:00 2001 From: Ronald Y Date: Wed, 22 May 2024 13:58:30 +0800 Subject: [PATCH 1/3] new package: spleeter-proot --- tur-on-device/spleeter-proot/LICENSE | 21 ++++++++++ tur-on-device/spleeter-proot/build.sh | 42 +++++++++++++++++++ .../spleeter-is-proot.subpackage.sh | 4 ++ tur-on-device/spleeter-proot/spleeter-proot | 3 ++ 4 files changed, 70 insertions(+) create mode 100644 tur-on-device/spleeter-proot/LICENSE create mode 100644 tur-on-device/spleeter-proot/build.sh create mode 100644 tur-on-device/spleeter-proot/spleeter-is-proot.subpackage.sh create mode 100644 tur-on-device/spleeter-proot/spleeter-proot diff --git a/tur-on-device/spleeter-proot/LICENSE b/tur-on-device/spleeter-proot/LICENSE new file mode 100644 index 000000000..484aef79a --- /dev/null +++ b/tur-on-device/spleeter-proot/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present, Deezer SA. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/tur-on-device/spleeter-proot/build.sh b/tur-on-device/spleeter-proot/build.sh new file mode 100644 index 000000000..a7d9d816d --- /dev/null +++ b/tur-on-device/spleeter-proot/build.sh @@ -0,0 +1,42 @@ +TERMUX_PKG_HOMEPAGE=https://research.deezer.com/projects/spleeter.html +TERMUX_PKG_DESCRIPTION="Audio source separation based, pacakged in proot" +TERMUX_PKG_LICENSE="MIT" +TERMUX_PKG_MAINTAINER="@termux-user-repository" +TERMUX_PKG_VERSION=2.4.0 +TERMUX_PKG_SKIP_SRC_EXTRACT=true +TERMUX_PKG_DEPENDS="proot-distro" +TERMUX_PKG_BUILD_DEPENDS="wget" +TERMUX_PKG_UNDEF_SYMBOLS_FILES=all + +TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686" + +termux_step_pre_configure() { + if [ "${TERMUX_ON_DEVICE_BUILD}" = false ]; then + termux_error_exit "This package doesn't support cross-compiling." + fi +} + +termux_step_post_get_source () { + cp "$TERMUX_PKG_BUILDER_DIR"/LICENSE "$TERMUX_PKG_SRCDIR"/ +} + +termux_step_make_install(){ + proot-distro install --override-alias app_spleeter ubuntu + proot-distro login app_spleeter --isolated -- eval useradd -U -m -s /bin/bash -p root android + proot-distro login app_spleeter --user android -- eval " +mkdir -p ~/miniconda3 +wget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.4.0-0-Linux-$TERMUX_ARCH.sh -O ~/miniconda3/miniconda.sh +" + proot-distro login app_spleeter --user android --isolated -- eval " +bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 +rm -rf ~/miniconda3/miniconda.sh + +~/miniconda3/bin/conda config --set auto_activate_base false +~/miniconda3/bin/conda create -n spleeter_py310 -y python=3.10 +~/miniconda3/bin/conda run -n spleeter_py310 pip install --no-deps spleeter +~/miniconda3/bin/conda run -n spleeter_py310 pip install ffmpeg-python httpx==0.19.0 norbert typer==0.3.2 +~/miniconda3/bin/conda run -n spleeter_py310 pip install pandas==1.5.3 tensorflow==2.10 +" + install -Dm700 "$TERMUX_PKG_BUILDER_DIR"/spleeter-proot $TERMUX_PREFIX/bin/ + ln -sfr $TERMUX_PREFIX/bin/spleeter-proot $TERMUX_PREFIX/bin/spleeter +} diff --git a/tur-on-device/spleeter-proot/spleeter-is-proot.subpackage.sh b/tur-on-device/spleeter-proot/spleeter-is-proot.subpackage.sh new file mode 100644 index 000000000..f58194d60 --- /dev/null +++ b/tur-on-device/spleeter-proot/spleeter-is-proot.subpackage.sh @@ -0,0 +1,4 @@ +TERMUX_SUBPKG_DESCRIPTION="Symlinks to bin/spleeter" +TERMUX_SUBPKG_INCLUDE=" +bin/spleeter +" diff --git a/tur-on-device/spleeter-proot/spleeter-proot b/tur-on-device/spleeter-proot/spleeter-proot new file mode 100644 index 000000000..954682b6b --- /dev/null +++ b/tur-on-device/spleeter-proot/spleeter-proot @@ -0,0 +1,3 @@ +#!/data/data/com.termux/files/usr/bin/sh + +proot-distro login --user android app_spleeter --shared-tmp --work-dir "$PWD" -- /home/android/miniconda3/bin/conda run -n spleeter_py310 spleeter "$@" From a98154c5c123d60c9b3f6cff8b4cdc1386415572 Mon Sep 17 00:00:00 2001 From: Ronald Y Date: Thu, 23 May 2024 13:06:13 +0800 Subject: [PATCH 2/3] spleeter-proot: install 2stems model and clean pip cache --- tur-on-device/spleeter-proot/build.sh | 7 +++++++ tur-on-device/spleeter-proot/spleeter-proot | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tur-on-device/spleeter-proot/build.sh b/tur-on-device/spleeter-proot/build.sh index a7d9d816d..84c039003 100644 --- a/tur-on-device/spleeter-proot/build.sh +++ b/tur-on-device/spleeter-proot/build.sh @@ -21,6 +21,12 @@ termux_step_post_get_source () { } termux_step_make_install(){ + # install 2stems model + mkdir -p "$PREFIX/etc/spleeter-proot/pretrained_models/2stems" + wget "https://github.com/deezer/spleeter/releases/download/v1.4.0/2stems.tar.gz" + tar -xf 2stems.tar.gz -C "$PREFIX/etc/spleeter-proot/pretrained_models/2stems/" + + # install proot rootfs and spleeter proot-distro install --override-alias app_spleeter ubuntu proot-distro login app_spleeter --isolated -- eval useradd -U -m -s /bin/bash -p root android proot-distro login app_spleeter --user android -- eval " @@ -36,6 +42,7 @@ rm -rf ~/miniconda3/miniconda.sh ~/miniconda3/bin/conda run -n spleeter_py310 pip install --no-deps spleeter ~/miniconda3/bin/conda run -n spleeter_py310 pip install ffmpeg-python httpx==0.19.0 norbert typer==0.3.2 ~/miniconda3/bin/conda run -n spleeter_py310 pip install pandas==1.5.3 tensorflow==2.10 +~/miniconda3/bin/conda run -n spleeter_py310 pip cache purge " install -Dm700 "$TERMUX_PKG_BUILDER_DIR"/spleeter-proot $TERMUX_PREFIX/bin/ ln -sfr $TERMUX_PREFIX/bin/spleeter-proot $TERMUX_PREFIX/bin/spleeter diff --git a/tur-on-device/spleeter-proot/spleeter-proot b/tur-on-device/spleeter-proot/spleeter-proot index 954682b6b..c9680b37e 100644 --- a/tur-on-device/spleeter-proot/spleeter-proot +++ b/tur-on-device/spleeter-proot/spleeter-proot @@ -1,3 +1,3 @@ #!/data/data/com.termux/files/usr/bin/sh -proot-distro login --user android app_spleeter --shared-tmp --work-dir "$PWD" -- /home/android/miniconda3/bin/conda run -n spleeter_py310 spleeter "$@" +proot-distro login --user android app_spleeter --shared-tmp --env MODEL_PATH="$PREFIX/etc/spleeter-proot/pretrained_models/2stems" --work-dir "$PWD" -- /home/android/miniconda3/bin/conda run -n spleeter_py310 spleeter "$@" From d33a97fa3dd9aada611c78ca8f2d51e8c5774b7c Mon Sep 17 00:00:00 2001 From: Ronald Y Date: Fri, 24 May 2024 09:23:27 +0800 Subject: [PATCH 3/3] spleeter-proot: refactor and fix packages --- tur-on-device/spleeter-proot/build.sh | 40 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/tur-on-device/spleeter-proot/build.sh b/tur-on-device/spleeter-proot/build.sh index 84c039003..3e477a5a9 100644 --- a/tur-on-device/spleeter-proot/build.sh +++ b/tur-on-device/spleeter-proot/build.sh @@ -20,6 +20,13 @@ termux_step_post_get_source () { cp "$TERMUX_PKG_BUILDER_DIR"/LICENSE "$TERMUX_PKG_SRCDIR"/ } +proot_run () { + proot-distro login app_spleeter --isolated -- "$@" +} +proot_run_user () { + proot-distro login app_spleeter --user android --isolated -- "$@" +} + termux_step_make_install(){ # install 2stems model mkdir -p "$PREFIX/etc/spleeter-proot/pretrained_models/2stems" @@ -28,22 +35,23 @@ termux_step_make_install(){ # install proot rootfs and spleeter proot-distro install --override-alias app_spleeter ubuntu - proot-distro login app_spleeter --isolated -- eval useradd -U -m -s /bin/bash -p root android - proot-distro login app_spleeter --user android -- eval " -mkdir -p ~/miniconda3 -wget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.4.0-0-Linux-$TERMUX_ARCH.sh -O ~/miniconda3/miniconda.sh -" - proot-distro login app_spleeter --user android --isolated -- eval " -bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3 -rm -rf ~/miniconda3/miniconda.sh - -~/miniconda3/bin/conda config --set auto_activate_base false -~/miniconda3/bin/conda create -n spleeter_py310 -y python=3.10 -~/miniconda3/bin/conda run -n spleeter_py310 pip install --no-deps spleeter -~/miniconda3/bin/conda run -n spleeter_py310 pip install ffmpeg-python httpx==0.19.0 norbert typer==0.3.2 -~/miniconda3/bin/conda run -n spleeter_py310 pip install pandas==1.5.3 tensorflow==2.10 -~/miniconda3/bin/conda run -n spleeter_py310 pip cache purge -" + + proot_run apt update + proot_run apt upgrade -y + proot_run apt install -y libhdf5-dev gcc wget pkg-config + proot_run useradd -U -m -s /bin/bash -p root android + proot_run_user mkdir -p /home/android/miniconda3 + proot_run_user wget https://repo.anaconda.com/miniconda/Miniconda3-py310_24.4.0-0-Linux-$TERMUX_ARCH.sh -O /home/android/miniconda3/miniconda.sh + proot_run_user bash /home/android/miniconda3/miniconda.sh -b -u -p /home/android/miniconda3 + proot_run_user rm -rf /home/android/miniconda3/miniconda.sh + proot_run_user /home/android/miniconda3/bin/conda config --set auto_activate_base false + proot_run_user /home/android/miniconda3/bin/conda create -n spleeter_py310 -y python=3.10 + proot_run_user /home/android/miniconda3/bin/conda run -n spleeter_py310 pip install ffmpeg-python httpx[http2]==0.19.0 norbert typer==0.3.2 + proot_run_user /home/android/miniconda3/bin/conda run -n spleeter_py310 pip install pandas==1.5.3 tensorflow==2.10 + proot_run_user /home/android/miniconda3/bin/conda run -n spleeter_py310 pip install --no-deps spleeter + proot_run_user /home/android/miniconda3/bin/conda run -n spleeter_py310 pip cache purge + proot_run apt autoremove -y gcc wget pkg-config + install -Dm700 "$TERMUX_PKG_BUILDER_DIR"/spleeter-proot $TERMUX_PREFIX/bin/ ln -sfr $TERMUX_PREFIX/bin/spleeter-proot $TERMUX_PREFIX/bin/spleeter }