Refactor code for getting dependencies in build_model_rpm.py