#!/bin/bash set -exo pipefail . $(dirname ${BASH_SOURCE[0]})/../helpers.sh export ARCHS=(all) function postinst_configure_pre() { :; } function postinst_configure_post() { :; } function _vcompare() { for V in $@; do if [[ "$V" =~ ^\<[0-9.]*$ ]]; then [[ $(echo -e "$NCMAJOR_OVERRIDE\n${V:1}" | sort -V | head -1) -eq "$NCMAJOR_OVERRIDE" ]] || return 1; elif [[ "$V" =~ ^\<=[0-9.]*$ ]]; then [[ $(echo -e "$NCMAJOR_OVERRIDE\n${V:2}" | sort -V | head -1) -eq "$NCMAJOR_OVERRIDE" ]] || return 1; elif [[ "$V" =~ ^\>[0-9.]*$ ]]; then [[ $(echo -e "$NCMAJOR_OVERRIDE\n${V:1}" | sort -rV | head -1) -eq "$NCMAJOR_OVERRIDE" ]] || return 1; elif [[ "$V" =~ ^\>=[0-9.]*$ ]]; then [[ $(echo -e "$NCMAJOR_OVERRIDE\n${V:2}" | sort -rV | head -1) -eq "$NCMAJOR_OVERRIDE" ]] || return 1; elif [[ "$V" =~ ^=[0-9.]*$ ]]; then [[ "$NCMAJOR_OVERRIDE" -eq "${V:1}" ]] || return 1; elif [[ "$V" =~ ^==[0-9.]*$ ]]; then [[ "$NCMAJOR_OVERRIDE" -eq "${V:1}" ]] || return 1; else echo "Unknown version string '${V}'" return 1 fi done return 0 } function pre_fetch() { :; } function _fetch() { cd "${SRCDIR}" VERSIONS=$(curl -H 'Accept: application/json' "${_NCAPPS_URL}" | jq --arg app "${APP}" -r "${_NCAPPS_JQ}") while read -r VERSION URL COMPAT; do if _vcompare $COMPAT; then echo "Fetching version ${VERSION}" wget "${URL}" --output-document "app.tar.gz" tar -xf "app.tar.gz" return fi done <<<$VERSIONS echo "No compatible app version is available" exit 1 } function post_fetch() { :; } function pre_prepare() { :; } function _prepare() { mkdir -p \ "${PKGDIR}/DEBIAN" \ "${PKGDIR}/usr/share/doc/${PKGNAME}" \ "${PKGDIR}/usr/lib/nextcloud/nextcloud-apps" VERSION=$(cat "${SRCDIR}/${APP}/appinfo/info.xml" | xq-python -r .info.version) SUMMARY=$(cat "${SRCDIR}/${APP}/appinfo/info.xml" | xq-python -r '.info.summary | if type == "array" then (.[] | select(.["@lang"]=="en") | .["#text"]) else (.) end') DESCRIPTION=$(cat "${SRCDIR}/${APP}/appinfo/info.xml" | xq-python -r '.info.description | if type == "array" then (.[] | select(.["@lang"]=="en") | .["#text"]) else (.) end') PHP_MIN=$(cat "${SRCDIR}/${APP}/appinfo/info.xml" | xq-python -r '.info.dependencies.php."@min-version"') PHP_MAX=$(cat "${SRCDIR}/${APP}/appinfo/info.xml" | xq-python -r '.info.dependencies.php."@max-version"') PHP_DEP="" # #f [[ "${PHP_MIN}" != "null" ]]; then # PHP_DEP="${PHP_DEP}, php (>= ${PHP_MIN})" # fi # if [[ "${PHP_MAX}" != "null" ]]; then # # awk increments the last version component, from https://stackoverflow.com/a/69489163 # PHP_MAX=$(echo "${PHP_MAX}" | awk -F. -v OFS=. '{$NF=$NF+1;print}') # PHP_DEP="${PHP_DEP}, php (<< ${PHP_MAX})" # fi cp -r "${SRCDIR}/${APP}" "${PKGDIR}/usr/lib/nextcloud/nextcloud-apps/${APP}" cat > "${PKGDIR}/DEBIAN/control" < "${PKGDIR}/DEBIAN/postinst" <