changeset 112:0838fdca3a2b

Implemented the check-fast-track command to check installed packages that are installed from LocalBSDPorts against FreeBSD and LocalBSDPorts
author Franz Glasner <hg@dom66.de>
date Mon, 14 Oct 2019 16:52:34 +0200
parents fa73423234bf
children 2d531cbd0feb
files bin/fpkg
diffstat 1 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bin/fpkg	Mon Oct 14 14:38:04 2019 +0200
+++ b/bin/fpkg	Mon Oct 14 16:52:34 2019 +0200
@@ -43,6 +43,12 @@
 
     `pkg upgrade -n` on the local host and all running visible jails
 
+  check-fast-track
+    Check packages installed from the LocalBSDPorts repository against
+    the repositories `FreeBSD` and `LocalBSDPorts` on the local host
+    and all visible jails
+     
+
 ENVIRONMENT:
 
   FPKG_AUDIT_FLAGS
@@ -81,6 +87,18 @@
 : ${FPKG_SIGN:='===> '}
 : ${FPKG_SKIPSIGN:='----> '}
 
+#
+# The official FreeBSD binary repository
+#
+: ${FREEBSD_REPO:=FreeBSD}
+
+#
+# Local repository with ports with default OPTIONS (i.e. unchanged)
+# but newer than the packages in the "FreeBSD" repository.
+# Some sort of a fast-track repository.
+#
+: ${LOCALBSDPORTS_REPO:=LocalBSDPorts}
+
 
 has_same_userland_version() {
     : 'Check whether the jail `_jail` has the same FreeBSD userland version
@@ -178,6 +196,45 @@
 }
 
 
+command_check_fasttrack() {
+    : 'Check the fast-track repository versions against the canonical
+    FreeBSD repository versions.
+
+    Input (Globals):
+        FREEBSD_REPO:       the (canonical) FreeBSD repository name
+        LOCALBSDPORTS_REPO: the fast-track repository name
+
+    '
+    local _name local _repo _j
+
+    echo "${FPKG_SIGN}LOCALHOST"
+    pkg query '%n %R' |
+        while read _name _repo; do
+            if [ "${_repo}" = "${LOCALBSDPORTS_REPO}" ]; then
+                echo "   ${_name}"
+                printf "      %-15s : %s\n" "${LOCALBSDPORTS_REPO}" "$(pkg version -r ${LOCALBSDPORTS_REPO} -n ${_name} -v)"
+                printf "      %-15s : %s\n" "${FREEBSD_REPO}" "$(pkg version -r ${FREEBSD_REPO} -n ${_name} -v)"
+            fi
+        done
+    for _j in $(jls -N | awk '{if(NR>1)print $1}' | sort); do
+        echo ""
+        echo "${FPKG_SIGN}JAIL: ${_j}"
+        if has_same_userland_version "${_j}"; then
+            pkg -j "${_j}" query '%n %R' |
+                while read _name _repo; do
+                    if [ "${_repo}" = "${LOCALBSDPORTS_REPO}" ]; then
+                        echo "   ${_name}"
+                        printf "      %s-15s : %s\n" "${LOCALBSDPORTS_REPO}" "$(pkg -j ${_j} version -r ${LOCALBSDPORTS_REPO} -n ${_name} -v)"
+                        printf "      %-15s : %s\n" "${FREEBSD_REPO}" "$(pkg -j ${_j} version -r ${FREEBSD_REPO} -n ${_name} -v)"
+            fi
+                done
+        else
+            echo "${FPKG_SKIPSIGN}SKIPPED because of different userland"
+        fi
+    done
+}
+
+
 #
 # Global option handling
 #
@@ -226,6 +283,9 @@
     upgrade-check|upgrade_check)
         command_upgrade_check "$@"
         ;;
+    check-fast-track|check-fasttrack|check_fast_track|check_fasttrack)
+        command_check_fasttrack "$@"
+        ;;
     *)
         echo "ERROR: unknown command \`${command}'" >&2
         exit 2;