Add reprepro version obsolescence

We've moved reprepro to a version that supports keeping multiple
versions for the purpose of facilitating downgrades if people need it.
However the logic of the multiple versions functionality there does not
permit the granular rules we want. This implements them manually.

1. For Unstable builds, we only want to keep a max of 4 in the repo
(matching what we keep in the web archive). Since reprepro doesn't
support granularity of Limit at the component level, implement logic to
remove all but the most recent 4 unstables if there end up being more
than 4 after importing the new version.

2. For Stable builds, we want to keep the last point release of a given
major release (e.g. keep 10.10.13 but obsolete 10.10.12), while also
keeping older major versions (e.g. 10.9.10). Again the logic in reprepro
is too simplistic to handle this, so we implement it manually. For any
version that comes in, if the point version is above 0, we remove any
packages with a version that's one point release behind that one within
the same major version, while preserving everything else.
This commit is contained in:
Joshua M. Boniface
2025-03-30 16:47:14 -04:00
parent bfd3345210
commit 726f9b0760

View File

@@ -142,6 +142,36 @@ jobs:
# Only include the source DSC for amd64; the other architectures are the same and conflict
sudo reprepro --waitforlock 30 --basedir /srv/debian --component ${COMPONENT} includedsc ${{ matrix.release }} /srv/incoming/server/${{ env.JELLYFIN_VERSION }}/debian/${{ matrix.release }}/${{ matrix.arch }}/*.dsc || exit 1
fi
# Only keep ${NKEEP} (4) unstables; we have to do this manually since reprepro doesn't have granularity for this at the component level
if [[ ${COMPONENT} == "unstable" ]]; then
NKEEP=4
# Get whatever the oldest version is; since these are dated, a simple numerical sort works
LIST="$( sudo reprepro -b /srv/debian -C unstable list ${{ matrix.release }} | awk '{ print $NF }' | sort -rn | uniq )"
COUNT=$( wc -l <<<"${LIST}" )
if [[ ${COUNT} -gt ${NKEEP} ]]; then
# Get anything that isn't in the latest ${NKEEP} entries
OBSOLETE=( sed "1,${NKEEP}d" <<<"${LIST}" )
for VERSION in ${OBSOLETE[@]}; do
for PACKAGE in jellyfin jellyfin-server jellyfin-web; do
sudo reprepro --waitforlock 30 --basedir /srv/debian --component ${COMPONENT} remove ${{ matrix.release }} ${PACKAGE}=${VERSION}
done
done
fi
fi
# Only keep the latest point release for a given stable version; i.e. 10.10.14 obsoletes 10.10.13 and removes it, while leaving 10.9.10
if [[ ${COMPONENT} == "stable" ]]; then
NEW_VERSION=${{ matrix.release }}
NEW_MAJOR_VERSION="${NEW_VERSION#v}"
NEW_MAJOR_VERSION="${NEW_MAJOR_VERSION%.*}"
NEW_POINT_VERSION="${NEW_VERSION##*.}"
if [[ ${NEW_POINT_VERSION} -gt 0 ]]; then
LAST_POINT_VERSION=$(( NEW_POINT_VERSION - 1 ))
LAST_VERSION="${NEW_MAJOR_VERSION}.${LAST_POINT_VERSION}"
for PACKAGE in jellyfin jellyfin-server jellyfin-web; do
sudo reprepro --waitforlock 30 --basedir /srv/debian --component ${COMPONENT} remove ${{ matrix.release }} ${PACKAGE}=${LAST_VERSION}
done
fi
fi
- name: "Move artifacts into repository"
uses: appleboy/ssh-action@2ead5e36573f08b82fbfce1504f1a4b05a647c6f # v1.2.2
@@ -253,6 +283,36 @@ jobs:
# Only include the source DSC for amd64; the other architectures are the same and conflict
sudo reprepro --waitforlock 30 --basedir /srv/ubuntu --component ${COMPONENT} includedsc ${{ matrix.release }} /srv/incoming/server/${{ env.JELLYFIN_VERSION }}/ubuntu/${{ matrix.release }}/${{ matrix.arch }}/*.dsc || exit 1
fi
# Only keep ${NKEEP} (4) unstables; we have to do this manually since reprepro doesn't have granularity for this at the component level
if [[ ${COMPONENT} == "unstable" ]]; then
NKEEP=4
# Get whatever the oldest version is; since these are dated, a simple numerical sort works
LIST="$( sudo reprepro -b /srv/ubuntu -C unstable list ${{ matrix.release }} | awk '{ print $NF }' | sort -rn | uniq )"
COUNT=$( wc -l <<<"${LIST}" )
if [[ ${COUNT} -gt ${NKEEP} ]]; then
# Get anything that isn't in the latest ${NKEEP} entries
OBSOLETE=( sed "1,${NKEEP}d" <<<"${LIST}" )
for VERSION in ${OBSOLETE[@]}; do
for PACKAGE in jellyfin jellyfin-server jellyfin-web; do
sudo reprepro --waitforlock 30 --basedir /srv/ubuntu --component ${COMPONENT} remove ${{ matrix.release }} ${PACKAGE}=${VERSION}
done
done
fi
fi
# Only keep the latest point release for a given stable version; i.e. 10.10.14 obsoletes 10.10.13 and removes it, while leaving 10.9.10
if [[ ${COMPONENT} == "stable" ]]; then
NEW_VERSION=${{ matrix.release }}
NEW_MAJOR_VERSION="${NEW_VERSION#v}"
NEW_MAJOR_VERSION="${NEW_MAJOR_VERSION%.*}"
NEW_POINT_VERSION="${NEW_VERSION##*.}"
if [[ ${NEW_POINT_VERSION} -gt 0 ]]; then
LAST_POINT_VERSION=$(( NEW_POINT_VERSION - 1 ))
LAST_VERSION="${NEW_MAJOR_VERSION}.${LAST_POINT_VERSION}"
for PACKAGE in jellyfin jellyfin-server jellyfin-web; do
sudo reprepro --waitforlock 30 --basedir /srv/ubuntu --component ${COMPONENT} remove ${{ matrix.release }} ${PACKAGE}=${LAST_VERSION}
done
fi
fi
- name: "Move artifacts into repository"
uses: appleboy/ssh-action@2ead5e36573f08b82fbfce1504f1a4b05a647c6f # v1.2.2