Avoid tripping up on multiple results When ensuring dirs for secondary arches, correctly handle multiple directories matching the pattern Change-Id: Ia6c2acb3be11b7e81efb143668754b83c7a517b3 Signed-off-by: Mat Booth <mat.booth@redhat.com> Reviewed-on: https://git.eclipse.org/r/c/linuxtools/org.eclipse.linuxtools.eclipse-build/+/171805
diff --git a/utils/ensure_arch.sh b/utils/ensure_arch.sh index a53a5b1..176de8a 100755 --- a/utils/ensure_arch.sh +++ b/utils/ensure_arch.sh
@@ -8,23 +8,25 @@ # $ ensure_arch.sh bundleDir sourceArch targetArch targetArch ... pushd $1 1>/dev/null -src=$(ls | grep -e "gtk\.linux\.$2$" || ls | grep -e "linux\.$2$") -if [ -z "$src" ] ; then +srcs=$(ls | grep -e "gtk\.linux\.$2$" || ls | grep -e "linux\.$2$") +if [ -z "$srcs" ] ; then echo "no bundle found for $2" exit 1 fi for a in ${@:3} ; do - tgt=${src/$2/$a} - if [ -d "$tgt" ] ; then - echo "bundle $tgt already exists" - else - cp -r ${src} $tgt - for f in $(cd $tgt && find . -type f | grep $2) ; do - mv $tgt/$f $tgt/${f/$2/$a} - done - find $tgt -type f -exec sed -i -e "s/$2/$a/g" {} \; - echo "bundle $tgt created" - fi + for src in $srcs ; do + tgt=${src/$2/$a} + if [ -d "$tgt" ] ; then + echo "bundle $tgt already exists" + else + cp -r ${src} $tgt + for f in $(cd $tgt && find . -type f | grep $2) ; do + mv $tgt/$f $tgt/${f/$2/$a} + done + find $tgt -type f -exec sed -i -e "s/$2/$a/g" {} \; + echo "bundle $tgt created" + fi + done done popd 1>/dev/null