#! /bin/bash if [ $# != 3 ]; then echo "Usage: $0 "; exit; fi if [ ! -d $1 ]; then echo "Missing RPM dir"; exit; fi if [ ! -d $2 ]; then echo "Missing SRPM dir"; exit; fi if [ ! -f $3 ]; then echo "Missing file list"; exit; fi if [ -d RPMS ]; then echo "./RPMS dir already exists, will not risk overwriting"; exit; fi if [ -d SRPMS ]; then echo "./SRPMS dir already exists, will not risk overwriting"; exit; fi mkdir RPMS; mkdir SRPMS; #Returns the cleaned up list of RPMs in an image, strip empty lines cat $3 | sed -e 's/^#.*//' -e 's/--.*$//' | grep -v "^$" | while read i; do if [ ! -f $1/$i ]; then echo "Missing RPM file: $1/$i"; exit; fi cp -a $1/$i ./RPMS/; # Returns the SRPM that originated this RPM j=`rpm -qp --info $1/$i | grep "Source RPM" | sed -e 's/^.*Source RPM: //';` if [ ! -f $2/$j ]; then echo "Missing SRPM file: $2/$j"; exit; fi cp -a $2/$j ./SRPMS/; done; echo "Success";