How do I build a Linux environment that specifies specific versions of packages?

It looks like it sees the package you want, but for whatever reason is installing from the updates repository.

You can disable the updates repository in your yum command;

yum install -y $package --disablerepo=updates