#!/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 # FIXME: download downstream binary index and check for architecture-missing-builds 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="bookworm" DOWNSTREAM_DISTRIBUTION="fuchur-backports" DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages" DOWNSTREAM_TAG="progress" ;; graograman) UPSTREAM_DISTRIBUTIONS="bookworm bookworm-updates bookworm-proposed-updates" DOWNSTREAM_DISTRIBUTION="graograman" DOWNSTREAM_MIRROR="https://apt.progress-linux.org/packages" DOWNSTREAM_TAG="progress" ;; graograman-backports) UPSTREAM_DISTRIBUTIONS="sid experimental" DOWNSTREAM_DISTRIBUTION="graograman-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" #ARCHITECTURES="amd64 armel armhf arm64 i386 all source" ARCHITECTURES="amd64 arm64 all source" Download_downstream_indices () { # Download downstream indices # 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_indices () { # Download upstream indices # 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}.binaries" ] && [ "$(( $(stat -c %Y upstream.${MODE}.binaries) + ( 4 * 3600 ) ))" -lt "$(date +%s)" ] # then # # file is older than 4 hours rm -f "upstream.${MODE}.binaries" # fi # if [ ! -e "upstream.${MODE}.indices" ] # then echo -n "Downloading indices... " 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 for ARCHITECTURE in ${ARCHITECTURES} do echo -n "." case "${ARCHITECTURE}" in source) wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}/updates/${SECTION}/${ARCHITECTURE}/Sources.xz" | xz -d >> "upstream.${MODE}.sources" ;; *) if wget -q -O /dev/null "http://security.debian.org/dists/${DISTRIBUTION}/updates/${SECTION}/binary-${ARCHITECTURE}/Packages.xz" then wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}/updates/${SECTION}/binary-${ARCHITECTURE}/Packages.xz" | xz -d >> "upstream.${MODE}.binaries" fi ;; esac done done fi if wget -q -O /dev/null "http://security.debian.org/dists/${DISTRIBUTION}-security/Release" then for SECTION in ${UPSTREAM_SECTIONS} do for ARCHITECTURE in ${ARCHITECTURES} do echo -n "." case "${ARCHITECTURE}" in source) wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}-security/${SECTION}/${ARCHITECTURE}/Sources.xz" | xz -d >> "upstream.${MODE}.sources" ;; *) wget -q -O - "http://security.debian.org/dists/${DISTRIBUTION}-security/${SECTION}/binary-${ARCHITECTURE}/Packages.xz" | xz -d >> "upstream.${MODE}.binaries" ;; esac done done fi ;; esac for SECTION in ${UPSTREAM_SECTIONS} do for ARCHITECTURE in ${ARCHITECTURES} do echo -n "." case "${ARCHITECTURE}" in source) wget -q -O - "${UPSTREAM_MIRROR}/dists/${DISTRIBUTION}/${SECTION}/${ARCHITECTURE}/Sources.xz" | xz -d >> "upstream.${MODE}.sources" ;; *) wget -q -O - "${UPSTREAM_MIRROR}/dists/${DISTRIBUTION}/${SECTION}/binary-${ARCHITECTURE}/Packages.xz" | xz -d >> "upstream.${MODE}.binaries" ;; esac done done done echo " done." # fi } Download_downstream_indices Download_upstream_indices # Process downstream indices 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 }')" case "${MODE}" in *-backports) # ignore BinNMUs UPSTREAM_VERSION="$(sed -n "/^Package: ${PACKAGE}$/,/^Version:/p" upstream.${MODE}.sources | awk '/^Version: / { print $2 }' | sort -rV | head -n1)" ;; *) # upstream_source_version = highest version of (upstream_source_versions + upstream_binary_versions) UPSTREAM_VERSION="$(grep -A2 "^Package: ${PACKAGE}\$" upstream.${MODE}.sources | awk '/^Version: / { print $2 }') $(for BINARY in $(grep -A1 "^Package: ${PACKAGE}\$" upstream.${MODE}.sources | grep '^Binary:' | cut -d: -f 2- | sed -e 's|,||g'); do grep -A2 "^Package: ${BINARY}\$" upstream.${MODE}.binaries ; done | awk '/^Version: / { print $2 }')" UPSTREAM_VERSION="$(echo ${UPSTREAM_VERSION} | sed -e 's| |\n|g' | sort -rV | head -n1)" ;; esac 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."