#!/bin/bash -e LOGIN=pitti HOST=chinstrap.ubuntu.com if [ -z "$1" ]; then echo "Usage: $0 " exit 0 fi # open changes file exec 3<$1 # read until Files: section while true; do read -u 3 line if [ "$line" = "Files:" ]; then break fi done # read files count=0 while true; do read -u 3 md5sum size section priority fname if [ -z "$fname" ] || echo "$md5sum" | grep -q :; then break; fi files[$count]="$fname" ((count=count+1)) done if [ $count = 0 ]; then echo "No files found. Exiting." exit -1 fi echo "Uploading files to $HOST..." echo ${files[*]} $1 scp ${files[*]} $1 $LOGIN@$HOST: if grep -q '^Distribution:.*security' "$1"; then QUEUE=security else QUEUE=ubuntu fi echo "dput'ing to queue $QUEUE..." ssh $LOGIN@$HOST "dput -u $QUEUE $1 && rm ${files[*]} $1"