Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 291 lines (261 sloc) 6.28 KB
#!/bin/bash
set -u
. build.profile
[[ -d "${TMPDIR}" ]] || mkdir -p "${TMPDIR}"
tmp="${TMPDIR}/cv.$$.tmp"
#tmp=/tmp/cv.tmp
function rm_tmp() {
:
rm -f "${tmp}"
}
trap rm_tmp EXIT
declare -A CHECK_URL
function parsefile() {
U=$1
P=$2
D=${3:-''}
curl -s -L "${U}" -o "${tmp}"
x1=$(grep --max-count=1 -oP -e "${P}" "${tmp}")
if [[ -n "${D}" ]]; then
x1=${x1}'-'$(grep --max-count=1 -oP -e "${D}" "${tmp}")
fi
echo $x1
}
function parselast() {
U=$1
P=$2
D=${3:-''}
curl -s -L "${U}" -o "${tmp}"
x1=$(grep -oP -e "${P}" "${tmp}"|tail -1)
echo $x1
}
# git_describe_remote
function gdrem() {
G=$1
P=$2
C=${3:-'(?<=<title>Release ).*?(?=<)'}
D=${4:-''}
L=$(git ls-remote --refs --sort=-v:refname "https://github.com/${G}" "${P}" | head -1)
_IFS=$IFS
${IFS+':'} unset _IFS
IFS=[$'\t'/]
set -- $L
IFS=$_IFS
${_IFS+':'} unset IFS
SHA=$1
TAG=$4
URL="https://github.com/${G}/releases"
parsefile "${URL}/tag/${TAG}" "${C}" "${D}"
echo "${URL}"
}
function parse() {
U=$1
P=$2
parsefile "${U}" "${P}"
echo "${U}"
}
function bparse() {
U=$1
P=$2
if [[ $(curl -s -L "${U}") =~ ${P} ]]; then
echo "${BASH_REMATCH[1]}${BASH_REMATCH[2]:+-}${BASH_REMATCH[2]:-}"
fi
echo "${U}"
}
function mtype() {
local _a=$1
local _p=$(type -p $_a)
echo '...'${_p#$PREFIX}
}
# https://api.github.com/repos/paperless-ngx/paperless-ngx/releases/latest&
if [[ -e "$PROJECT"/profile ]]; then
. "$PROJECT"/profile
function exec_BUILD_node () {
node --version
mtype node
}
function exec_BUILD_python () {
python --version|cut -d' ' -f2
mtype python
}
function exec_BUILD_redis () {
redis-cli --version|cut -d' ' -f2
mtype redis-cli
}
function exec_BUILD_sqlite () {
sqlite3 --version|cut -d' ' -f1
mtype sqlite3
}
function exec_BUILD_nginx () {
nginx -v 2>&1|cut -d/ -f2|cut -d' ' -f1
mtype nginx
}
function exec_BUILD_ffmpeg () {
ffmpeg -version | head -1 | cut -d' ' -f3
mtype ffmpeg
}
function exec_BUILD_imagemagick () {
magick --version | head -1 | cut -d' ' -f3
mtype magick
}
function exec_BUILD_unpaper () {
unpaper --version | head -1
mtype unpaper
}
function exec_BUILD_tesseract () {
tesseract --version | head -1 | cut -d' ' -f2
mtype tesseract
}
function exec_BUILD_zbar () {
zbarimg --version
mtype zbarimg
}
function exec_BUILD_leptonica() {
pkg-config --modversion lept
echo "no-exec"
}
function exec_BUILD_jbig2enc () {
jbig2 -V 2>&1|head -1|cut -d' ' -f2
mtype jbig2
}
function exec_BUILD_jbig2dec () {
jbig2dec -V 2>&1|cut -d' ' -f2
mtype jbig2dec
}
function exec_BUILD_pngquant () {
pngquant -V
mtype pngquant
}
function exec_BUILD_libwebp () {
webpinfo -version|cut -d' ' -f4
mtype webpinfo
}
function exec_BUILD_libjpegturbo () {
re='version (\S+)\s\(build\s(\S+)\)'
[[ $(cjpeg -version 2>&1) =~ $re ]] && echo "${BASH_REMATCH[1]}-${BASH_REMATCH[2]}"
mtype cjpeg
}
function exec_BUILD_libtiff () {
re='Version\s+(\S+)'
[[ $(tiffinfo 2>&1) =~ $re ]] && echo "${BASH_REMATCH[1]}"
mtype tiffinfo
}
fi
version_BUILD_paperless() {
gdrem paperless-ngx/paperless-ngx 'refs/tags/v*'|cut -d' ' -f2
}
version_BUILD_imagemagick() {
gdrem ImageMagick/ImageMagick 'refs/tags/[0-9]*'|cut -d' ' -f1
}
version_BUILD_node() {
parse 'https://github.com/nodejs/node/releases' '(?<=Version ).*?(?= ).*LTS\)'|cut -d' ' -f1
}
version_BUILD_python() {
parselast 'https://raw.githubusercontent.com/python/peps/main/peps/pep-0664.rst' '(?<=^- )[0-9].*(?=: )'
}
version_BUILD_redis() {
parse 'https://redis.io/downloads/' '(?<=>).*(?=\s+release notes)'
}
version_BUILD_sqlite() {
parse 'https://sqlite.org/index.html' '(?<=Version ).*(?=<)'
}
version_BUILD_nginx() {
parse 'https://nginx.org/' '(?<=nginx-).*?(?=<)'
}
version_BUILD_tesseract() {
gdrem tesseract-ocr/tesseract 'refs/tags/[0-9]*'|cut -d' ' -f1
}
version_BUILD_tessdata() {
gdrem tesseract-ocr/tessdata_best 'refs/tags/[0-9]*' '(?<=Release ).*?(?=\s)'|cut -d' ' -f2
}
version_BUILD_jbig2dec() {
gdrem ArtifexSoftware/jbig2dec 'refs/tags/[0-9]*'|cut -d' ' -f2
}
version_BUILD_jbig2enc() {
gdrem agl/jbig2enc 'refs/tags/[0-9]*'|cut -d' ' -f1
}
version_BUILD_leptonica() {
gdrem DanBloomberg/leptonica 'refs/tags/[0-9]*'|cut -d' ' -f3
}
version_BUILD_ffmpeg() {
parse 'https://git.videolan.org/?p=ffmpeg.git;a=blob_plain;f=Changelog' '(?<=^version )\d.*(?=:)'
}
version_BUILD_pngquant() {
gdrem kornelski/pngquant 'refs/tags/*'|cut -d' ' -f1
}
version_BUILD_zbar() {
gdrem mchehab/zbar 'refs/tags/[0-9]*'|cut -d' ' -f2
}
version_BUILD_unpaper() {
gdrem unpaper/unpaper 'refs/tags/unpaper-*' '(?<=<title>Release unpaper-).*?(?=\s)' '(?<= )[0-9]+(?= commits)'|tr '\n' ' '
}
version_BUILD_libfontttf() {
gdrem liberationfonts/liberation-fonts 'refs/tags/[0-9]*'|cut -d' ' -f1
}
version_BUILD_libwebp() {
bparse 'https://chromium.googlesource.com/webm/libwebp/' 'v([1-9]+\.[0-9]+\.[0-9]+)'
}
version_BUILD_libjpegturbo() {
gdrem libjpeg-turbo/libjpeg-turbo 'refs/tags/[0-9]*'|cut -d' ' -f1
}
version_BUILD_libtiff() {
bparse 'https://download.osgeo.org/libtiff/?C=M&O=D' 'tiff-(\S+?).tar.gz'
}
function version() {
Bi=$1
B=$(eval eval echo \\$\${Bi})
shift
# printf "%-s\n" "$Bi"
printf "#### %26s\n" "$B"
if [[ $(type -t exec_${Bi}) = 'function' ]]; then
# printf " exe %32s %s\n" "$(exec_${Bi}|tr '\n' ' ')"
v=$(exec_${Bi}|tr '\n' ' ')
printf " exe %26s %s\n" $v
else
: # printf "no exec_()\n"
fi
if [[ $(type -t version_${Bi}) = 'function' ]]; then
v=$(version_${Bi})
printf " ver %26s %s\n" $v
else
printf "no version_()\n"
fi
echo
}
_parts=(
BUILD_paperless
BUILD_node
BUILD_python
BUILD_redis
BUILD_sqlite
BUILD_nginx
BUILD_tesseract
BUILD_tessdata
BUILD_libwebp
BUILD_libjpegturbo
BUILD_libtiff
BUILD_jbig2dec
BUILD_jbig2enc
BUILD_leptonica
BUILD_ffmpeg
BUILD_imagemagick
BUILD_pngquant
BUILD_zbar
BUILD_unpaper
BUILD_libfontttf
)
_xparts=(
BUILD_leptonica
)
# list of versions
for p in "${_parts[@]}"; do
B=$(eval eval echo \\$\${p})
echo -n "$B - "
done
echo
# check versions
for p in "${_parts[@]}"; do
version $p
done
# apptainer build --sandbox xxx docker://ghcr.io/paperless-ngx/paperless-ngx:latest
# grep PYTHON xxx/.singularity.d/env/10-docker2singularity.sh