#!/bin/bash # hendry@hannux.com # Input: .changes file # Output: Copies files listed in the .changes file to the mirror # TODO: Run apt-ftparchive after this # Props to #bash on Freenode FLATREPO=/home/hendry/packages/dapper MIRROR=/home/hendry/mirror/pool/main for DOTCHANGES in $FLATREPO/*.changes; do FILELIST="" TEMPFILE=`tempfile` # Grab the Files bit to the changes file: grep -A7 ^Files: $DOTCHANGES | grep -v ^Files: > $TEMPFILE exec < $TEMPFILE # http://wooledge.org/mywiki/BashFaq#faq24 while read line do [[ $line ]] || break # quit on empty line md5=`echo $line | awk '{print $1}'` filename="`dirname $DOTCHANGES`/`echo $line | awk '{print $NF}'`" [[ `md5sum $filename | awk '{print $1}'` == $md5 ]] || { echo $filename md5sum mismatch; exit 1; } FILELIST="$FILELIST $filename" done rm $TEMPFILE # don't need this anymore SOURCE=`grep ^Source: $DOTCHANGES | awk '{print $NF}'` TODIR=$MIRROR/${SOURCE::1}/$SOURCE [[ -d $TODIR ]] && rm -rf $TODIR # if something is already there, nuke it mkdir -p $TODIR cp -v $FILELIST $TODIR done