From 855faf68ddbb9569c0e2a50c89b226f323271dd6 Mon Sep 17 00:00:00 2001 From: Peter Marquardt Date: Wed, 26 Jun 2024 10:57:26 +0200 Subject: [PATCH] paperless-ngx: adding BUILD_DIR support - minor update 2.10.1 to 2.10.2 - BUILD_DIR=. # remap in build.local to use --- .gitignore | 1 + Python.build.sh | 3 ++ build.profile | 7 ++-- buildall.sh | 47 ++++++++++++++------------ ffmpeg.build.sh | 22 +++++++----- jbig2dec.build.sh | 4 +++ jbig2enc.build.sh | 4 +++ leptonica.build.sh | 4 +++ liberation-fonts-ttf.build.sh | 3 ++ nginx.build.sh | 6 +++- node.build.sh | 14 +++++--- paperless-ngx.build.sh | 63 ++++++++++++++++++++++++++--------- paperless.conf.build.sh | 2 +- pngquant.build.sh | 3 ++ redis.build.sh | 4 +++ sqlite.build.sh | 6 +++- tesseract.build.sh | 3 ++ unpaper.build.sh | 3 ++ zbar.build.sh | 4 +++ 19 files changed, 148 insertions(+), 55 deletions(-) diff --git a/.gitignore b/.gitignore index 6a948f5..4422a83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/build /build.local /ffmpeg-* /jbig2enc-* diff --git a/Python.build.sh b/Python.build.sh index 106f14f..99f61b5 100755 --- a/Python.build.sh +++ b/Python.build.sh @@ -62,6 +62,9 @@ pip3 install sphinx } +pushd "${BUILD_DIR}" + B_PYTHON +popd } diff --git a/build.profile b/build.profile index da4e5ae..106dec5 100644 --- a/build.profile +++ b/build.profile @@ -1,4 +1,7 @@ -BUILD_TAG=2.10.1 +BUILD_TAG=2.10.2 + +BUILD_DIR=. +BUILD_SRC="${PWD}" . build.local @@ -26,4 +29,4 @@ BUILD_jbig2enc=jbig2enc-0.28-17-gea05019 BUILD_jbig2dec=jbig2dec-0.20 BUILD_libfontttf=liberation-fonts-ttf-2.1.5 -BUILD_paperless=paperless-ngx-2.10.1 +BUILD_paperless=paperless-ngx-2.10.2 diff --git a/buildall.sh b/buildall.sh index cf42802..3fa8b0c 100755 --- a/buildall.sh +++ b/buildall.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +set -u BUILD_LOCAL=build.local if [ ! -e ${BUILD_LOCAL} ]; then @@ -40,46 +41,50 @@ mkdir -vp --mode=700 "${TMPDIR}" mkdir -vp --mode=700 "${XDG_CACHE_HOME:=${TMPDIR}.cache}" mkdir -vp --mode=700 "${DEVSHM}" +mkdir -vp "${BUILD_DIR}" + # logging -LOGS=${PWD}/logs -logfile="/usr/bin/cronolog -S $LOGS/build.log $LOGS/build-%Y-%m-%d.log" +LOGS="${BUILD_DIR}"/logs -mkdir -vp "$LOGS" +mkdir -vp "${LOGS}" +pushd "${LOGS}" cnt=1 -logfile=$LOGS/build-"$(date +%Y-%m-%d)".$cnt.log +logfile=build-"$(date +%Y-%m-%d)".$cnt.log set -o noclobber # shellcheck disable=SC2188 while ! { > "${logfile}" ; } &> /dev/null; do cnt=$((cnt + 1)) - printf -v logfile "%s.%s.log" "${LOGS}/build-$(date +%Y-%m-%d)" ${cnt} + printf -v logfile "%s.%s.log" "build-$(date +%Y-%m-%d)" ${cnt} done set +o noclobber set -x -ln -fs "${logfile}" "${LOGS}/build.log" +ln -fs "${logfile}" "build.log" + +popd { -[ -d "${BUILD_sqlite}" ] || ./sqlite.build.sh -[ -d "${BUILD_redis}" ] || ./redis.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 -[ -d "${BUILD_jbig2enc}" ] || ./jbig2enc.build.sh -[ -d "${BUILD_jbig2dec}" ] || ./jbig2dec.build.sh -[ -d "${BUILD_tesseract}" ] || ./tesseract.build.sh -[ -d "${BUILD_libfontttf}" ] || ./liberation-fonts-ttf.build.sh -[ -d "${BUILD_nginx}" ] || ./nginx.build.sh +[ -d "${BUILD_DIR}/${BUILD_sqlite}" ] || ./sqlite.build.sh +[ -d "${BUILD_DIR}/${BUILD_redis}" ] || ./redis.build.sh +[ -d "${BUILD_DIR}/${BUILD_python}" ] || ./Python.build.sh +[ -d "${BUILD_DIR}/${BUILD_node}" ] || ./node.build.sh +[ -d "${BUILD_DIR}/${BUILD_ffmpeg}" ] || ./ffmpeg.build.sh +[ -d "${BUILD_DIR}/${BUILD_pngquant}" ] || ./pngquant.build.sh +[ -d "${BUILD_DIR}/${BUILD_unpaper}" ] || ./unpaper.build.sh +[ -d "${BUILD_DIR}/${BUILD_zbar}" ] || ./zbar.build.sh +[ -d "${BUILD_DIR}/${BUILD_leptonica}" ] || ./leptonica.build.sh +[ -d "${BUILD_DIR}/${BUILD_jbig2enc}" ] || ./jbig2enc.build.sh +[ -d "${BUILD_DIR}/${BUILD_jbig2dec}" ] || ./jbig2dec.build.sh +[ -d "${BUILD_DIR}/${BUILD_tesseract}" ] || ./tesseract.build.sh +[ -d "${BUILD_DIR}/${BUILD_libfontttf}" ] || ./liberation-fonts-ttf.build.sh +[ -d "${BUILD_DIR}/${BUILD_nginx}" ] || ./nginx.build.sh ./nginx.conf.build.sh ./profile.build.sh ./startstop.build.sh [ -d "$PROJECT/${BUILD_paperless}" ] || ./paperless-ngx.build.sh -} 2>&1 | tee "$logfile" 2>&1 +} 2>&1 | tee "${LOGS}/${logfile}" 2>&1 diff --git a/ffmpeg.build.sh b/ffmpeg.build.sh index ec0a6a7..8e64734 100755 --- a/ffmpeg.build.sh +++ b/ffmpeg.build.sh @@ -11,25 +11,25 @@ function B_FFMPEG { BUILD_PKG=${BUILD_ffmpeg} # SRCURL[0]="https://ffmpeg.org//releases/${BUILD_ffmpeg}.tar.gz" -SRCURL[0]="https://beehive.molgen.mpg.de/704acada29e5fe5791f9f9949ff7b4ff/ffmpeg-7.0.tar.gz" +SRCURL="https://beehive.molgen.mpg.de/704acada29e5fe5791f9f9949ff7b4ff/ffmpeg-7.0.tar.gz" -PREFIX=${PREFIX}/${BUILD_PKG} +PREFIX="${PREFIX}/${BUILD_PKG}" -mkdir -p ${PREFIX} +mkdir -p "${PREFIX}" -cat >${PREFIX}/profile <<-EOF +cat >"${PREFIX}"/profile <<-EOF PATH=${PREFIX}/bin:\$PATH PKG_CONFIG_PATH=${PROJECT}/${BUILD_PKG}/lib/pkgconfig\${PKG_CONFIG_PATH:+:}\${PKG_CONFIG_PATH:-} EOF -test -e ${BUILD_PKG}.tar.gz || wget -nv ${SRCURL} -O ${BUILD_PKG}.tar.gz -test -d ${BUILD_PKG} || mkdir -pv ${BUILD_PKG} && tar -xf ${BUILD_PKG}.tar.gz --strip-components=1 -C ${BUILD_PKG} +test -e "${BUILD_PKG}".tar.gz || wget -nv "${SRCURL}" -O "${BUILD_PKG}".tar.gz +test -d "${BUILD_PKG}" || mkdir -pv "${BUILD_PKG}" && tar -xf "${BUILD_PKG}".tar.gz --strip-components=1 -C "${BUILD_PKG}" -cd ${BUILD_PKG} +cd "${BUILD_PKG}" local _conf=( - --prefix=${PREFIX} + --prefix="${PREFIX}" --enable-gpl --enable-version3 --enable-nonfree @@ -39,10 +39,14 @@ local _conf=( ./configure "${_conf[@]}" -make -j $NPROC install +make -j "${NPROC}" install } +pushd "${BUILD_DIR}" + B_FFMPEG +popd + } diff --git a/jbig2dec.build.sh b/jbig2dec.build.sh index 36a33db..4ae98b0 100755 --- a/jbig2dec.build.sh +++ b/jbig2dec.build.sh @@ -45,6 +45,10 @@ make -j "${NPROC}" install popd } +pushd "${BUILD_DIR}" + B_JBIG2DEC +popd + } diff --git a/jbig2enc.build.sh b/jbig2enc.build.sh index ccdaf37..97a73ce 100755 --- a/jbig2enc.build.sh +++ b/jbig2enc.build.sh @@ -52,6 +52,10 @@ make -j ${NPROC} install popd } +pushd "${BUILD_DIR}" + B_JBIG2ENC +popd + } diff --git a/leptonica.build.sh b/leptonica.build.sh index f12e707..02678c7 100755 --- a/leptonica.build.sh +++ b/leptonica.build.sh @@ -37,6 +37,10 @@ make -j ${NPROC} install } +pushd "${BUILD_DIR}" + B_LEPTONICA +popd + } diff --git a/liberation-fonts-ttf.build.sh b/liberation-fonts-ttf.build.sh index 657abe0..8546ade 100755 --- a/liberation-fonts-ttf.build.sh +++ b/liberation-fonts-ttf.build.sh @@ -29,6 +29,9 @@ done } +pushd "${BUILD_DIR}" + B_LIBFONTTTF +popd } diff --git a/nginx.build.sh b/nginx.build.sh index b8957f9..bfa66fd 100755 --- a/nginx.build.sh +++ b/nginx.build.sh @@ -40,7 +40,7 @@ pushd ${BUILD_PKG} # What you see here is the representation of the string "nginx" compressed with HPACK's Huffman encoding. # ~/go/src/github.com/wwwutz/hpack -patch -p1 --silent --backup --forward --input=../nginx.chicken.patch || true +patch -p1 --silent --backup --forward --input=${BUILD_SRC}/nginx.chicken.patch || true local _conf=( --prefix="${PREFIX}" @@ -70,6 +70,10 @@ popd } +pushd "${BUILD_DIR}" + B_NGINX +popd + } diff --git a/node.build.sh b/node.build.sh index 13e62da..8d9b238 100755 --- a/node.build.sh +++ b/node.build.sh @@ -13,7 +13,7 @@ function B_NODEJS { [ -d "$PREFIX" ] || { echo "PREFIX unset or not a directory";exit; } -wget "https://nodejs.org/download/release/v20.15.0/node-v20.15.0.tar.gz" +# wget "https://nodejs.org/download/release/v20.15.0/node-v20.15.0.tar.gz" SRCURL="https://beehive.molgen.mpg.de/4916451f1f2f966896f4922f90470350/node-v20.15.0.tar.gz" PREFIX=${PREFIX}/${BUILD_node} @@ -28,23 +28,29 @@ EOF test -e ${BUILD_node}.tar.gz || wget -nv ${SRCURL} -O ${BUILD_node}.tar.gz test -d ${BUILD_node} || mkdir -pv ${BUILD_node} && tar -xf ${BUILD_node}.tar.gz --strip-components=1 -C ${BUILD_node} -. ${PREFIX}/profile +# . "${PREFIX}"/profile cd ${BUILD_node} local _conf=( - --prefix=${PREFIX} + --prefix="${PREFIX}" ) +# export npm_config_cache="${PREFIX}"/cache + CFLAGS='-O2 -fPIC' \ ./configure "${_conf[@]}" -make -j $NPROC +make -j "${NPROC}" make install } +pushd "${BUILD_DIR}" + B_NODEJS +popd + } diff --git a/paperless-ngx.build.sh b/paperless-ngx.build.sh index f1ae962..927f5ff 100755 --- a/paperless-ngx.build.sh +++ b/paperless-ngx.build.sh @@ -18,28 +18,56 @@ set -e . ${PREFIX}/${BUILD_jbig2dec}/profile . ${PREFIX}/${BUILD_tesseract}/profile + function B_PAPERLESS { PREFIX=${PROJECT}/paperless-ngx -if [ ! -d ${BUILD_paperless} ]; then - if [ ! -e ${BUILD_paperless}.tar ]; then - git clone https://github.com/paperless-ngx/paperless-ngx.git --branch v${BUILD_paperless##*-} --single-branch ${BUILD_paperless} - tar cf ${BUILD_paperless}.tar ${BUILD_paperless} - else - tar -xf ${BUILD_paperless}.tar - fi - if [ ! -d ${PREFIX} ]; then - git clone ${BUILD_paperless} $PREFIX - else - pushd ${PREFIX} - git pull origin v${BUILD_paperless##*-} - popd - fi +BUILD_PKG=${BUILD_paperless} + +if [[ -e ${BUILD_PKG}.tar ]]; then + tar -xf ${BUILD_PKG}.tar +fi + +if [[ ! -d ${BUILD_PKG} ]]; then + git clone https://github.com/paperless-ngx/paperless-ngx.git --branch v${BUILD_PKG##*-} --single-branch ${BUILD_PKG} +fi + +if [[ ! -e ${BUILD_PKG}.tar ]]; then + tar cf ${BUILD_PKG}.tar ${BUILD_PKG} +fi + +if [[ ! -d ${PREFIX} ]]; then + git clone ${BUILD_PKG} ${PREFIX} +else + pushd ${PREFIX} + git pull origin v${BUILD_paperless##*-} + popd fi + + +#if [ ! -d ${BUILD_paperless} ]; then +# if [ ! -e ${BUILD_paperless}.tar ]; then +# git clone https://github.com/paperless-ngx/paperless-ngx.git --branch #v${BUILD_paperless##*-} --single-branch ${BUILD_paperless} +# tar cf ${BUILD_paperless}.tar ${BUILD_paperless} +# else +# tar -xf ${BUILD_paperless}.tar +# fi +# if [ ! -d ${PREFIX} ]; then +# git clone ${BUILD_paperless} $PREFIX +# else +# pushd ${PREFIX} +# git pull origin v${BUILD_paperless##*-} +# popd +# fi +#fi + # we need paperless-ngx to be extracted since it reads paperless.conf.example +# what a mess 8-( +pushd ${BUILD_SRC} ./paperless.conf.build.sh +popd pushd $PROJECT @@ -55,7 +83,6 @@ pushd $PREFIX . ${PROJECT}/profile - pipenv requirements > requirements.txt pip install -r requirements.txt @@ -85,7 +112,7 @@ pushd src ./manage.py migrate PAPERLESS_ADMIN_USER=${PAPERLESS_ADMIN_USER:-admin} -PAPERLESS_ADMIN_PASSWORD=${PAPERLESS_ADMIN_PASSWORD:-$(cat /dev/urandom | head -c 64 | openssl base64 |head -1)} +PAPERLESS_ADMIN_PASSWORD=${PAPERLESS_ADMIN_PASSWORD:-$( head -c 64 /dev/urandom | openssl base64 |head -1)} PAPERLESS_ADMIN_MAIL=${PAPERLESS_ADMIN_MAIL:-admin@localhost.lan} ./manage.py shell -c "from django.contrib.auth.models import User; User.objects.create_superuser('${PAPERLESS_ADMIN_USER}', '${PAPERLESS_ADMIN_MAIL}', '${PAPERLESS_ADMIN_PASSWORD}')" || true @@ -104,6 +131,10 @@ popd } +pushd "${BUILD_DIR}" + B_PAPERLESS +popd + } diff --git a/paperless.conf.build.sh b/paperless.conf.build.sh index b0e5e5e..c6aa0ce 100755 --- a/paperless.conf.build.sh +++ b/paperless.conf.build.sh @@ -8,7 +8,7 @@ PREFIX=${PROJECT}/paperless-ngx TO=${PROJECT}/conf/paperless.conf # ist source entpackt ? -[ -d "./${BUILD_paperless}" ] || { echo "${BUILD_paperless} does not exist.";exit 1; } +[ -d "${BUILD_DIR}/${BUILD_paperless}" ] || { echo "${BUILD_paperless} does not exist.";exit 1; } # config file hoch linken ln -vfs ${PROJECT}/conf/paperless.conf ${PREFIX} diff --git a/pngquant.build.sh b/pngquant.build.sh index 0cd0a5b..da5831d 100755 --- a/pngquant.build.sh +++ b/pngquant.build.sh @@ -58,6 +58,9 @@ install -v -Dm0755 ./target/release/pngquant "${PREFIX}"/bin/pngquant popd } +pushd "${BUILD_DIR}" + B_PNGQUANT +popd } diff --git a/redis.build.sh b/redis.build.sh index e603638..ecbd759 100755 --- a/redis.build.sh +++ b/redis.build.sh @@ -30,6 +30,10 @@ make -j "${NPROC}" install PREFIX="${PREFIX}" } +pushd "${BUILD_DIR}" + B_REDIS +popd + } diff --git a/sqlite.build.sh b/sqlite.build.sh index 850e44e..de88c3a 100755 --- a/sqlite.build.sh +++ b/sqlite.build.sh @@ -9,7 +9,7 @@ set -u function B_SQLITE { # wget "https://sqlite.org/2024/sqlite-autoconf-3460000.tar.gz" -SRCURL[0]="https://beehive.molgen.mpg.de/ff687dfc7483196420a4f16a6f53702d/sqlite-autoconf-3460000.tar.gz" +SRCURL="https://beehive.molgen.mpg.de/ff687dfc7483196420a4f16a6f53702d/sqlite-autoconf-3460000.tar.gz" BUILD_PKG=${BUILD_sqlite} BUILD_EXT=${SRCURL/${SRCURL%.*.*}/} @@ -51,6 +51,10 @@ popd } +pushd "${BUILD_DIR}" + B_SQLITE +popd + } diff --git a/tesseract.build.sh b/tesseract.build.sh index 89f5d08..26f442b 100755 --- a/tesseract.build.sh +++ b/tesseract.build.sh @@ -95,7 +95,10 @@ tar xf tessconfigs.tar --exclude=.git -C ${PREFIX}/share/tessdata } +pushd "${BUILD_DIR}" + B_TESSERACT B_TESSDATA +popd } diff --git a/unpaper.build.sh b/unpaper.build.sh index 9b4ddf0..79fddc8 100755 --- a/unpaper.build.sh +++ b/unpaper.build.sh @@ -64,6 +64,9 @@ popd } +pushd "${BUILD_DIR}" + B_UNPAPER +popd } diff --git a/zbar.build.sh b/zbar.build.sh index d838be0..4b6d839 100755 --- a/zbar.build.sh +++ b/zbar.build.sh @@ -57,6 +57,10 @@ make install } +pushd "${BUILD_DIR}" + B_ZBAR +popd + }