Skip to content

Commit

Permalink
_BUMPS_BRK → _BUMPS_RVW
Browse files Browse the repository at this point in the history
  • Loading branch information
xiota committed Nov 3, 2023
1 parent bf84d5d commit 1a872a2
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/lib/interfere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function interference-bump() {
set -euo pipefail

local _PACKAGES _PKGTAG _BUMPSFILE _BUMPS
local _BUMPS_TMP _BUMPS_UPD _BUMPS_BRK _BUMP _LINE
local _BUMPS_TMP _BUMPS_UPD _BUMPS_RVW _BUMP _LINE

_BUMPSFILE="${CAUR_INTERFERE}/PKGREL_BUMPS"

Expand All @@ -156,7 +156,7 @@ function interference-bump() {
_BUMPS=""
fi

# format: [name] [version]-pkgrel bump
# format: [name] [version]-[pkgrel] [bump]
_PACKAGES="$(
repoctl list -v \
| sed -E \
Expand All @@ -172,7 +172,7 @@ function interference-bump() {
<(sort -u <<<"${_BUMPS}" || true)
)

# combine with repo package listing
# combine mismatched package with current listing
_BUMPS_TMP+=$(
echo
while read -r _LINE; do
Expand All @@ -181,25 +181,26 @@ function interference-bump() {
done <<<"${_BUMPS_TMP}"
)

_BUMPS_BRK=$(
# _BUMPS_RVW will contain packages that need review.
# These are usually packages that have yet to be rebuils.
# The pkgver and pkgrel match, but bump is still mismatched.
_BUMPS_RVW=$(
echo
sort -u <<<"${_BUMPS_TMP}"
)

# remove broken packages; keep updated packages
# "broken" packages have same pkgver and pkgrel, but different bump
# "updated" packages have different pkgver or different pkgrel.
# _BUMPS_UPD will contain packages with new releases.
# The pkgver and pkgrel no longer match the bump list.
_BUMPS_UPD=$(
sed -Ez \
-e 's&\n(\S+ \S+) \S+\n\1 \S+\n&\n\n&g' \
-e 's&\n(\S+ \S+) \S+\n\1 \S+\n&\n\n&g' \
<<<"${_BUMPS_BRK}" | sort -u || true
<<<"${_BUMPS_RVW}" | sort -u || true
)

# broken packages only; for later review
_BUMPS_BRK=$(
_BUMPS_RVW=$(
comm -23 \
<(sort -u <<<"${_BUMPS_BRK}" || true) \
<(sort -u <<<"${_BUMPS_RVW}" || true) \
<(sort -u <<<"${_BUMPS_UPD}" || true)
)

Expand All @@ -213,24 +214,24 @@ function interference-bump() {
)
done <<<"${_BUMPS_TMP}"

# Add new bump or increase existing one
# add new bump or increase existing one
for _PKGTAG in "$@"; do
[[ -z "$_PKGTAG" ]] && continue
# increase existing bump
_LINE=$(grep -Esm1 "^$_PKGTAG " <<<"$_BUMPS" || true)
if [[ -z "$_LINE" ]]; then
# add new bump
_LINE=$(grep -Esm1 "^$_PKGTAG " <<<"$_PACKAGES" || true)
_BUMPS+=$'\n'"$_LINE"
[[ -n "$_LINE" ]] && _BUMPS+=$'\n'"$_LINE"
fi
if [[ -n "$_LINE" ]]; then
_BUMP=$(sed -E 's&^.* ([0-9]+)&\1&' <<<"$_LINE")
_BUMPS=$(sed -E 's&^('"${_LINE% *}"') '"$_BUMP"'$&\1 '"$((_BUMP + 1))"'&' <<<"$_BUMPS")
fi
done

# display broken packages for review
echo "${_BUMPS_BRK}" | sed -E 's& .*$&&' | sort -u
# display packages for review
echo "${_BUMPS_RVW}" | sed -E 's& .*$&&' | sort -u

# update bump file
sort -u <<<"${_BUMPS}" >"${_BUMPSFILE}"
Expand Down

0 comments on commit 1a872a2

Please sign in to comment.