#! /bin/sh set -e case $# in 0 | 1 | 2 | 3) echo >&2 "Usage: $0 HOST PATH ARCH:ARCH:... DIST..." exit 1 ;; *) RSYNC_HOST=$1 RSYNC_PATH=$2 WANT_ARCH=$3; shift 3 ;; esac ## Check the available distributions for architectures. : ${RSYNC="rsync"} for dist in "$@"; do $RSYNC --list-only $RSYNC_HOST::$RSYNC_PATH/dists/$dist/main/ done | { ## Gather up excluded architectures as we go. excludes="" while read mode size date time name; do ## Check directories of binary packages. If it's an architecture we ## don't want to reject, then continue on. case "$name" in binary-all) continue ;; binary-*) arch=${name#binary-} case ":$WANT_ARCH:" in *:"$arch":*) continue ;; esac ;; *) continue ;; esac ## Pick out the architecture name. Check whether we've seen it before. arch=${name#binary-} case " $excludes " in *" $arch "*) ;; *) excludes="${excludes+$excludes }$arch" ;; esac done ## Done. Print out the finished list. echo $excludes }