On Tue, 2010-12-21 at 18:32 -0700, Michal Jaegermann wrote:
On Tue, Dec 21, 2010 at 06:12:47PM -0500, James Laska wrote:
> Something to help testers find the right src.rpm name of the
> component under test?
Something like that?
Exactly, thanks for sharing. I've added some comments below for some
common gotchas that always get me with bash scripts. Hope it's helpful.
#!/bin/bash
me=$(basename $0)
usage () {
echo "Usage: $me <name>"
echo "where <name> is either path to a file or an rpm package name"
exit 1
}
[ -z "$1" ] && usage
arg="$1"
case $arg in
*/*) file="-f" ;;
esac
It might be a bit more error-proof to use, since the file argument could
be in the current directory (no '/'):
test -f %{arg} && file="-f" || file=""
pkg=$(rpm -q $file --qf '%{sourcerpm}\n' $arg|head -1)
If conditionally initializing the value of $file, you might want to
provide a default value above. Perhaps something like the following to
default to the empty '' string if no value is set. If you use the
earlier statement, it will be initialized.
${file:-}
bname=${pkg%-*}
echo ${bname%-*}
Nice, I didn't realize that a single '%' would do the *shortest* match.
Thanks!
echo ${pkg%.src.rpm}
exit
You can pass here as an argument /sbin/dmsetup or device-mapper with
the same effect (source package for these is called 'lvm2').
Yeah, exactly. As an extra data point, dmalcolm posted a somewhat
script that opens up a bugzilla web page to assist in filing a bug
against a component. I'm sure that could be adjusted to find the
%{sourcerpm} name using the procedure you outlined.
http://lists.fedoraproject.org/pipermail/test/2010-December/096079.html
Thanks,
James