From 6b68e9628c373bb2498335e5a1828620dd12416f Mon Sep 17 00:00:00 2001 From: Jose V Beneyto Date: Wed, 6 Nov 2013 11:28:20 +0100 Subject: [PATCH] Implemented -arm support to checkOverlayUpdates.sh script (FS#63) --- checkOverlayUpdates.sh | 73 ++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/checkOverlayUpdates.sh b/checkOverlayUpdates.sh index d8b4fdc..245f937 100755 --- a/checkOverlayUpdates.sh +++ b/checkOverlayUpdates.sh @@ -2,59 +2,68 @@ # # This script gets ports from an overlay that need to be updated # +# Requeriments: You need 'ports' and 'prt-get' installed # 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 + overlay=$1 - # check for existing repo - case $repo in - core|opt|xorg|contrib) ;; - *) echo "Error, $repo is not a valid repo"; exit 1;; + # check for a valid overlay + case $overlay in + core-arm|opt-arm|xorg-arm|contrib-arm) ;; + cubieboard-arm|cubieboard2-arm|efikamx-arm|raspberrypi-arm) ;; + *) + echo "Error, unsupported overlay: $overlay" + exit 1 + ;; esac - - # obtain paths + + # get a list of ports in the overlay 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 + overlay_ports=$(find $overlay_path -type f -name 'Pkgfile' -exec dirname {} \; | sed "s|$overlay_path/||g") + + # for device overlay repos we need to know the upstream repo/port + for port in $overlay_ports; do + # get upstream repo/port + for repo in core opt xorg; do + repo_path=$(grep 'destination' /etc/ports/$repo.{rsync,httpup} 2>/dev/null | cut -d'=' -f2) + u_repo=$(basename $(dirname $(prt-get --no-std-config --config-prepend="prtdir $repo_path" path $port 2>/dev/null) 2>/dev/null) 2>/dev/null) + # breaks if there is an upstream repo + [ ! -z $u_repo ] && break + done + # show differences between upstream port and overlayed port + if [ ! -z $u_repo ]; then + # get versions + . $repo_path/$port/Pkgfile + u_port_version=$version-$release + . $overlay_path/$port/Pkgfile + o_port_version=$version-$release + if [ "$u_port_version" != "$o_port_version" ]; then + printf "%-20s %-20s %-s\n" $port "$o_port_version" "$u_port_version ($u_repo)" >> $TMP_FILE + fi fi done - - if [ "$(wc -l $TMP_FILE)" != "0" ]; then - printf "%-20s %10s %10s\n" "PORT" $overlay $repo + + # print results + if [ "$(wc -l $TMP_FILE | cut -d' ' -f1)" != "0" ]; then + echo "Results for overlay: $overlay" + printf "%-20s %-20s %-s\n" "PORT" "VERSION" "UPSTREAM" cat $TMP_FILE && : > $TMP_FILE echo fi } if [ $# -lt 1 ]; then - echo "Usage: $(basename $0) [repo_overlay]" + echo "Usage: $(basename $0) [overlay_repo]" exit 1 fi -TMP_FILE=$(mktemp) - for TARGET in $@; do + TMP_FILE=$(mktemp) checkOverlayUpdates $TARGET + rm -f $TMP_FILE done -rm -f $TMP_FILE - # End of file -- 2.26.2