diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48367b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +obs-plugin-backgroundremoval* + diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..b039d89 --- /dev/null +++ b/Containerfile @@ -0,0 +1,43 @@ +ARG PACKAGE_NAME=obs-backgroundremoval +ARG PACKAGE_VERSION=1.1.13 + +ENV CPU_ARCH=x86_64 +ENV DEBIAN_FRONTEND=noninteractive + + +FROM debian:bookworm + +RUN set -eux \ + && apt-get --yes update \ + && apt-get --yes install --no-install-recommends \ + build-essential \ + ca-certificates \ + cmake \ + curl \ + libcurl4-openssl-dev \ + git \ + libobs-dev \ + libonnx-dev \ + libopencv-dev \ + libsimde-dev \ + wget \ + && rm -rf /var/lib/apt/lists/* + +RUN git clone https://github.com/locaal-ai/obs-backgroundremoval.git \ + && cd obs-backgroundremoval \ + && git checkout ${PACKAGE_VERSION} \ + && mkdir build \ + && cd build \ + && cmake .. \ + && cmake --build . \ + && cmake --install . \ + && mkdir --parents /build + +VOLUME [ "/build" ] + +CMD set -eux \ + && mkdir --parents /build/usr/lib/${CPU_ARCH}-linux-gnu/obs-plugins/ \ + && cp --force /usr/local/lib/obs-plugins/obs-backgroundremoval.so /build/usr/lib/${CPU_ARCH}-linux-gnu/obs-plugins/ \ + && cp --force /usr/local/lib/obs-plugins/obs-backgroundremoval/libonnxruntime.so* /build/usr/lib/${CPU_ARCH}-linux-gnu/ \ + && mkdir --parents /build/usr/share/obs/obs-plugins/obs-backgroundremoval/ \ + && cp --force --recursive /usr/local/share/obs/obs-plugins/obs-backgroundremoval/* /build/usr/share/obs/obs-plugins/obs-backgroundremoval/ diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..4a53203 --- /dev/null +++ b/build.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +DEB_NAME=obs-plugin-backgroundremoval +DEB_VERSION=${1:-1.1.13} +DEB_ARCH=`dpkg --print-architecture` + +dpkg -s podman 2>/dev/null >/dev/null +if [ $? -ne 0 ]; then + echo "ERROR: 'podman' not installed, please install like so and re-run this script:" + echo " sudo apt install -y podman" + exit 1 +fi + +if [ -d ./build ]; then + rm -rf "./build" +fi +mkdir ./build + +podman build --build-arg PACKAGE_VERSION="${DEB_VERSION}" --tag "${DEB_NAME}:${DEB_VERSION}" . +podman run --env CPU_ARCH=`uname -m` --interactive --tty --rm --volume "${PWD}/build:/build" "${DEB_NAME}:${DEB_VERSION}" + +if [ -d "./${DEB_NAME}_${DEB_VERSION}" ]; then + rm -rf "./${DEB_NAME}_${DEB_VERSION}/" +fi +mkdir --parents "./${DEB_NAME}_${DEB_VERSION}/DEBIAN" +cat << EOF > "./${DEB_NAME}_${DEB_VERSION}/DEBIAN/control" +Package: ${DEB_NAME} +Version: ${DEB_VERSION} +Architecture: ${DEB_ARCH} +Depends: obs-studio +Maintainer: Juergen Pabel +Description: OBS Studio plugin backgroundremoval +EOF + +(cd ./build ; tar cf - .) | (cd "./${DEB_NAME}_${DEB_VERSION}" ; tar xf -) +dpkg-deb --root-owner-group --build "${DEB_NAME}_${DEB_VERSION}" && dpkg-name -o -s . "./${DEB_NAME}_${DEB_VERSION}.deb"