diff options
Diffstat (limited to 'web/update')
-rwxr-xr-x | web/update | 177 |
1 files changed, 177 insertions, 0 deletions
diff --git a/web/update b/web/update new file mode 100755 index 0000000..a73d6a9 --- /dev/null +++ b/web/update @@ -0,0 +1,177 @@ +#!/bin/sh + +set -e + +RED="\033[1;33;31m" +GREEN="\033[1;33;32m" +YELLOW="\033[1;33;33m" +BLUE="\033[1;33;34m" +WHITE="\033[1;33;37m" +NORMAL="\033[0m" + +# FIXME: getopt +# FIXME: -f for forced indices download + +MODE="$(basename ${0} | awk -F. '{ print $2 }')" + +case "${MODE}" in + engywuck) + UPSTREAM_DISTRIBUTIONS="buster buster-updates buster-proposed-updates" + DOWNSTREAM_DISTRIBUTION="engywuck" + DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages" + DOWNSTREAM_TAG="progress" + ;; + + engywuck-backports) + UPSTREAM_DISTRIBUTIONS="bullseye bullseye-updates bullseye-proposed-updates" + DOWNSTREAM_DISTRIBUTION="engywuck-backports" + DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages" + DOWNSTREAM_TAG="progress" + ;; + + fuchur) + UPSTREAM_DISTRIBUTIONS="bullseye bullseye-updates bullseye-proposed-updates" + DOWNSTREAM_DISTRIBUTION="fuchur" + DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages" + DOWNSTREAM_TAG="progress" + ;; + + fuchur-backports) + UPSTREAM_DISTRIBUTIONS="sid experimental" + DOWNSTREAM_DISTRIBUTION="fuchur-backports" + DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages" + DOWNSTREAM_TAG="progress" + ;; + + buster) + UPSTREAM_DISTRIBUTIONS="buster buster-updates buster-proposed-updates" + DOWNSTREAM_DISTRIBUTION="buster" + DOWNSTREAM_MIRROR="https://apt.bfh.science/packages" + DOWNSTREAM_TAG="bfh" + ;; + + buster-backports) + UPSTREAM_DISTRIBUTIONS="sid experimental" + DOWNSTREAM_DISTRIBUTION="buster-backports" + DOWNSTREAM_MIRROR="https://apt.bfh.science/packages" + DOWNSTREAM_TAG="bfh" + ;; +esac + +UPSTREAM_SECTIONS="main contrib non-free" +UPSTREAM_MIRROR="http://debian.ethz.ch/debian" + +DOWNSTREAM_SECTIONS="main contrib non-free" + +Download_downstream_sources () +{ + # Download downstream sources +# if [ -e "downstream.${MODE}.sources" ] && [ "$(( $(stat -c %Y downstream.${MODE}.sources) + ( 4 * 3600 ) ))" -lt "$(date +%s)" ] +# then +# # file is older than 4 hours + rm -f "downstream.${MODE}.sources" +# fi + + if [ ! -e "downstream.${MODE}.sources" ] + then + for SECTION in ${DOWNSTREAM_SECTIONS} + do + wget -q -O - "${DOWNSTREAM_MIRROR}/dists/${DOWNSTREAM_DISTRIBUTION}/${SECTION}/source/Sources.xz" | xz -d >> "downstream.${MODE}.sources" + done + fi +} + +Download_upstream_sources () +{ + # Download upstream sources + if [ -e "upstream.${MODE}.sources" ] && [ "$(( $(stat -c %Y upstream.${MODE}.sources) + ( 4 * 3600 ) ))" -lt "$(date +%s)" ] + then + # file is older than 4 hours + rm -f "upstream.${MODE}.sources" + fi + + if [ ! -e "upstream.${MODE}.sources" ] + then + for DISTRIBUTION in ${UPSTREAM_DISTRIBUTIONS} + do + case "${DISTRIBUTION}" in + *-*) + ;; + + *) + if wget -q -O /dev/null "http://security.debian.org/dists/${DISTRIBUTION}/updates/Release" + then + for SECTION in ${UPSTREAM_SECTIONS} + do + wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}/updates/${SECTION}/source/Sources.xz" | xz -d >> "upstream.${MODE}.sources" + done + fi + ;; + esac + + for SECTION in ${UPSTREAM_SECTIONS} + do + wget -q -O - "${UPSTREAM_MIRROR}/dists/${DISTRIBUTION}/${SECTION}/source/Sources.xz" | xz -d >> "upstream.${MODE}.sources" + done + done + fi +} + +Download_downstream_sources +Download_upstream_sources + +# Process downstream sources +DOWNSTREAM_PACKAGES="$(awk '/^Package: / { print $2 }' downstream.${MODE}.sources | sort -u)" + +echo "################################################################################" +echo "${DOWNSTREAM_DISTRIBUTION}" +echo "################################################################################" + +echo -n "Comparing versions... " + +for PACKAGE in ${DOWNSTREAM_PACKAGES} +do + DOWNSTREAM_VERSION="$(sed -n "/^Package: ${PACKAGE}$/,/^Version:/p" downstream.${MODE}.sources | awk '/^Version: / { print $2 }')" + UPSTREAM_VERSION="$(sed -n "/^Package: ${PACKAGE}$/,/^Version:/p" upstream.${MODE}.sources | awk '/^Version: / { print $2 }' | sort -rV | head -n1)" + + if echo ${UPSTREAM_VERSION} | grep -qs '-' + then + # package is non-native + DOWNSTREAM="$(echo ${DOWNSTREAM_VERSION} | sed -e "s|~${DOWNSTREAM_TAG}.*||" -e "s|${DOWNSTREAM_TAG}.*||")" + else + # package is native + DOWNSTREAM="$(echo ${DOWNSTREAM_VERSION} | sed -e "s|-0.0~${DOWNSTREAM_TAG}.*||" -e "s|-0.*${DOWNSTREAM_TAG}.*||")" + fi + + if grep -qs "^${PACKAGE} ${UPSTREAM_VERSION}$" ignore.txt + then + continue + fi + + if [ -z "${UPSTREAM_VERSION}" ] && grep -qs "^${PACKAGE} ${DOWNSTREAM_VERSION}$" ignore.txt + then + continue + fi + + if [ -z "${UPSTREAM_VERSION}" ] + then + echo "${BLUE}${PACKAGE}${NORMAL} '!${DOWNSTREAM_VERSION}'" + continue + fi + + # comparing versions + if dpkg --compare-versions ${UPSTREAM_VERSION} eq ${DOWNSTREAM} + then + echo -n "." + elif dpkg --compare-versions ${UPSTREAM_VERSION} gt ${DOWNSTREAM} + then + echo "${RED}${PACKAGE}${NORMAL} '${UPSTREAM_VERSION} >> ${DOWNSTREAM_VERSION}'" + elif dpkg --compare-versions ${UPSTREAM_VERSION} lt ${DOWNSTREAM} + then + echo "${YELLOW}${PACKAGE}${NORMAL} '${UPSTREAM_VERSION} << ${DOWNSTREAM_VERSION}'" + else + echo "${PACKAGE}: internal error" + fi +done + +echo " done." |