#!/bin/bash

for rpm in $(find -name xmlsec1-devel*); do
  is_debug="$(echo $rpm | grep debuginfo)"
  if [ "$is_debug" == "" ]; then
   arch="$(echo $rpm | rev | cut -d. -f2 | rev)"
   #echo $rpm $arch
   if [ "$arch" == "x86_64" ] || [ "$arch" == "noarch" ] || [ "$arch" == "src" ] || [ "$arch" == "i386" ] || [ "$arch" == "i686" ]; then
     key="centos7official"
   elif  [ "$arch" == "ppc" ] || [ "$arch" == "ppc64" ] || [ "$arch" == "ppc64le" ]; then
     key="centos7ppc64"
   elif [ "$arch" == "armv7hl" ]; then
     key="centos7arm32"
   elif [ "$arch" == "aarch64" ]; then
     key="centos7aarch64"
   fi
  else
     arch="debuginfo"
     key="centos7debuginfo2"
  fi

#echo $rpm $arch $key

#not_signed=$(rpm -qpi $rpm 2> /dev/null| grep "^Signature" | grep -v "(none)")

#if [ "$not_signed" == ""  ]; then
  echo $rpm $arch $key
  rpm-sign --key=$key $rpm
  echo "------------------------------"
#else
#  echo $rpm is already signed
#fi
     
done
