#!/bin/bash

yxml=0;
nxml=0;

for i in `find /var/git/meta-repo/kits/*/*/* -maxdepth 0 -type d`; do
  # Filter out files, metadata and profiles directories
  if [ $(basename -- ${i%.*}) != "files" ] && [ `echo $i | grep -v profiles` ] && [ `echo $i | grep -v metadata` ]; then
    if [ `ls $i/metadata.xml 2>/dev/null` ]; then
      # Count packages with existing metadata.xml
      let yxml=$yxml+1;
    else
      # Count packages with missing metadata.xml
      echo "$i has no metadata";
      let nxml=$nxml+1;
    fi
  fi
done

echo "Packages with metadata.xml: $yxml
Packages without metadata.xml: $nxml";
