downloading sourcecs in an RPM specfile
22 Aug 2008Here's a quick hack to download all sourcefiles from a specfile automatically.
#!/bin/bash
specfile=$1
OLDIFS=$IFS
IFS="
"
sedcmd="sed"
for varline in `cat "$specfile" |grep "^%define"`;
do
var=`echo "$varline" | awk '{print $2}'`
val=`echo "$varline" | awk '{print $3}'`
sedscript="s:%{$var}:$val:g"
sedcmd="$sedcmd -e $sedscript"
done
IFS=$OLDIFS
mkdir -p /usr/src/redhat/SOURCES
for url in `cat $specfile | $sedcmd | grep "^Source" | awk '{print $2}'`;
do
f=`echo "$url" | sed 's:.*/::'`
wget -O "/usr/src/redhat/SOURCES/$f" "$url"
done