minor improvements
[distro-functions] / src / identify-distros
index 9c2221f43b7826137f1bbe3206984321fa3356eb..67d960820e6463cc1f6068b94de2c7da01933c11 100644 (file)
@@ -91,9 +91,34 @@ EOF
     fi
   done < <(echo "$policy" | sed -rn "$expression" | sort -rn || [[ $? == 141 ]])
   echo "$shortest"
-
 }
 
+# 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
+}
 
 isdebian-testing() {
   [[ $(debian-archive) == testing ]]
@@ -118,6 +143,9 @@ debian-codename-compat() {
     etiona)
       echo bionic
       ;;
+    nabia)
+      echo focal
+      ;;
     *)
       echo $n
       ;;