diff --git a/get_sources.sh b/get_sources.sh
index 5533cfe..f1dd30c 100755
--- a/get_sources.sh
+++ b/get_sources.sh
@@ -47,23 +47,19 @@ do
 done
 
 # check metadata file and extract package name
-found=0
 shopt -s nullglob
-for meta in .*.metadata
-do
-  pn=${meta%.metadata}
-  pn=${pn#.}
-  if [ -e "SPECS/$pn.spec" ]
-  then
-      found=1
-      break
-  fi
-done
-if (( $found != 1 ))
+set -- .*.metadata
+if (( $# == 0 ))
 then
-    echo 'Missing metadata or spec. Please run from inside a sources git repo'
+    echo 'Missing metadata. Please run from inside a sources git repo'
     exit 1
+elif (( $# > 1 ))
+then
+    echo "Warning: multiple metadata files found. Using $1"
 fi
+meta=$1
+pn=${meta%.metadata}
+pn=${pn#.}
 
 if [ ! -d .git ] || [ ! -d SPECS ]; then
   echo 'You need to run this from inside a sources git repo'