unos-repository

APK repository for unos
git clone git://git.finwo.net/misc/unos-repository
Log | Files | Refs | README

channel-lint.sh (1199B)


      1 #!/bin/sh
      2 # mk/channel-lint.sh - reject dead overlays.
      3 #
      4 # A layer carrying a package identical to the one it shadows wins forever and
      5 # stops tracking its upstream. That is what a graduation done by copy instead
      6 # of git mv leaves behind, and nothing else in the build would notice.
      7 set -eu
      8 
      9 HERE=$(cd "$(dirname "$0")" && pwd)
     10 ROOT=$(cd "${HERE}/.." && pwd)
     11 
     12 # shellcheck disable=SC1091
     13 . "${HERE}/channels.inc"
     14 
     15 rc=0
     16 
     17 for d in "${CHANDIR}"/*/; do
     18 	channel=$(basename "${d}")
     19 	chan_exists "${channel}" || continue
     20 	upstream=$(chan_conf "${channel}" upstream)
     21 	[ -n "${upstream}" ] || continue
     22 
     23 	for pkg in "${d}packages"/*/; do
     24 		[ -d "${pkg}" ] || continue
     25 		name=$(basename "${pkg}")
     26 
     27 		shadowed=
     28 		for layer in $(chan_layers "${upstream}"); do
     29 			[ -d "${CHANDIR}/${layer}/packages/${name}" ] \
     30 				&& shadowed="${CHANDIR}/${layer}/packages/${name}"
     31 		done
     32 		[ -n "${shadowed}" ] || continue
     33 
     34 		if diff -r -q "${shadowed}" "${pkg}" >/dev/null 2>&1; then
     35 			printf 'channel-lint: %s/packages/%s is identical to %s\n' \
     36 				"${channel}" "${name}" \
     37 				"$(basename "$(dirname "$(dirname "${shadowed}")")")" >&2
     38 			rc=1
     39 		fi
     40 	done
     41 done
     42 
     43 [ "${rc}" = 0 ] && printf 'channel-lint: OK\n'
     44 exit "${rc}"