From fe885325b1a210c1a79eb91136d50fca72077435 Mon Sep 17 00:00:00 2001 From: Jose V Beneyto Date: Tue, 15 Oct 2013 11:15:31 +0200 Subject: [PATCH] Added checkOverlayUpdates.sh which gets ports from an overlay that need to be updated --- checkOverlayUpdates.sh | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 checkOverlayUpdates.sh diff --git a/checkOverlayUpdates.sh b/checkOverlayUpdates.sh new file mode 100755 index 0000000..d8b4fdc --- /dev/null +++ b/checkOverlayUpdates.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# This script gets ports from an overlay that need to be updated +# +# Note: Before execute this script you should be run 'ports -u' to be sure +# you're up to date + +checkOverlayUpdates() { + overlay=$1 + repo=${overlay/-arm*/} + + if [ "$overlay" == "$repo" ]; then + echo "Error, $overlay is not a valid overlay" + exit 1 + fi + + # check for existing repo + case $repo in + core|opt|xorg|contrib) ;; + *) echo "Error, $repo is not a valid repo"; exit 1;; + esac + + # obtain paths + overlay_path=$(grep 'destination' /etc/ports/$overlay.{rsync,httpup} 2>/dev/null | cut -d'=' -f2) + repo_path=$(grep 'destination' /etc/ports/$repo.{rsync,httpup} 2>/dev/null | cut -d'=' -f2) + + # foreach overlayed port check for updates available + find $overlay_path -type f -name 'Pkgfile' -exec dirname {} \; | while read o_port; do + port=$repo_path/$(basename $o_port) + # get versions for both (port and o_port) + . $port/Pkgfile + port_version=$version-$release + . $o_port/Pkgfile + o_port_version=$version-$release + if [ "$port_version" != "$o_port_version" ]; then + printf "%-20s %10s %10s\n" $(basename $port) $o_port_version $port_version >> $TMP_FILE + fi + done + + if [ "$(wc -l $TMP_FILE)" != "0" ]; then + printf "%-20s %10s %10s\n" "PORT" $overlay $repo + cat $TMP_FILE && : > $TMP_FILE + echo + fi +} + +if [ $# -lt 1 ]; then + echo "Usage: $(basename $0) [repo_overlay]" + exit 1 +fi + +TMP_FILE=$(mktemp) + +for TARGET in $@; do + checkOverlayUpdates $TARGET +done + +rm -f $TMP_FILE + +# End of file -- 2.26.2