Skip to content

Commit

Permalink
Merge pull request #40 from mariux64/update-2.10.2
Browse files Browse the repository at this point in the history
paperless-ngx: adding BUILD_DIR support
  • Loading branch information
wwwutz authored Jun 26, 2024
2 parents de1f2c5 + 855faf6 commit 47f5f6a
Show file tree
Hide file tree
Showing 19 changed files with 148 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build
/build.local
/ffmpeg-*
/jbig2enc-*
Expand Down
3 changes: 3 additions & 0 deletions Python.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pip3 install sphinx

}

pushd "${BUILD_DIR}"

B_PYTHON

popd
}
7 changes: 5 additions & 2 deletions build.profile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
BUILD_TAG=2.10.1
BUILD_TAG=2.10.2

BUILD_DIR=.
BUILD_SRC="${PWD}"

. build.local

Expand Down Expand Up @@ -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
47 changes: 26 additions & 21 deletions buildall.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -u

BUILD_LOCAL=build.local
if [ ! -e ${BUILD_LOCAL} ]; then
Expand Down Expand Up @@ -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
22 changes: 13 additions & 9 deletions ffmpeg.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,10 +39,14 @@ local _conf=(

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

make -j $NPROC install
make -j "${NPROC}" install

}

pushd "${BUILD_DIR}"

B_FFMPEG

popd

}
4 changes: 4 additions & 0 deletions jbig2dec.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ make -j "${NPROC}" install
popd
}

pushd "${BUILD_DIR}"

B_JBIG2DEC

popd

}
4 changes: 4 additions & 0 deletions jbig2enc.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ make -j ${NPROC} install
popd
}

pushd "${BUILD_DIR}"

B_JBIG2ENC

popd

}
4 changes: 4 additions & 0 deletions leptonica.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ make -j ${NPROC} install

}

pushd "${BUILD_DIR}"

B_LEPTONICA

popd

}
3 changes: 3 additions & 0 deletions liberation-fonts-ttf.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ done

}

pushd "${BUILD_DIR}"

B_LIBFONTTTF

popd
}
6 changes: 5 additions & 1 deletion nginx.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -70,6 +70,10 @@ popd

}

pushd "${BUILD_DIR}"

B_NGINX

popd

}
14 changes: 10 additions & 4 deletions node.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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

}
63 changes: 47 additions & 16 deletions paperless-ngx.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -55,7 +83,6 @@ pushd $PREFIX

. ${PROJECT}/profile


pipenv requirements > requirements.txt

pip install -r requirements.txt
Expand Down Expand Up @@ -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
Expand All @@ -104,6 +131,10 @@ popd

}

pushd "${BUILD_DIR}"

B_PAPERLESS

popd

}
2 changes: 1 addition & 1 deletion paperless.conf.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions pngquant.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ install -v -Dm0755 ./target/release/pngquant "${PREFIX}"/bin/pngquant
popd
}

pushd "${BUILD_DIR}"

B_PNGQUANT

popd
}
4 changes: 4 additions & 0 deletions redis.build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ make -j "${NPROC}" install PREFIX="${PREFIX}"

}

pushd "${BUILD_DIR}"

B_REDIS

popd

}
Loading

0 comments on commit 47f5f6a

Please sign in to comment.