#!/bin/bash #-- make sure we know how to handle the distro # Each file needs to define a function called get_source that will # be passed the working directory and a package name, and that must # return the full absolute path to the source tree. # # A similar remove_source function must also be defined (same parameters) # that just removes everything created in the working directory for this # package. # get_source() { pwd=$(pwd) workdir="$1" pkg="$2" #-- set up the proper environment cd "$workdir" [ ! -d $pkg ] && mkdir $pkg cd $pkg [ ! -d rpmbuild ] && mkdir rpmbuild for ii in BUILD SOURCES SPECS SRPMS do [ ! -d rpmbuild/$ii ] && mkdir rpmbuild/$ii done rpmhome="$workdir/$pkg" #-- fetch the bits from fedpkg if [ -d $pkg ] then res=$(cd $pkg; fedpkg pull >/dev/null 2>&1) else res=$(fedpkg clone -a $pkg >/dev/null 2>&1) fi if [ ! -d $pkg ] then echo "" cd $pwd exit 1 fi #-- get the srpm made cd $pkg res=$(fedpkg srpm >/dev/null 2>&1) fname=$(ls -1 *.src.rpm | head -1) if [ -z "$fname" ] then echo "" cd $pwd exit 1 fi #-- unpack the srpm srpm=$(ls -1 | grep .src.rpm | head -1) res=$(HOME=$rpmhome rpm -i $srpm >/dev/null 2>&1) #-- unpack the source and apply the patches cd $rpmhome/rpmbuild/SPECS res=$(HOME=$rpmhome rpmbuild --nodeps -bp ${pkg}.spec >/dev/null 2>&1) #-- all done. as you were. and report the path. path=$(ls $rpmhome/rpmbuild/BUILD | grep $pkg | head -1) if [ ! -z $path ] then echo $rpmhome/rpmbuild/BUILD/$path else echo "" fi cd $pwd } remove_source () { pwd=$(pwd) workdir="$1" pkg="$2" cd "$workdir" rm -rf $pkg >/dev/null 2>&1 cd $pwd }