CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Added checkOverlayUpdates.sh which gets ports from an overlay that need to be updated
authorJose V Beneyto <sepen@crux.nu>
Tue, 15 Oct 2013 09:15:31 +0000 (11:15 +0200)
committerJose V Beneyto <sepen@crux.nu>
Tue, 15 Oct 2013 09:15:31 +0000 (11:15 +0200)
checkOverlayUpdates.sh [new file with mode: 0755]

diff --git a/checkOverlayUpdates.sh b/checkOverlayUpdates.sh
new file mode 100755 (executable)
index 0000000..d8b4fdc
--- /dev/null
@@ -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