Skip to content

Commit

Permalink
add ffmpeg & pngquant
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwutz committed Feb 15, 2024
1 parent ad8be0a commit 6c84404
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
/leptonica-*
/nginx-*
/node-*
/pngquant-*
/sqlite-*
/tessconfigs
/tessdata
/tesseract-*
/unpaper-*
/zbar-*
/ffmpeg-*
*.tar
*.tar.gz
*.tar.xz
Expand Down
2 changes: 2 additions & 0 deletions build.profile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ TMPDIR=${TMPDIR:-/tmp/${USER}/${BUILD_TAG}}
BUILD_sqlite=sqlite-3.45.1
BUILD_python=Python-3.11.8
BUILD_node=node-20.11.0
BUILD_ffmpeg=ffmpeg-6.1.1
BUILD_pngquant=pngquant-3.0.3-2-g88da53e
BUILD_unpaper=unpaper-7.0.0-99-gf41e9bb
BUILD_zbar=zbar-0.23.93
BUILD_leptonica=leptonica-1.84.1
Expand Down
2 changes: 2 additions & 0 deletions buildall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ ln -fs $logfile $LOGS/build.log
[ -d ${BUILD_sqlite} ] || ./sqlite.build.sh
[ -d ${BUILD_python} ] || ./Python.build.sh
[ -d ${BUILD_node} ] || ./node.build.sh
[ -d ${BUILD_ffmpeg} ] || ./ffmpeg.build.sh
[ -d ${BUILD_pngquant} ] || ./pngquant.build.sh
[ -d ${BUILD_unpaper} ] || ./unpaper.build.sh
[ -d ${BUILD_zbar} ] || ./zbar.build.sh
[ -d ${BUILD_leptonica} ] || ./leptonica.build.sh
Expand Down
2 changes: 2 additions & 0 deletions cleanall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ RMRF=(
$BUILD_sqlite
$BUILD_python
$BUILD_node
$BUILD_ffmpeg
$BUILD_unpaper
$BUILD_pngquant
$BUILD_zbar
$BUILD_leptonica
$BUILD_tesseract
Expand Down
48 changes: 48 additions & 0 deletions ffmpeg.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
{
set -x
set -e

. build.profile

function B_FFMPEG {

[ -d "$PREFIX" ] || { echo "PREFIX unset or not a directory";exit; }

# SRCURL[0]="https://ffmpeg.org//releases/${BUILD_ffmpeg}.tar.gz"
SRCURL[0]="https://beehive.molgen.mpg.de/cce359cad7ed0d4f0079f7864080ad36/ffmpeg-6.1.1.tar.gz"

PREFIX=${PREFIX}/${BUILD_ffmpeg}

mkdir -p $PREFIX

cat >$PREFIX/profile <<-EOF
PATH=$PREFIX/bin:\$PATH
PKG_CONFIG_PATH=${PROJECT}/${BUILD_ffmpeg}/lib/pkgconfig${PKG_CONFIG_PATH:+:}$PKG_CONFIG_PATH
EOF


test -e ${BUILD_ffmpeg}.tar.gz || wget -nv ${SRCURL} -O ${BUILD_ffmpeg}.tar.gz
test -d ${BUILD_ffmpeg} || mkdir -pv ${BUILD_ffmpeg} && tar -xf ${BUILD_ffmpeg}.tar.gz --strip-components=1 -C ${BUILD_ffmpeg}

cd ${BUILD_ffmpeg}

local _conf=(
--prefix=${PREFIX}
--enable-gpl
--enable-version3
--enable-nonfree
--enable-gray
--disable-doc
)

./configure "${_conf[@]}"

make -j $NPROC
make install

}

B_FFMPEG

}
3 changes: 3 additions & 0 deletions paperless-ngx.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ set -e

. build.profile

. ${PREFIX}/${BUILD_pngquant}/profile
. ${PREFIX}/${BUILD_ffmpeg}/profile
. ${PREFIX}/${BUILD_unpaper}/profile
. ${PREFIX}/${BUILD_sqlite}/profile
. ${PREFIX}/${BUILD_zbar}/profile
. ${PREFIX}/${BUILD_python}/profile
Expand Down
3 changes: 2 additions & 1 deletion paperless.conf.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ _sed=(
-e "/#PAPERLESS_SECRET_KEY=change-me/ a PAPERLESS_SECRET_KEY=${PAPERLESS_SECRET_KEY}"
# -e '/#PAPERLESS_AUTO_LOGIN_USERNAME=/ a PAPERLESS_AUTO_LOGIN_USERNAME=paperless'
-e '/#PAPERLESS_OCR_LANGUAGE=/ a PAPERLESS_OCR_LANGUAGE=deu+eng'
-e '/#PAPERLESS_OCR_MODE=skip/ a PAPERLESS_OCR_MODE=redo'
-e '/#PAPERLESS_OCR_MODE=skip/ a PAPERLESS_OCR_MODE=force'
-e "/#PAPERLESS_OCR_LANGUAGE=/ a PAPERLESS_NLTK_DIR=${PROJECT}/data/nltk"
-e "/#PAPERLESS_OCR_CLEAN=/ a PAPERLESS_OCR_CLEAN=clean-final"
-e "/#PAPERLESS_CONSUMPTION_DIR=/ a PAPERLESS_CONSUMPTION_DIR=${PROJECT}/consume"
-e "/#PAPERLESS_CONSUMPTION_DIR=/ a PAPERLESS_LOGGING_DIR=${PROJECT}/log"
-e '/#PAPERLESS_CONSUMER_RECURSIVE=/ a PAPERLESS_CONSUMER_RECURSIVE=true'
Expand Down
63 changes: 63 additions & 0 deletions pngquant.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
{
set -x
set -e

. build.profile

. ${PREFIX}/${BUILD_python}/profile

function B_PNGQUANT {

[ -d "$PREFIX" ] || { echo "PREFIX unset or not a directory";exit; }

BUILD_PKG=${BUILD_pngquant}

PREFIX=${PREFIX}/${BUILD_PKG}

if [ ! -d ${BUILD_pngquant} ]; then
if [ ! -e ${BUILD_pngquant}.tar ]; then
git clone --recursive https://github.com/kornelski/pngquant.git --single-branch ${BUILD_pngquant}
pushd ${BUILD_pngquant}
GITVER=$(git describe --tags)
popd
if [ "${GITVER}" != "${BUILD_pngquant##pngquant-}" ]; then
echo "${GITVER} should be ${BUILD_pngquant}. update!"
exit 1
fi
tar cf ${BUILD_pngquant}.tar ${BUILD_pngquant}
else
tar -xf ${BUILD_pngquant}.tar
fi
fi

if [ ! -d ${PREFIX} ]; then
git clone ${BUILD_pngquant} $PREFIX
else
pushd ${PREFIX}
git pull origin
popd
fi

cat >$PREFIX/profile <<-EOF
PATH=$PREFIX/bin:\$PATH
PKG_CONFIG_PATH=${PROJECT}/${BUILD_PKG}/lib/pkgconfig${PKG_CONFIG_PATH:+:}$PKG_CONFIG_PATH
EOF

cd ${BUILD_PKG}

local _conf=(
--release
)

[ -d /usr/local/package/bin ] && PATH=${PATH}:/usr/local/package/bin

CARGO_HOME=.cargo cargo build "${_conf[@]}"

install -v -Dm0755 ./target/release/pngquant $PREFIX/bin/pngquant

}

B_PNGQUANT

}
2 changes: 2 additions & 0 deletions profile.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin
. ${PROJECT}/${BUILD_node}/profile
. ${PROJECT}/${BUILD_nginx}/profile
. ${PROJECT}/${BUILD_unpaper}/profile
. ${PROJECT}/${BUILD_ffmpeg}/profile
. ${PROJECT}/${BUILD_pngquant}/profile
. ${PROJECT}/${BUILD_leptonica}/profile
. ${PROJECT}/${BUILD_tesseract}/profile
Expand Down
2 changes: 2 additions & 0 deletions unpaper.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -e
. build.profile

. ${PREFIX}/${BUILD_python}/profile
. ${PREFIX}/${BUILD_ffmpeg}/profile

function B_UNPAPER {

Expand Down Expand Up @@ -55,6 +56,7 @@ local _cflags=(
local _conf=(
--prefix ${PREFIX}
--buildtype=debugoptimized
--pkg-config-path=${PKG_CONFIG_PATH}
)

CFLAGS="${_cflags[@]}" meson setup "${_conf[@]}" builddir
Expand Down

0 comments on commit 6c84404

Please sign in to comment.