+# formatted for use in pfile in brc
+positive-origins() {
+ isdeb || return 0
+ local archive expression pri name highpri shortest
+ local policy="${1:-$(apt-cache policy)}" || return $?
+ # a = archive
+ # n = codename
+ # o = origin
+ # c = component (licensing component)
+ # l = label (Debian{,-Security,-Updates})
+ read -rd '' expression <<EOF ||:
+/^ *([-0-9]+).*/{s/^ *([-0-9]+).*/\1/;h}
+/^.*o=([^,]+).*/{s/^.*o=([^,]+).*/ \1/;H;x;s/\n//;p}
+EOF
+ origins=
+ while read -r pri name; do
+ if (( pri > 0 )); then
+ if [[ ! $origins ]]; then
+ origins=$name
+ else
+ origins+=,$name
+ fi
+ fi
+ done < <(echo "$policy" | sed -rn "$expression" | sort -rn || [[ $? == 141 ]])
+ echo $origins
+}