That's not the intended use case of system packages.
System packaging systems, such as rpm or Debian, are intended to package software for distribution to other Linux machines. It is very much a feature that they install files and run scripts as the root user. What you are doing sounds more closely aligned to what configuration management software, such as puppet or SaltStack, might be used for.
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.